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_ARMWhileLoop : SDTypeProfile<0, 2, [SDTCisVT<0, i32>,
112 SDTCisVT<1, OtherVT>]>;
114 def ARMSmlald : SDNode<"ARMISD::SMLALD", SDT_LongMac>;
115 def ARMSmlaldx : SDNode<"ARMISD::SMLALDX", SDT_LongMac>;
116 def ARMSmlsld : SDNode<"ARMISD::SMLSLD", SDT_LongMac>;
117 def ARMSmlsldx : SDNode<"ARMISD::SMLSLDX", SDT_LongMac>;
119 def SDT_MulHSR : SDTypeProfile<1, 3, [SDTCisVT<0,i32>,
122 SDTCisSameAs<0, 3>]>;
124 def ARMsmmlar : SDNode<"ARMISD::SMMLAR", SDT_MulHSR>;
125 def ARMsmmlsr : SDNode<"ARMISD::SMMLSR", SDT_MulHSR>;
128 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
129 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
130 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntUnaryOp>;
132 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
133 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
134 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
135 [SDNPHasChain, SDNPSideEffect,
136 SDNPOptInGlue, SDNPOutGlue]>;
137 def ARMcopystructbyval : SDNode<"ARMISD::COPY_STRUCT_BYVAL" ,
139 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
140 SDNPMayStore, SDNPMayLoad]>;
142 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
143 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
145 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
146 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
148 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
149 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
152 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
153 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
154 def ARMintretflag : SDNode<"ARMISD::INTRET_FLAG", SDT_ARMcall,
155 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
156 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
158 def ARMsubs : SDNode<"ARMISD::SUBS", SDTIntBinOp, [SDNPOutGlue]>;
160 def ARMssatnoshift : SDNode<"ARMISD::SSAT", SDTIntSatNoShOp, []>;
162 def ARMusatnoshift : SDNode<"ARMISD::USAT", SDTIntSatNoShOp, []>;
164 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
165 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
167 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
169 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
172 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
175 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
178 def ARMcmn : SDNode<"ARMISD::CMN", SDT_ARMCmp,
181 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
182 [SDNPOutGlue, SDNPCommutative]>;
184 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
186 def ARMasrl : SDNode<"ARMISD::ASRL", SDT_ARMIntShiftParts, []>;
187 def ARMlsrl : SDNode<"ARMISD::LSRL", SDT_ARMIntShiftParts, []>;
188 def ARMlsll : SDNode<"ARMISD::LSLL", SDT_ARMIntShiftParts, []>;
190 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
191 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
192 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
194 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
196 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
197 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
198 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
200 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
201 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
202 SDT_ARMEH_SJLJ_Setjmp,
203 [SDNPHasChain, SDNPSideEffect]>;
204 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
205 SDT_ARMEH_SJLJ_Longjmp,
206 [SDNPHasChain, SDNPSideEffect]>;
207 def ARMeh_sjlj_setup_dispatch: SDNode<"ARMISD::EH_SJLJ_SETUP_DISPATCH",
208 SDT_ARMEH_SJLJ_SetupDispatch,
209 [SDNPHasChain, SDNPSideEffect]>;
211 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
212 [SDNPHasChain, SDNPSideEffect]>;
213 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
214 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
216 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
217 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
219 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
221 def ARMmemcopy : SDNode<"ARMISD::MEMCPY", SDT_ARMMEMCPY,
222 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
223 SDNPMayStore, SDNPMayLoad]>;
225 def ARMsmulwb : SDNode<"ARMISD::SMULWB", SDTIntBinOp, []>;
226 def ARMsmulwt : SDNode<"ARMISD::SMULWT", SDTIntBinOp, []>;
227 def ARMsmlalbb : SDNode<"ARMISD::SMLALBB", SDT_LongMac, []>;
228 def ARMsmlalbt : SDNode<"ARMISD::SMLALBT", SDT_LongMac, []>;
229 def ARMsmlaltb : SDNode<"ARMISD::SMLALTB", SDT_LongMac, []>;
230 def ARMsmlaltt : SDNode<"ARMISD::SMLALTT", SDT_LongMac, []>;
232 // Vector operations shared between NEON and MVE
234 def ARMvdup : SDNode<"ARMISD::VDUP", SDTypeProfile<1, 1, [SDTCisVec<0>]>>;
236 // VDUPLANE can produce a quad-register result from a double-register source,
237 // so the result is not constrained to match the source.
238 def ARMvduplane : SDNode<"ARMISD::VDUPLANE",
239 SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>,
242 def SDTARMVSHUF : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0, 1>]>;
243 def ARMvrev64 : SDNode<"ARMISD::VREV64", SDTARMVSHUF>;
244 def ARMvrev32 : SDNode<"ARMISD::VREV32", SDTARMVSHUF>;
245 def ARMvrev16 : SDNode<"ARMISD::VREV16", SDTARMVSHUF>;
247 def SDTARMVGETLN : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisInt<1>,
249 def ARMvgetlaneu : SDNode<"ARMISD::VGETLANEu", SDTARMVGETLN>;
250 def ARMvgetlanes : SDNode<"ARMISD::VGETLANEs", SDTARMVGETLN>;
252 def SDTARMVMOVIMM : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVT<1, i32>]>;
253 def ARMvmovImm : SDNode<"ARMISD::VMOVIMM", SDTARMVMOVIMM>;
254 def ARMvmvnImm : SDNode<"ARMISD::VMVNIMM", SDTARMVMOVIMM>;
255 def ARMvmovFPImm : SDNode<"ARMISD::VMOVFPIMM", SDTARMVMOVIMM>;
258 def SDTARMVSHIMM : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
260 def SDTARMVSH : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
261 SDTCisSameAs<0, 2>,]>;
262 def ARMvshlImm : SDNode<"ARMISD::VSHLIMM", SDTARMVSHIMM>;
263 def ARMvshrsImm : SDNode<"ARMISD::VSHRsIMM", SDTARMVSHIMM>;
264 def ARMvshruImm : SDNode<"ARMISD::VSHRuIMM", SDTARMVSHIMM>;
265 def ARMvshls : SDNode<"ARMISD::VSHLs", SDTARMVSH>;
266 def ARMvshlu : SDNode<"ARMISD::VSHLu", SDTARMVSH>;
268 def ARMWLS : SDNode<"ARMISD::WLS", SDT_ARMWhileLoop,
271 //===----------------------------------------------------------------------===//
272 // ARM Flag Definitions.
274 class RegConstraint<string C> {
275 string Constraints = C;
278 //===----------------------------------------------------------------------===//
279 // ARM specific transformation functions and pattern fragments.
282 // imm_neg_XFORM - Return the negation of an i32 immediate value.
283 def imm_neg_XFORM : SDNodeXForm<imm, [{
284 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), SDLoc(N), MVT::i32);
287 // imm_not_XFORM - Return the complement of a i32 immediate value.
288 def imm_not_XFORM : SDNodeXForm<imm, [{
289 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), SDLoc(N), MVT::i32);
292 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
293 def imm16_31 : ImmLeaf<i32, [{
294 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
297 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
298 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
299 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
302 def sext_bottom_16 : PatFrag<(ops node:$a),
303 (sext_inreg node:$a, i16)>;
304 def sext_top_16 : PatFrag<(ops node:$a),
305 (i32 (sra node:$a, (i32 16)))>;
307 def bb_mul : PatFrag<(ops node:$a, node:$b),
308 (mul (sext_bottom_16 node:$a), (sext_bottom_16 node:$b))>;
309 def bt_mul : PatFrag<(ops node:$a, node:$b),
310 (mul (sext_bottom_16 node:$a), (sra node:$b, (i32 16)))>;
311 def tb_mul : PatFrag<(ops node:$a, node:$b),
312 (mul (sra node:$a, (i32 16)), (sext_bottom_16 node:$b))>;
313 def tt_mul : PatFrag<(ops node:$a, node:$b),
314 (mul (sra node:$a, (i32 16)), (sra node:$b, (i32 16)))>;
316 /// Split a 32-bit immediate into two 16 bit parts.
317 def hi16 : SDNodeXForm<imm, [{
318 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, SDLoc(N),
322 def lo16AllZero : PatLeaf<(i32 imm), [{
323 // Returns true if all low 16-bits are 0.
324 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
327 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
328 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
330 // An 'and' node with a single use.
331 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
332 return N->hasOneUse();
335 // An 'xor' node with a single use.
336 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
337 return N->hasOneUse();
340 // An 'fmul' node with a single use.
341 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
342 return N->hasOneUse();
345 // An 'fadd' node which checks for single non-hazardous use.
346 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
347 return hasNoVMLxHazardUse(N);
350 // An 'fsub' node which checks for single non-hazardous use.
351 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
352 return hasNoVMLxHazardUse(N);
355 //===----------------------------------------------------------------------===//
356 // Operand Definitions.
359 // Immediate operands with a shared generic asm render method.
360 class ImmAsmOperand<int Low, int High> : AsmOperandClass {
361 let RenderMethod = "addImmOperands";
362 let PredicateMethod = "isImmediate<" # Low # "," # High # ">";
363 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]";
366 class ImmAsmOperandMinusOne<int Low, int High> : AsmOperandClass {
367 let PredicateMethod = "isImmediate<" # Low # "," # High # ">";
368 let DiagnosticType = "ImmRange" # Low # "_" # High;
369 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]";
372 // Operands that are part of a memory addressing mode.
373 class MemOperand : Operand<i32> { let OperandType = "OPERAND_MEMORY"; }
376 // FIXME: rename brtarget to t2_brtarget
377 def brtarget : Operand<OtherVT> {
378 let EncoderMethod = "getBranchTargetOpValue";
379 let OperandType = "OPERAND_PCREL";
380 let DecoderMethod = "DecodeT2BROperand";
383 // Branches targeting ARM-mode must be divisible by 4 if they're a raw
385 def ARMBranchTarget : AsmOperandClass {
386 let Name = "ARMBranchTarget";
389 // Branches targeting Thumb-mode must be divisible by 2 if they're a raw
391 def ThumbBranchTarget : AsmOperandClass {
392 let Name = "ThumbBranchTarget";
395 def arm_br_target : Operand<OtherVT> {
396 let ParserMatchClass = ARMBranchTarget;
397 let EncoderMethod = "getARMBranchTargetOpValue";
398 let OperandType = "OPERAND_PCREL";
401 // Call target for ARM. Handles conditional/unconditional
402 // FIXME: rename bl_target to t2_bltarget?
403 def arm_bl_target : Operand<i32> {
404 let ParserMatchClass = ARMBranchTarget;
405 let EncoderMethod = "getARMBLTargetOpValue";
406 let OperandType = "OPERAND_PCREL";
409 // Target for BLX *from* ARM mode.
410 def arm_blx_target : Operand<i32> {
411 let ParserMatchClass = ThumbBranchTarget;
412 let EncoderMethod = "getARMBLXTargetOpValue";
413 let OperandType = "OPERAND_PCREL";
416 // A list of registers separated by comma. Used by load/store multiple.
417 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
418 def reglist : Operand<i32> {
419 let EncoderMethod = "getRegisterListOpValue";
420 let ParserMatchClass = RegListAsmOperand;
421 let PrintMethod = "printRegisterList";
422 let DecoderMethod = "DecodeRegListOperand";
425 // A list of general purpose registers and APSR separated by comma.
427 def RegListWithAPSRAsmOperand : AsmOperandClass { let Name = "RegListWithAPSR"; }
428 def reglist_with_apsr : Operand<i32> {
429 let EncoderMethod = "getRegisterListOpValue";
430 let ParserMatchClass = RegListWithAPSRAsmOperand;
431 let PrintMethod = "printRegisterList";
432 let DecoderMethod = "DecodeRegListOperand";
435 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
437 def DPRRegListAsmOperand : AsmOperandClass {
438 let Name = "DPRRegList";
439 let DiagnosticType = "DPR_RegList";
441 def dpr_reglist : Operand<i32> {
442 let EncoderMethod = "getRegisterListOpValue";
443 let ParserMatchClass = DPRRegListAsmOperand;
444 let PrintMethod = "printRegisterList";
445 let DecoderMethod = "DecodeDPRRegListOperand";
448 def SPRRegListAsmOperand : AsmOperandClass {
449 let Name = "SPRRegList";
450 let DiagnosticString = "operand must be a list of registers in range [s0, s31]";
452 def spr_reglist : Operand<i32> {
453 let EncoderMethod = "getRegisterListOpValue";
454 let ParserMatchClass = SPRRegListAsmOperand;
455 let PrintMethod = "printRegisterList";
456 let DecoderMethod = "DecodeSPRRegListOperand";
459 def FPSRegListWithVPRAsmOperand : AsmOperandClass { let Name =
460 "FPSRegListWithVPR"; }
461 def fp_sreglist_with_vpr : Operand<i32> {
462 let EncoderMethod = "getRegisterListOpValue";
463 let ParserMatchClass = FPSRegListWithVPRAsmOperand;
464 let PrintMethod = "printRegisterList";
466 def FPDRegListWithVPRAsmOperand : AsmOperandClass { let Name =
467 "FPDRegListWithVPR"; }
468 def fp_dreglist_with_vpr : Operand<i32> {
469 let EncoderMethod = "getRegisterListOpValue";
470 let ParserMatchClass = FPDRegListWithVPRAsmOperand;
471 let PrintMethod = "printRegisterList";
474 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
475 def cpinst_operand : Operand<i32> {
476 let PrintMethod = "printCPInstOperand";
480 def pclabel : Operand<i32> {
481 let PrintMethod = "printPCLabel";
484 // ADR instruction labels.
485 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
486 def adrlabel : Operand<i32> {
487 let EncoderMethod = "getAdrLabelOpValue";
488 let ParserMatchClass = AdrLabelAsmOperand;
489 let PrintMethod = "printAdrLabelOperand<0>";
492 def neon_vcvt_imm32 : Operand<i32> {
493 let EncoderMethod = "getNEONVcvtImm32OpValue";
494 let DecoderMethod = "DecodeVCVTImmOperand";
497 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
498 def rot_imm_XFORM: SDNodeXForm<imm, [{
499 switch (N->getZExtValue()){
500 default: llvm_unreachable(nullptr);
501 case 0: return CurDAG->getTargetConstant(0, SDLoc(N), MVT::i32);
502 case 8: return CurDAG->getTargetConstant(1, SDLoc(N), MVT::i32);
503 case 16: return CurDAG->getTargetConstant(2, SDLoc(N), MVT::i32);
504 case 24: return CurDAG->getTargetConstant(3, SDLoc(N), MVT::i32);
507 def RotImmAsmOperand : AsmOperandClass {
509 let ParserMethod = "parseRotImm";
511 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
512 int32_t v = N->getZExtValue();
513 return v == 8 || v == 16 || v == 24; }],
515 let PrintMethod = "printRotImmOperand";
516 let ParserMatchClass = RotImmAsmOperand;
519 // Power-of-two operand for MVE VIDUP and friends, which encode
520 // {1,2,4,8} as its log to base 2, i.e. as {0,1,2,3} respectively
521 def MVE_VIDUP_imm_asmoperand : AsmOperandClass {
522 let Name = "VIDUP_imm";
523 let PredicateMethod = "isPowerTwoInRange<1,8>";
524 let RenderMethod = "addPowerTwoOperands";
525 let DiagnosticString = "vector increment immediate must be 1, 2, 4 or 8";
527 def MVE_VIDUP_imm : Operand<i32> {
528 let EncoderMethod = "getPowerTwoOpValue";
529 let DecoderMethod = "DecodePowerTwoOperand<0,3>";
530 let ParserMatchClass = MVE_VIDUP_imm_asmoperand;
533 // Pair vector indexing
534 class MVEPairVectorIndexOperand<string start, string end> : AsmOperandClass {
535 let Name = "MVEPairVectorIndex"#start;
536 let RenderMethod = "addMVEPairVectorIndexOperands";
537 let PredicateMethod = "isMVEPairVectorIndex<"#start#", "#end#">";
540 class MVEPairVectorIndex<string opval> : Operand<i32> {
541 let PrintMethod = "printVectorIndex";
542 let EncoderMethod = "getMVEPairVectorIndexOpValue<"#opval#">";
543 let DecoderMethod = "DecodeMVEPairVectorIndexOperand<"#opval#">";
544 let MIOperandInfo = (ops i32imm);
547 def MVEPairVectorIndex0 : MVEPairVectorIndex<"0"> {
548 let ParserMatchClass = MVEPairVectorIndexOperand<"0", "1">;
551 def MVEPairVectorIndex2 : MVEPairVectorIndex<"2"> {
552 let ParserMatchClass = MVEPairVectorIndexOperand<"2", "3">;
556 class MVEVectorIndexOperand<int NumLanes> : AsmOperandClass {
557 let Name = "MVEVectorIndex"#NumLanes;
558 let RenderMethod = "addMVEVectorIndexOperands";
559 let PredicateMethod = "isVectorIndexInRange<"#NumLanes#">";
562 class MVEVectorIndex<int NumLanes> : Operand<i32> {
563 let PrintMethod = "printVectorIndex";
564 let ParserMatchClass = MVEVectorIndexOperand<NumLanes>;
565 let MIOperandInfo = (ops i32imm);
568 // shift_imm: An integer that encodes a shift amount and the type of shift
569 // (asr or lsl). The 6-bit immediate encodes as:
572 // {4-0} imm5 shift amount.
573 // asr #32 encoded as imm5 == 0.
574 def ShifterImmAsmOperand : AsmOperandClass {
575 let Name = "ShifterImm";
576 let ParserMethod = "parseShifterImm";
578 def shift_imm : Operand<i32> {
579 let PrintMethod = "printShiftImmOperand";
580 let ParserMatchClass = ShifterImmAsmOperand;
583 // shifter_operand operands: so_reg_reg, so_reg_imm, and mod_imm.
584 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
585 def so_reg_reg : Operand<i32>, // reg reg imm
586 ComplexPattern<i32, 3, "SelectRegShifterOperand",
587 [shl, srl, sra, rotr]> {
588 let EncoderMethod = "getSORegRegOpValue";
589 let PrintMethod = "printSORegRegOperand";
590 let DecoderMethod = "DecodeSORegRegOperand";
591 let ParserMatchClass = ShiftedRegAsmOperand;
592 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
595 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
596 def so_reg_imm : Operand<i32>, // reg imm
597 ComplexPattern<i32, 2, "SelectImmShifterOperand",
598 [shl, srl, sra, rotr]> {
599 let EncoderMethod = "getSORegImmOpValue";
600 let PrintMethod = "printSORegImmOperand";
601 let DecoderMethod = "DecodeSORegImmOperand";
602 let ParserMatchClass = ShiftedImmAsmOperand;
603 let MIOperandInfo = (ops GPR, i32imm);
606 // FIXME: Does this need to be distinct from so_reg?
607 def shift_so_reg_reg : Operand<i32>, // reg reg imm
608 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
609 [shl,srl,sra,rotr]> {
610 let EncoderMethod = "getSORegRegOpValue";
611 let PrintMethod = "printSORegRegOperand";
612 let DecoderMethod = "DecodeSORegRegOperand";
613 let ParserMatchClass = ShiftedRegAsmOperand;
614 let MIOperandInfo = (ops GPR, GPR, i32imm);
617 // FIXME: Does this need to be distinct from so_reg?
618 def shift_so_reg_imm : Operand<i32>, // reg reg imm
619 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
620 [shl,srl,sra,rotr]> {
621 let EncoderMethod = "getSORegImmOpValue";
622 let PrintMethod = "printSORegImmOperand";
623 let DecoderMethod = "DecodeSORegImmOperand";
624 let ParserMatchClass = ShiftedImmAsmOperand;
625 let MIOperandInfo = (ops GPR, i32imm);
628 // mod_imm: match a 32-bit immediate operand, which can be encoded into
629 // a 12-bit immediate; an 8-bit integer and a 4-bit rotator (See ARMARM
630 // - "Modified Immediate Constants"). Within the MC layer we keep this
631 // immediate in its encoded form.
632 def ModImmAsmOperand: AsmOperandClass {
634 let ParserMethod = "parseModImm";
636 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
637 return ARM_AM::getSOImmVal(Imm) != -1;
639 let EncoderMethod = "getModImmOpValue";
640 let PrintMethod = "printModImmOperand";
641 let ParserMatchClass = ModImmAsmOperand;
644 // Note: the patterns mod_imm_not and mod_imm_neg do not require an encoder
645 // method and such, as they are only used on aliases (Pat<> and InstAlias<>).
646 // The actual parsing, encoding, decoding are handled by the destination
647 // instructions, which use mod_imm.
649 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
650 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
651 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
653 let ParserMatchClass = ModImmNotAsmOperand;
656 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
657 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
658 unsigned Value = -(unsigned)N->getZExtValue();
659 return Value && ARM_AM::getSOImmVal(Value) != -1;
661 let ParserMatchClass = ModImmNegAsmOperand;
664 /// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal()
665 def arm_i32imm : IntImmLeaf<i32, [{
666 if (Subtarget->useMovt())
668 return ARM_AM::isSOImmTwoPartVal(Imm.getZExtValue());
671 /// imm0_1 predicate - Immediate in the range [0,1].
672 def Imm0_1AsmOperand: ImmAsmOperand<0,1> { let Name = "Imm0_1"; }
673 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
675 /// imm0_3 predicate - Immediate in the range [0,3].
676 def Imm0_3AsmOperand: ImmAsmOperand<0,3> { let Name = "Imm0_3"; }
677 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
679 /// imm0_7 predicate - Immediate in the range [0,7].
680 def Imm0_7AsmOperand: ImmAsmOperand<0,7> {
683 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
684 return Imm >= 0 && Imm < 8;
686 let ParserMatchClass = Imm0_7AsmOperand;
689 /// imm8_255 predicate - Immediate in the range [8,255].
690 def Imm8_255AsmOperand: ImmAsmOperand<8,255> { let Name = "Imm8_255"; }
691 def imm8_255 : Operand<i32>, ImmLeaf<i32, [{
692 return Imm >= 8 && Imm < 256;
694 let ParserMatchClass = Imm8_255AsmOperand;
697 /// imm8 predicate - Immediate is exactly 8.
698 def Imm8AsmOperand: ImmAsmOperand<8,8> { let Name = "Imm8"; }
699 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
700 let ParserMatchClass = Imm8AsmOperand;
703 /// imm16 predicate - Immediate is exactly 16.
704 def Imm16AsmOperand: ImmAsmOperand<16,16> { let Name = "Imm16"; }
705 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
706 let ParserMatchClass = Imm16AsmOperand;
709 /// imm32 predicate - Immediate is exactly 32.
710 def Imm32AsmOperand: ImmAsmOperand<32,32> { let Name = "Imm32"; }
711 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
712 let ParserMatchClass = Imm32AsmOperand;
715 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
717 /// imm1_7 predicate - Immediate in the range [1,7].
718 def Imm1_7AsmOperand: ImmAsmOperand<1,7> { let Name = "Imm1_7"; }
719 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
720 let ParserMatchClass = Imm1_7AsmOperand;
723 /// imm1_15 predicate - Immediate in the range [1,15].
724 def Imm1_15AsmOperand: ImmAsmOperand<1,15> { let Name = "Imm1_15"; }
725 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
726 let ParserMatchClass = Imm1_15AsmOperand;
729 /// imm1_31 predicate - Immediate in the range [1,31].
730 def Imm1_31AsmOperand: ImmAsmOperand<1,31> { let Name = "Imm1_31"; }
731 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
732 let ParserMatchClass = Imm1_31AsmOperand;
735 /// imm0_15 predicate - Immediate in the range [0,15].
736 def Imm0_15AsmOperand: ImmAsmOperand<0,15> {
737 let Name = "Imm0_15";
739 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
740 return Imm >= 0 && Imm < 16;
742 let ParserMatchClass = Imm0_15AsmOperand;
745 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
746 def Imm0_31AsmOperand: ImmAsmOperand<0,31> { let Name = "Imm0_31"; }
747 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
748 return Imm >= 0 && Imm < 32;
750 let ParserMatchClass = Imm0_31AsmOperand;
753 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
754 def Imm0_32AsmOperand: ImmAsmOperand<0,32> { let Name = "Imm0_32"; }
755 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
756 return Imm >= 0 && Imm < 33;
758 let ParserMatchClass = Imm0_32AsmOperand;
761 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
762 def Imm0_63AsmOperand: ImmAsmOperand<0,63> { let Name = "Imm0_63"; }
763 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
764 return Imm >= 0 && Imm < 64;
766 let ParserMatchClass = Imm0_63AsmOperand;
769 /// imm0_239 predicate - Immediate in the range [0,239].
770 def Imm0_239AsmOperand : ImmAsmOperand<0,239> {
771 let Name = "Imm0_239";
773 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
774 let ParserMatchClass = Imm0_239AsmOperand;
777 /// imm0_255 predicate - Immediate in the range [0,255].
778 def Imm0_255AsmOperand : ImmAsmOperand<0,255> { let Name = "Imm0_255"; }
779 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
780 let ParserMatchClass = Imm0_255AsmOperand;
783 /// imm0_65535 - An immediate is in the range [0,65535].
784 def Imm0_65535AsmOperand: ImmAsmOperand<0,65535> { let Name = "Imm0_65535"; }
785 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
786 return Imm >= 0 && Imm < 65536;
788 let ParserMatchClass = Imm0_65535AsmOperand;
791 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
792 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
793 return -Imm >= 0 && -Imm < 65536;
796 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
797 // a relocatable expression.
799 // FIXME: This really needs a Thumb version separate from the ARM version.
800 // While the range is the same, and can thus use the same match class,
801 // the encoding is different so it should have a different encoder method.
802 def Imm0_65535ExprAsmOperand: AsmOperandClass {
803 let Name = "Imm0_65535Expr";
804 let RenderMethod = "addImmOperands";
805 let DiagnosticString = "operand must be an immediate in the range [0,0xffff] or a relocatable expression";
808 def imm0_65535_expr : Operand<i32> {
809 let EncoderMethod = "getHiLo16ImmOpValue";
810 let ParserMatchClass = Imm0_65535ExprAsmOperand;
813 def Imm256_65535ExprAsmOperand: ImmAsmOperand<256,65535> { let Name = "Imm256_65535Expr"; }
814 def imm256_65535_expr : Operand<i32> {
815 let ParserMatchClass = Imm256_65535ExprAsmOperand;
818 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
819 def Imm24bitAsmOperand: ImmAsmOperand<0,0xffffff> {
820 let Name = "Imm24bit";
821 let DiagnosticString = "operand must be an immediate in the range [0,0xffffff]";
823 def imm24b : Operand<i32>, ImmLeaf<i32, [{
824 return Imm >= 0 && Imm <= 0xffffff;
826 let ParserMatchClass = Imm24bitAsmOperand;
830 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
832 def BitfieldAsmOperand : AsmOperandClass {
833 let Name = "Bitfield";
834 let ParserMethod = "parseBitfield";
837 def bf_inv_mask_imm : Operand<i32>,
839 return ARM::isBitFieldInvertedMask(N->getZExtValue());
841 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
842 let PrintMethod = "printBitfieldInvMaskImmOperand";
843 let DecoderMethod = "DecodeBitfieldMaskOperand";
844 let ParserMatchClass = BitfieldAsmOperand;
845 let GISelPredicateCode = [{
846 // There's better methods of implementing this check. IntImmLeaf<> would be
847 // equivalent and have less boilerplate but we need a test for C++
848 // predicates and this one causes new rules to be imported into GlobalISel
849 // without requiring additional features first.
850 const auto &MO = MI.getOperand(1);
853 return ARM::isBitFieldInvertedMask(MO.getCImm()->getZExtValue());
857 def imm1_32_XFORM: SDNodeXForm<imm, [{
858 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
861 def Imm1_32AsmOperand: ImmAsmOperandMinusOne<1,32> {
862 let Name = "Imm1_32";
864 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
865 uint64_t Imm = N->getZExtValue();
866 return Imm > 0 && Imm <= 32;
869 let PrintMethod = "printImmPlusOneOperand";
870 let ParserMatchClass = Imm1_32AsmOperand;
873 def imm1_16_XFORM: SDNodeXForm<imm, [{
874 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
877 def Imm1_16AsmOperand: ImmAsmOperandMinusOne<1,16> { let Name = "Imm1_16"; }
878 def imm1_16 : Operand<i32>, ImmLeaf<i32, [{
879 return Imm > 0 && Imm <= 16;
882 let PrintMethod = "printImmPlusOneOperand";
883 let ParserMatchClass = Imm1_16AsmOperand;
886 def MVEShiftImm1_7AsmOperand: ImmAsmOperand<1,7> {
887 let Name = "MVEShiftImm1_7";
888 // Reason we're doing this is because instruction vshll.s8 t1 encoding
889 // accepts 1,7 but the t2 encoding accepts 8. By doing this we can get a
890 // better diagnostic message if someone uses bigger immediate than the t1/t2
892 let DiagnosticString = "operand must be an immediate in the range [1,8]";
894 def mve_shift_imm1_7 : Operand<i32> {
895 let ParserMatchClass = MVEShiftImm1_7AsmOperand;
896 let EncoderMethod = "getMVEShiftImmOpValue";
899 def MVEShiftImm1_15AsmOperand: ImmAsmOperand<1,15> {
900 let Name = "MVEShiftImm1_15";
901 // Reason we're doing this is because instruction vshll.s16 t1 encoding
902 // accepts 1,15 but the t2 encoding accepts 16. By doing this we can get a
903 // better diagnostic message if someone uses bigger immediate than the t1/t2
905 let DiagnosticString = "operand must be an immediate in the range [1,16]";
907 def mve_shift_imm1_15 : Operand<i32> {
908 let ParserMatchClass = MVEShiftImm1_15AsmOperand;
909 let EncoderMethod = "getMVEShiftImmOpValue";
912 // Define ARM specific addressing modes.
913 // addrmode_imm12 := reg +/- imm12
915 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
916 class AddrMode_Imm12 : MemOperand,
917 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
918 // 12-bit immediate operand. Note that instructions using this encode
919 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
920 // immediate values are as normal.
922 let EncoderMethod = "getAddrModeImm12OpValue";
923 let DecoderMethod = "DecodeAddrModeImm12Operand";
924 let ParserMatchClass = MemImm12OffsetAsmOperand;
925 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
928 def addrmode_imm12 : AddrMode_Imm12 {
929 let PrintMethod = "printAddrModeImm12Operand<false>";
932 def addrmode_imm12_pre : AddrMode_Imm12 {
933 let PrintMethod = "printAddrModeImm12Operand<true>";
936 // ldst_so_reg := reg +/- reg shop imm
938 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
939 def ldst_so_reg : MemOperand,
940 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
941 let EncoderMethod = "getLdStSORegOpValue";
942 // FIXME: Simplify the printer
943 let PrintMethod = "printAddrMode2Operand";
944 let DecoderMethod = "DecodeSORegMemOperand";
945 let ParserMatchClass = MemRegOffsetAsmOperand;
946 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
949 // postidx_imm8 := +/- [0,255]
952 // {8} 1 is imm8 is non-negative. 0 otherwise.
953 // {7-0} [0,255] imm8 value.
954 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
955 def postidx_imm8 : MemOperand {
956 let PrintMethod = "printPostIdxImm8Operand";
957 let ParserMatchClass = PostIdxImm8AsmOperand;
958 let MIOperandInfo = (ops i32imm);
961 // postidx_imm8s4 := +/- [0,1020]
964 // {8} 1 is imm8 is non-negative. 0 otherwise.
965 // {7-0} [0,255] imm8 value, scaled by 4.
966 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
967 def postidx_imm8s4 : MemOperand {
968 let PrintMethod = "printPostIdxImm8s4Operand";
969 let ParserMatchClass = PostIdxImm8s4AsmOperand;
970 let MIOperandInfo = (ops i32imm);
974 // postidx_reg := +/- reg
976 def PostIdxRegAsmOperand : AsmOperandClass {
977 let Name = "PostIdxReg";
978 let ParserMethod = "parsePostIdxReg";
980 def postidx_reg : MemOperand {
981 let EncoderMethod = "getPostIdxRegOpValue";
982 let DecoderMethod = "DecodePostIdxReg";
983 let PrintMethod = "printPostIdxRegOperand";
984 let ParserMatchClass = PostIdxRegAsmOperand;
985 let MIOperandInfo = (ops GPRnopc, i32imm);
988 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
989 let Name = "PostIdxRegShifted";
990 let ParserMethod = "parsePostIdxReg";
992 def am2offset_reg : MemOperand,
993 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
994 [], [SDNPWantRoot]> {
995 let EncoderMethod = "getAddrMode2OffsetOpValue";
996 let PrintMethod = "printAddrMode2OffsetOperand";
997 // When using this for assembly, it's always as a post-index offset.
998 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
999 let MIOperandInfo = (ops GPRnopc, i32imm);
1002 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
1003 // the GPR is purely vestigal at this point.
1004 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
1005 def am2offset_imm : MemOperand,
1006 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
1007 [], [SDNPWantRoot]> {
1008 let EncoderMethod = "getAddrMode2OffsetOpValue";
1009 let PrintMethod = "printAddrMode2OffsetOperand";
1010 let ParserMatchClass = AM2OffsetImmAsmOperand;
1011 let MIOperandInfo = (ops GPRnopc, i32imm);
1015 // addrmode3 := reg +/- reg
1016 // addrmode3 := reg +/- imm8
1018 // FIXME: split into imm vs. reg versions.
1019 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
1020 class AddrMode3 : MemOperand,
1021 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
1022 let EncoderMethod = "getAddrMode3OpValue";
1023 let ParserMatchClass = AddrMode3AsmOperand;
1024 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
1027 def addrmode3 : AddrMode3
1029 let PrintMethod = "printAddrMode3Operand<false>";
1032 def addrmode3_pre : AddrMode3
1034 let PrintMethod = "printAddrMode3Operand<true>";
1037 // FIXME: split into imm vs. reg versions.
1038 // FIXME: parser method to handle +/- register.
1039 def AM3OffsetAsmOperand : AsmOperandClass {
1040 let Name = "AM3Offset";
1041 let ParserMethod = "parseAM3Offset";
1043 def am3offset : MemOperand,
1044 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
1045 [], [SDNPWantRoot]> {
1046 let EncoderMethod = "getAddrMode3OffsetOpValue";
1047 let PrintMethod = "printAddrMode3OffsetOperand";
1048 let ParserMatchClass = AM3OffsetAsmOperand;
1049 let MIOperandInfo = (ops GPR, i32imm);
1052 // ldstm_mode := {ia, ib, da, db}
1054 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
1055 let EncoderMethod = "getLdStmModeOpValue";
1056 let PrintMethod = "printLdStmModeOperand";
1059 // addrmode5 := reg +/- imm8*4
1061 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
1062 class AddrMode5 : MemOperand,
1063 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
1064 let EncoderMethod = "getAddrMode5OpValue";
1065 let DecoderMethod = "DecodeAddrMode5Operand";
1066 let ParserMatchClass = AddrMode5AsmOperand;
1067 let MIOperandInfo = (ops GPR:$base, i32imm);
1070 def addrmode5 : AddrMode5 {
1071 let PrintMethod = "printAddrMode5Operand<false>";
1074 def addrmode5_pre : AddrMode5 {
1075 let PrintMethod = "printAddrMode5Operand<true>";
1078 // addrmode5fp16 := reg +/- imm8*2
1080 def AddrMode5FP16AsmOperand : AsmOperandClass { let Name = "AddrMode5FP16"; }
1081 class AddrMode5FP16 : Operand<i32>,
1082 ComplexPattern<i32, 2, "SelectAddrMode5FP16", []> {
1083 let EncoderMethod = "getAddrMode5FP16OpValue";
1084 let DecoderMethod = "DecodeAddrMode5FP16Operand";
1085 let ParserMatchClass = AddrMode5FP16AsmOperand;
1086 let MIOperandInfo = (ops GPR:$base, i32imm);
1089 def addrmode5fp16 : AddrMode5FP16 {
1090 let PrintMethod = "printAddrMode5FP16Operand<false>";
1093 // addrmode6 := reg with optional alignment
1095 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
1096 def addrmode6 : MemOperand,
1097 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1098 let PrintMethod = "printAddrMode6Operand";
1099 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1100 let EncoderMethod = "getAddrMode6AddressOpValue";
1101 let DecoderMethod = "DecodeAddrMode6Operand";
1102 let ParserMatchClass = AddrMode6AsmOperand;
1105 def am6offset : MemOperand,
1106 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
1107 [], [SDNPWantRoot]> {
1108 let PrintMethod = "printAddrMode6OffsetOperand";
1109 let MIOperandInfo = (ops GPR);
1110 let EncoderMethod = "getAddrMode6OffsetOpValue";
1111 let DecoderMethod = "DecodeGPRRegisterClass";
1114 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
1115 // (single element from one lane) for size 32.
1116 def addrmode6oneL32 : MemOperand,
1117 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1118 let PrintMethod = "printAddrMode6Operand";
1119 let MIOperandInfo = (ops GPR:$addr, i32imm);
1120 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1123 // Base class for addrmode6 with specific alignment restrictions.
1124 class AddrMode6Align : MemOperand,
1125 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1126 let PrintMethod = "printAddrMode6Operand";
1127 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1128 let EncoderMethod = "getAddrMode6AddressOpValue";
1129 let DecoderMethod = "DecodeAddrMode6Operand";
1132 // Special version of addrmode6 to handle no allowed alignment encoding for
1133 // VLD/VST instructions and checking the alignment is not specified.
1134 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1135 let Name = "AlignedMemoryNone";
1136 let DiagnosticString = "alignment must be omitted";
1138 def addrmode6alignNone : AddrMode6Align {
1139 // The alignment specifier can only be omitted.
1140 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1143 // Special version of addrmode6 to handle 16-bit alignment encoding for
1144 // VLD/VST instructions and checking the alignment value.
1145 def AddrMode6Align16AsmOperand : AsmOperandClass {
1146 let Name = "AlignedMemory16";
1147 let DiagnosticString = "alignment must be 16 or omitted";
1149 def addrmode6align16 : AddrMode6Align {
1150 // The alignment specifier can only be 16 or omitted.
1151 let ParserMatchClass = AddrMode6Align16AsmOperand;
1154 // Special version of addrmode6 to handle 32-bit alignment encoding for
1155 // VLD/VST instructions and checking the alignment value.
1156 def AddrMode6Align32AsmOperand : AsmOperandClass {
1157 let Name = "AlignedMemory32";
1158 let DiagnosticString = "alignment must be 32 or omitted";
1160 def addrmode6align32 : AddrMode6Align {
1161 // The alignment specifier can only be 32 or omitted.
1162 let ParserMatchClass = AddrMode6Align32AsmOperand;
1165 // Special version of addrmode6 to handle 64-bit alignment encoding for
1166 // VLD/VST instructions and checking the alignment value.
1167 def AddrMode6Align64AsmOperand : AsmOperandClass {
1168 let Name = "AlignedMemory64";
1169 let DiagnosticString = "alignment must be 64 or omitted";
1171 def addrmode6align64 : AddrMode6Align {
1172 // The alignment specifier can only be 64 or omitted.
1173 let ParserMatchClass = AddrMode6Align64AsmOperand;
1176 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1177 // for VLD/VST instructions and checking the alignment value.
1178 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1179 let Name = "AlignedMemory64or128";
1180 let DiagnosticString = "alignment must be 64, 128 or omitted";
1182 def addrmode6align64or128 : AddrMode6Align {
1183 // The alignment specifier can only be 64, 128 or omitted.
1184 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1187 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1188 // encoding for VLD/VST instructions and checking the alignment value.
1189 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1190 let Name = "AlignedMemory64or128or256";
1191 let DiagnosticString = "alignment must be 64, 128, 256 or omitted";
1193 def addrmode6align64or128or256 : AddrMode6Align {
1194 // The alignment specifier can only be 64, 128, 256 or omitted.
1195 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1198 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1199 // instructions, specifically VLD4-dup.
1200 def addrmode6dup : MemOperand,
1201 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1202 let PrintMethod = "printAddrMode6Operand";
1203 let MIOperandInfo = (ops GPR:$addr, i32imm);
1204 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1205 // FIXME: This is close, but not quite right. The alignment specifier is
1207 let ParserMatchClass = AddrMode6AsmOperand;
1210 // Base class for addrmode6dup with specific alignment restrictions.
1211 class AddrMode6DupAlign : MemOperand,
1212 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1213 let PrintMethod = "printAddrMode6Operand";
1214 let MIOperandInfo = (ops GPR:$addr, i32imm);
1215 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1218 // Special version of addrmode6 to handle no allowed alignment encoding for
1219 // VLD-dup instruction and checking the alignment is not specified.
1220 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1221 let Name = "DupAlignedMemoryNone";
1222 let DiagnosticString = "alignment must be omitted";
1224 def addrmode6dupalignNone : AddrMode6DupAlign {
1225 // The alignment specifier can only be omitted.
1226 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1229 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1230 // instruction and checking the alignment value.
1231 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1232 let Name = "DupAlignedMemory16";
1233 let DiagnosticString = "alignment must be 16 or omitted";
1235 def addrmode6dupalign16 : AddrMode6DupAlign {
1236 // The alignment specifier can only be 16 or omitted.
1237 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1240 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1241 // instruction and checking the alignment value.
1242 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1243 let Name = "DupAlignedMemory32";
1244 let DiagnosticString = "alignment must be 32 or omitted";
1246 def addrmode6dupalign32 : AddrMode6DupAlign {
1247 // The alignment specifier can only be 32 or omitted.
1248 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1251 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1252 // instructions and checking the alignment value.
1253 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1254 let Name = "DupAlignedMemory64";
1255 let DiagnosticString = "alignment must be 64 or omitted";
1257 def addrmode6dupalign64 : AddrMode6DupAlign {
1258 // The alignment specifier can only be 64 or omitted.
1259 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1262 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1263 // for VLD instructions and checking the alignment value.
1264 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1265 let Name = "DupAlignedMemory64or128";
1266 let DiagnosticString = "alignment must be 64, 128 or omitted";
1268 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1269 // The alignment specifier can only be 64, 128 or omitted.
1270 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1273 // addrmodepc := pc + reg
1275 def addrmodepc : MemOperand,
1276 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1277 let PrintMethod = "printAddrModePCOperand";
1278 let MIOperandInfo = (ops GPR, i32imm);
1281 // addr_offset_none := reg
1283 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1284 def addr_offset_none : MemOperand,
1285 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1286 let PrintMethod = "printAddrMode7Operand";
1287 let DecoderMethod = "DecodeAddrMode7Operand";
1288 let ParserMatchClass = MemNoOffsetAsmOperand;
1289 let MIOperandInfo = (ops GPR:$base);
1292 // t_addr_offset_none := reg [r0-r7]
1293 def MemNoOffsetTAsmOperand : AsmOperandClass { let Name = "MemNoOffsetT"; }
1294 def t_addr_offset_none : MemOperand {
1295 let PrintMethod = "printAddrMode7Operand";
1296 let DecoderMethod = "DecodetGPRRegisterClass";
1297 let ParserMatchClass = MemNoOffsetTAsmOperand;
1298 let MIOperandInfo = (ops tGPR:$base);
1301 def nohash_imm : Operand<i32> {
1302 let PrintMethod = "printNoHashImmediate";
1305 def CoprocNumAsmOperand : AsmOperandClass {
1306 let Name = "CoprocNum";
1307 let ParserMethod = "parseCoprocNumOperand";
1309 def p_imm : Operand<i32> {
1310 let PrintMethod = "printPImmediate";
1311 let ParserMatchClass = CoprocNumAsmOperand;
1312 let DecoderMethod = "DecodeCoprocessor";
1315 def CoprocRegAsmOperand : AsmOperandClass {
1316 let Name = "CoprocReg";
1317 let ParserMethod = "parseCoprocRegOperand";
1319 def c_imm : Operand<i32> {
1320 let PrintMethod = "printCImmediate";
1321 let ParserMatchClass = CoprocRegAsmOperand;
1323 def CoprocOptionAsmOperand : AsmOperandClass {
1324 let Name = "CoprocOption";
1325 let ParserMethod = "parseCoprocOptionOperand";
1327 def coproc_option_imm : Operand<i32> {
1328 let PrintMethod = "printCoprocOptionImm";
1329 let ParserMatchClass = CoprocOptionAsmOperand;
1332 //===----------------------------------------------------------------------===//
1334 include "ARMInstrFormats.td"
1336 //===----------------------------------------------------------------------===//
1337 // Multiclass helpers...
1340 /// AsI1_bin_irs - Defines a set of (op r, {mod_imm|r|so_reg}) patterns for a
1341 /// binop that produces a value.
1342 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1343 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1344 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1345 SDPatternOperator opnode, bit Commutable = 0> {
1346 // The register-immediate version is re-materializable. This is useful
1347 // in particular for taking the address of a local.
1348 let isReMaterializable = 1 in {
1349 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1350 iii, opc, "\t$Rd, $Rn, $imm",
1351 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1352 Sched<[WriteALU, ReadALU]> {
1357 let Inst{19-16} = Rn;
1358 let Inst{15-12} = Rd;
1359 let Inst{11-0} = imm;
1362 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1363 iir, opc, "\t$Rd, $Rn, $Rm",
1364 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1365 Sched<[WriteALU, ReadALU, ReadALU]> {
1370 let isCommutable = Commutable;
1371 let Inst{19-16} = Rn;
1372 let Inst{15-12} = Rd;
1373 let Inst{11-4} = 0b00000000;
1377 def rsi : AsI1<opcod, (outs GPR:$Rd),
1378 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1379 iis, opc, "\t$Rd, $Rn, $shift",
1380 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1381 Sched<[WriteALUsi, ReadALU]> {
1386 let Inst{19-16} = Rn;
1387 let Inst{15-12} = Rd;
1388 let Inst{11-5} = shift{11-5};
1390 let Inst{3-0} = shift{3-0};
1393 def rsr : AsI1<opcod, (outs GPR:$Rd),
1394 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1395 iis, opc, "\t$Rd, $Rn, $shift",
1396 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1397 Sched<[WriteALUsr, ReadALUsr]> {
1402 let Inst{19-16} = Rn;
1403 let Inst{15-12} = Rd;
1404 let Inst{11-8} = shift{11-8};
1406 let Inst{6-5} = shift{6-5};
1408 let Inst{3-0} = shift{3-0};
1412 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1413 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1414 /// it is equivalent to the AsI1_bin_irs counterpart.
1415 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1416 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1417 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1418 SDNode opnode, bit Commutable = 0> {
1419 // The register-immediate version is re-materializable. This is useful
1420 // in particular for taking the address of a local.
1421 let isReMaterializable = 1 in {
1422 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1423 iii, opc, "\t$Rd, $Rn, $imm",
1424 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1425 Sched<[WriteALU, ReadALU]> {
1430 let Inst{19-16} = Rn;
1431 let Inst{15-12} = Rd;
1432 let Inst{11-0} = imm;
1435 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1436 iir, opc, "\t$Rd, $Rn, $Rm",
1437 [/* pattern left blank */]>,
1438 Sched<[WriteALU, ReadALU, ReadALU]> {
1442 let Inst{11-4} = 0b00000000;
1445 let Inst{15-12} = Rd;
1446 let Inst{19-16} = Rn;
1449 def rsi : AsI1<opcod, (outs GPR:$Rd),
1450 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1451 iis, opc, "\t$Rd, $Rn, $shift",
1452 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1453 Sched<[WriteALUsi, ReadALU]> {
1458 let Inst{19-16} = Rn;
1459 let Inst{15-12} = Rd;
1460 let Inst{11-5} = shift{11-5};
1462 let Inst{3-0} = shift{3-0};
1465 def rsr : AsI1<opcod, (outs GPR:$Rd),
1466 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1467 iis, opc, "\t$Rd, $Rn, $shift",
1468 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1469 Sched<[WriteALUsr, ReadALUsr]> {
1474 let Inst{19-16} = Rn;
1475 let Inst{15-12} = Rd;
1476 let Inst{11-8} = shift{11-8};
1478 let Inst{6-5} = shift{6-5};
1480 let Inst{3-0} = shift{3-0};
1484 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1486 /// These opcodes will be converted to the real non-S opcodes by
1487 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1488 let hasPostISelHook = 1, Defs = [CPSR] in {
1489 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1490 InstrItinClass iis, SDNode opnode,
1491 bit Commutable = 0> {
1492 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1494 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1495 Sched<[WriteALU, ReadALU]>;
1497 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1499 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1500 Sched<[WriteALU, ReadALU, ReadALU]> {
1501 let isCommutable = Commutable;
1503 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1504 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1506 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1507 so_reg_imm:$shift))]>,
1508 Sched<[WriteALUsi, ReadALU]>;
1510 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1511 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1513 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1514 so_reg_reg:$shift))]>,
1515 Sched<[WriteALUSsr, ReadALUsr]>;
1519 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1520 /// operands are reversed.
1521 let hasPostISelHook = 1, Defs = [CPSR] in {
1522 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1523 InstrItinClass iis, SDNode opnode,
1524 bit Commutable = 0> {
1525 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1527 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1528 Sched<[WriteALU, ReadALU]>;
1530 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1531 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1533 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1535 Sched<[WriteALUsi, ReadALU]>;
1537 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1538 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1540 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1542 Sched<[WriteALUSsr, ReadALUsr]>;
1546 /// AI1_cmp_irs - Defines a set of (op r, {mod_imm|r|so_reg}) cmp / test
1547 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1548 /// a explicit result, only implicitly set CPSR.
1549 let isCompare = 1, Defs = [CPSR] in {
1550 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1551 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1552 SDPatternOperator opnode, bit Commutable = 0,
1553 string rrDecoderMethod = ""> {
1554 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1556 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1557 Sched<[WriteCMP, ReadALU]> {
1562 let Inst{19-16} = Rn;
1563 let Inst{15-12} = 0b0000;
1564 let Inst{11-0} = imm;
1566 let Unpredictable{15-12} = 0b1111;
1568 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1570 [(opnode GPR:$Rn, GPR:$Rm)]>,
1571 Sched<[WriteCMP, ReadALU, ReadALU]> {
1574 let isCommutable = Commutable;
1577 let Inst{19-16} = Rn;
1578 let Inst{15-12} = 0b0000;
1579 let Inst{11-4} = 0b00000000;
1581 let DecoderMethod = rrDecoderMethod;
1583 let Unpredictable{15-12} = 0b1111;
1585 def rsi : AI1<opcod, (outs),
1586 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1587 opc, "\t$Rn, $shift",
1588 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1589 Sched<[WriteCMPsi, ReadALU]> {
1594 let Inst{19-16} = Rn;
1595 let Inst{15-12} = 0b0000;
1596 let Inst{11-5} = shift{11-5};
1598 let Inst{3-0} = shift{3-0};
1600 let Unpredictable{15-12} = 0b1111;
1602 def rsr : AI1<opcod, (outs),
1603 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1604 opc, "\t$Rn, $shift",
1605 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1606 Sched<[WriteCMPsr, ReadALU]> {
1611 let Inst{19-16} = Rn;
1612 let Inst{15-12} = 0b0000;
1613 let Inst{11-8} = shift{11-8};
1615 let Inst{6-5} = shift{6-5};
1617 let Inst{3-0} = shift{3-0};
1619 let Unpredictable{15-12} = 0b1111;
1625 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1626 /// register and one whose operand is a register rotated by 8/16/24.
1627 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1628 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1629 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1630 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1631 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1632 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1636 let Inst{19-16} = 0b1111;
1637 let Inst{15-12} = Rd;
1638 let Inst{11-10} = rot;
1642 class AI_ext_rrot_np<bits<8> opcod, string opc>
1643 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1644 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1645 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1647 let Inst{19-16} = 0b1111;
1648 let Inst{11-10} = rot;
1651 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1652 /// register and one whose operand is a register rotated by 8/16/24.
1653 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1654 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1655 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1656 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1657 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1658 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1663 let Inst{19-16} = Rn;
1664 let Inst{15-12} = Rd;
1665 let Inst{11-10} = rot;
1666 let Inst{9-4} = 0b000111;
1670 class AI_exta_rrot_np<bits<8> opcod, string opc>
1671 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1672 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1673 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1676 let Inst{19-16} = Rn;
1677 let Inst{11-10} = rot;
1680 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1681 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1682 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, SDNode opnode,
1683 bit Commutable = 0> {
1684 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1685 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1686 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1687 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1689 Sched<[WriteALU, ReadALU]> {
1694 let Inst{15-12} = Rd;
1695 let Inst{19-16} = Rn;
1696 let Inst{11-0} = imm;
1698 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1699 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1700 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1702 Sched<[WriteALU, ReadALU, ReadALU]> {
1706 let Inst{11-4} = 0b00000000;
1708 let isCommutable = Commutable;
1710 let Inst{15-12} = Rd;
1711 let Inst{19-16} = Rn;
1713 def rsi : AsI1<opcod, (outs GPR:$Rd),
1714 (ins GPR:$Rn, so_reg_imm:$shift),
1715 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1716 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1718 Sched<[WriteALUsi, ReadALU]> {
1723 let Inst{19-16} = Rn;
1724 let Inst{15-12} = Rd;
1725 let Inst{11-5} = shift{11-5};
1727 let Inst{3-0} = shift{3-0};
1729 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1730 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1731 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1732 [(set GPRnopc:$Rd, CPSR,
1733 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1735 Sched<[WriteALUsr, ReadALUsr]> {
1740 let Inst{19-16} = Rn;
1741 let Inst{15-12} = Rd;
1742 let Inst{11-8} = shift{11-8};
1744 let Inst{6-5} = shift{6-5};
1746 let Inst{3-0} = shift{3-0};
1751 /// AI1_rsc_irs - Define instructions and patterns for rsc
1752 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1753 multiclass AI1_rsc_irs<bits<4> opcod, string opc, SDNode opnode> {
1754 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1755 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1756 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1757 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1759 Sched<[WriteALU, ReadALU]> {
1764 let Inst{15-12} = Rd;
1765 let Inst{19-16} = Rn;
1766 let Inst{11-0} = imm;
1768 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1769 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1770 [/* pattern left blank */]>,
1771 Sched<[WriteALU, ReadALU, ReadALU]> {
1775 let Inst{11-4} = 0b00000000;
1778 let Inst{15-12} = Rd;
1779 let Inst{19-16} = Rn;
1781 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1782 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1783 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1785 Sched<[WriteALUsi, ReadALU]> {
1790 let Inst{19-16} = Rn;
1791 let Inst{15-12} = Rd;
1792 let Inst{11-5} = shift{11-5};
1794 let Inst{3-0} = shift{3-0};
1796 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1797 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1798 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1800 Sched<[WriteALUsr, ReadALUsr]> {
1805 let Inst{19-16} = Rn;
1806 let Inst{15-12} = Rd;
1807 let Inst{11-8} = shift{11-8};
1809 let Inst{6-5} = shift{6-5};
1811 let Inst{3-0} = shift{3-0};
1816 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1817 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1818 InstrItinClass iir, PatFrag opnode> {
1819 // Note: We use the complex addrmode_imm12 rather than just an input
1820 // GPR and a constrained immediate so that we can use this to match
1821 // frame index references and avoid matching constant pool references.
1822 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1823 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1824 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1827 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1828 let Inst{19-16} = addr{16-13}; // Rn
1829 let Inst{15-12} = Rt;
1830 let Inst{11-0} = addr{11-0}; // imm12
1832 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1833 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1834 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1837 let shift{4} = 0; // Inst{4} = 0
1838 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1839 let Inst{19-16} = shift{16-13}; // Rn
1840 let Inst{15-12} = Rt;
1841 let Inst{11-0} = shift{11-0};
1846 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1847 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1848 InstrItinClass iir, PatFrag opnode> {
1849 // Note: We use the complex addrmode_imm12 rather than just an input
1850 // GPR and a constrained immediate so that we can use this to match
1851 // frame index references and avoid matching constant pool references.
1852 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1853 (ins addrmode_imm12:$addr),
1854 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1855 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1858 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1859 let Inst{19-16} = addr{16-13}; // Rn
1860 let Inst{15-12} = Rt;
1861 let Inst{11-0} = addr{11-0}; // imm12
1863 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1864 (ins ldst_so_reg:$shift),
1865 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1866 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1869 let shift{4} = 0; // Inst{4} = 0
1870 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1871 let Inst{19-16} = shift{16-13}; // Rn
1872 let Inst{15-12} = Rt;
1873 let Inst{11-0} = shift{11-0};
1879 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1880 InstrItinClass iir, PatFrag opnode> {
1881 // Note: We use the complex addrmode_imm12 rather than just an input
1882 // GPR and a constrained immediate so that we can use this to match
1883 // frame index references and avoid matching constant pool references.
1884 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1885 (ins GPR:$Rt, addrmode_imm12:$addr),
1886 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1887 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1890 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1891 let Inst{19-16} = addr{16-13}; // Rn
1892 let Inst{15-12} = Rt;
1893 let Inst{11-0} = addr{11-0}; // imm12
1895 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1896 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1897 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1900 let shift{4} = 0; // Inst{4} = 0
1901 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1902 let Inst{19-16} = shift{16-13}; // Rn
1903 let Inst{15-12} = Rt;
1904 let Inst{11-0} = shift{11-0};
1908 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1909 InstrItinClass iir, PatFrag opnode> {
1910 // Note: We use the complex addrmode_imm12 rather than just an input
1911 // GPR and a constrained immediate so that we can use this to match
1912 // frame index references and avoid matching constant pool references.
1913 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1914 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1915 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1916 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1919 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1920 let Inst{19-16} = addr{16-13}; // Rn
1921 let Inst{15-12} = Rt;
1922 let Inst{11-0} = addr{11-0}; // imm12
1924 def rs : AI2ldst<0b011, 0, isByte, (outs),
1925 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1926 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1927 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1930 let shift{4} = 0; // Inst{4} = 0
1931 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1932 let Inst{19-16} = shift{16-13}; // Rn
1933 let Inst{15-12} = Rt;
1934 let Inst{11-0} = shift{11-0};
1939 //===----------------------------------------------------------------------===//
1941 //===----------------------------------------------------------------------===//
1943 //===----------------------------------------------------------------------===//
1944 // Miscellaneous Instructions.
1947 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1948 /// the function. The first operand is the ID# for this instruction, the second
1949 /// is the index into the MachineConstantPool that this is, the third is the
1950 /// size in bytes of this constant pool entry.
1951 let hasSideEffects = 0, isNotDuplicable = 1 in
1952 def CONSTPOOL_ENTRY :
1953 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1954 i32imm:$size), NoItinerary, []>;
1956 /// A jumptable consisting of direct 32-bit addresses of the destination basic
1957 /// blocks (either absolute, or relative to the start of the jump-table in PIC
1958 /// mode). Used mostly in ARM and Thumb-1 modes.
1959 def JUMPTABLE_ADDRS :
1960 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1961 i32imm:$size), NoItinerary, []>;
1963 /// A jumptable consisting of 32-bit jump instructions. Used for Thumb-2 tables
1964 /// that cannot be optimised to use TBB or TBH.
1965 def JUMPTABLE_INSTS :
1966 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1967 i32imm:$size), NoItinerary, []>;
1969 /// A jumptable consisting of 8-bit unsigned integers representing offsets from
1970 /// a TBB instruction.
1972 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1973 i32imm:$size), NoItinerary, []>;
1975 /// A jumptable consisting of 16-bit unsigned integers representing offsets from
1976 /// a TBH instruction.
1978 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1979 i32imm:$size), NoItinerary, []>;
1982 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1983 // from removing one half of the matched pairs. That breaks PEI, which assumes
1984 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1985 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1986 def ADJCALLSTACKUP :
1987 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1988 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1990 def ADJCALLSTACKDOWN :
1991 PseudoInst<(outs), (ins i32imm:$amt, i32imm:$amt2, pred:$p), NoItinerary,
1992 [(ARMcallseq_start timm:$amt, timm:$amt2)]>;
1995 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
1996 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
1997 Requires<[IsARM, HasV6]> {
1999 let Inst{27-8} = 0b00110010000011110000;
2000 let Inst{7-0} = imm;
2001 let DecoderMethod = "DecodeHINTInstruction";
2004 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6K]>;
2005 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6K]>;
2006 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6K]>;
2007 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6K]>;
2008 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6K]>;
2009 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
2010 def : InstAlias<"esb$p", (HINT 16, pred:$p)>, Requires<[IsARM, HasRAS]>;
2011 def : InstAlias<"csdb$p", (HINT 20, pred:$p)>, Requires<[IsARM, HasV6K]>;
2013 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
2015 [(set GPR:$Rd, (int_arm_sel GPR:$Rn, GPR:$Rm))]>,
2016 Requires<[IsARM, HasV6]> {
2021 let Inst{15-12} = Rd;
2022 let Inst{19-16} = Rn;
2023 let Inst{27-20} = 0b01101000;
2024 let Inst{7-4} = 0b1011;
2025 let Inst{11-8} = 0b1111;
2026 let Unpredictable{11-8} = 0b1111;
2029 // The 16-bit operand $val can be used by a debugger to store more information
2030 // about the breakpoint.
2031 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
2032 "bkpt", "\t$val", []>, Requires<[IsARM]> {
2034 let Inst{3-0} = val{3-0};
2035 let Inst{19-8} = val{15-4};
2036 let Inst{27-20} = 0b00010010;
2037 let Inst{31-28} = 0xe; // AL
2038 let Inst{7-4} = 0b0111;
2040 // default immediate for breakpoint mnemonic
2041 def : InstAlias<"bkpt", (BKPT 0), 0>, Requires<[IsARM]>;
2043 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
2044 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
2046 let Inst{3-0} = val{3-0};
2047 let Inst{19-8} = val{15-4};
2048 let Inst{27-20} = 0b00010000;
2049 let Inst{31-28} = 0xe; // AL
2050 let Inst{7-4} = 0b0111;
2053 // Change Processor State
2054 // FIXME: We should use InstAlias to handle the optional operands.
2055 class CPS<dag iops, string asm_ops>
2056 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
2057 []>, Requires<[IsARM]> {
2063 let Inst{31-28} = 0b1111;
2064 let Inst{27-20} = 0b00010000;
2065 let Inst{19-18} = imod;
2066 let Inst{17} = M; // Enabled if mode is set;
2067 let Inst{16-9} = 0b00000000;
2068 let Inst{8-6} = iflags;
2070 let Inst{4-0} = mode;
2073 let DecoderMethod = "DecodeCPSInstruction" in {
2075 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
2076 "$imod\t$iflags, $mode">;
2077 let mode = 0, M = 0 in
2078 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
2080 let imod = 0, iflags = 0, M = 1 in
2081 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
2084 // Preload signals the memory system of possible future data/instruction access.
2085 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
2087 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
2088 IIC_Preload, !strconcat(opc, "\t$addr"),
2089 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
2090 Sched<[WritePreLd]> {
2093 let Inst{31-26} = 0b111101;
2094 let Inst{25} = 0; // 0 for immediate form
2095 let Inst{24} = data;
2096 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2097 let Inst{22} = read;
2098 let Inst{21-20} = 0b01;
2099 let Inst{19-16} = addr{16-13}; // Rn
2100 let Inst{15-12} = 0b1111;
2101 let Inst{11-0} = addr{11-0}; // imm12
2104 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
2105 !strconcat(opc, "\t$shift"),
2106 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
2107 Sched<[WritePreLd]> {
2109 let Inst{31-26} = 0b111101;
2110 let Inst{25} = 1; // 1 for register form
2111 let Inst{24} = data;
2112 let Inst{23} = shift{12}; // U (add = ('U' == 1))
2113 let Inst{22} = read;
2114 let Inst{21-20} = 0b01;
2115 let Inst{19-16} = shift{16-13}; // Rn
2116 let Inst{15-12} = 0b1111;
2117 let Inst{11-0} = shift{11-0};
2122 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
2123 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
2124 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
2126 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
2127 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
2129 let Inst{31-10} = 0b1111000100000001000000;
2134 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
2135 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
2137 let Inst{27-4} = 0b001100100000111100001111;
2138 let Inst{3-0} = opt;
2141 // A8.8.247 UDF - Undefined (Encoding A1)
2142 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
2143 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
2145 let Inst{31-28} = 0b1110; // AL
2146 let Inst{27-25} = 0b011;
2147 let Inst{24-20} = 0b11111;
2148 let Inst{19-8} = imm16{15-4};
2149 let Inst{7-4} = 0b1111;
2150 let Inst{3-0} = imm16{3-0};
2154 * A5.4 Permanently UNDEFINED instructions.
2156 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
2157 * Other UDF encodings generate SIGILL.
2159 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
2161 * 1110 0111 1111 iiii iiii iiii 1111 iiii
2163 * 1101 1110 iiii iiii
2164 * It uses the following encoding:
2165 * 1110 0111 1111 1110 1101 1110 1111 0000
2166 * - In ARM: UDF #60896;
2167 * - In Thumb: UDF #254 followed by a branch-to-self.
2169 let isBarrier = 1, isTerminator = 1 in
2170 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2172 Requires<[IsARM,UseNaClTrap]> {
2173 let Inst = 0xe7fedef0;
2175 let isBarrier = 1, isTerminator = 1 in
2176 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2178 Requires<[IsARM,DontUseNaClTrap]> {
2179 let Inst = 0xe7ffdefe;
2182 def : Pat<(debugtrap), (BKPT 0)>, Requires<[IsARM, HasV5T]>;
2183 def : Pat<(debugtrap), (UDF 254)>, Requires<[IsARM, NoV5T]>;
2185 // Address computation and loads and stores in PIC mode.
2186 let isNotDuplicable = 1 in {
2187 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2189 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2190 Sched<[WriteALU, ReadALU]>;
2192 let AddedComplexity = 10 in {
2193 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2195 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2197 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2199 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2201 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2203 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2205 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2207 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2209 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2211 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2213 let AddedComplexity = 10 in {
2214 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2215 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2217 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2218 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2219 addrmodepc:$addr)]>;
2221 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2222 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2224 } // isNotDuplicable = 1
2227 // LEApcrel - Load a pc-relative address into a register without offending the
2229 let hasSideEffects = 0, isReMaterializable = 1 in
2230 // The 'adr' mnemonic encodes differently if the label is before or after
2231 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2232 // know until then which form of the instruction will be used.
2233 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2234 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2235 Sched<[WriteALU, ReadALU]> {
2238 let Inst{27-25} = 0b001;
2240 let Inst{23-22} = label{13-12};
2243 let Inst{19-16} = 0b1111;
2244 let Inst{15-12} = Rd;
2245 let Inst{11-0} = label{11-0};
2248 let hasSideEffects = 1 in {
2249 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2250 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2252 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2253 (ins i32imm:$label, pred:$p),
2254 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2257 //===----------------------------------------------------------------------===//
2258 // Control Flow Instructions.
2261 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2263 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2264 "bx", "\tlr", [(ARMretflag)]>,
2265 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2266 let Inst{27-0} = 0b0001001011111111111100011110;
2270 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2271 "mov", "\tpc, lr", [(ARMretflag)]>,
2272 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2273 let Inst{27-0} = 0b0001101000001111000000001110;
2276 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2277 // the user-space one).
2278 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2280 [(ARMintretflag imm:$offset)]>;
2283 // Indirect branches
2284 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2286 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2287 [(brind GPR:$dst)]>,
2288 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2290 let Inst{31-4} = 0b1110000100101111111111110001;
2291 let Inst{3-0} = dst;
2294 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2295 "bx", "\t$dst", [/* pattern left blank */]>,
2296 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2298 let Inst{27-4} = 0b000100101111111111110001;
2299 let Inst{3-0} = dst;
2303 // SP is marked as a use to prevent stack-pointer assignments that appear
2304 // immediately before calls from potentially appearing dead.
2306 // FIXME: Do we really need a non-predicated version? If so, it should
2307 // at least be a pseudo instruction expanding to the predicated version
2308 // at MC lowering time.
2309 Defs = [LR], Uses = [SP] in {
2310 def BL : ABXI<0b1011, (outs), (ins arm_bl_target:$func),
2311 IIC_Br, "bl\t$func",
2312 [(ARMcall tglobaladdr:$func)]>,
2313 Requires<[IsARM]>, Sched<[WriteBrL]> {
2314 let Inst{31-28} = 0b1110;
2316 let Inst{23-0} = func;
2317 let DecoderMethod = "DecodeBranchImmInstruction";
2320 def BL_pred : ABI<0b1011, (outs), (ins arm_bl_target:$func),
2321 IIC_Br, "bl", "\t$func",
2322 [(ARMcall_pred tglobaladdr:$func)]>,
2323 Requires<[IsARM]>, Sched<[WriteBrL]> {
2325 let Inst{23-0} = func;
2326 let DecoderMethod = "DecodeBranchImmInstruction";
2330 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2331 IIC_Br, "blx\t$func",
2332 [(ARMcall GPR:$func)]>,
2333 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2335 let Inst{31-4} = 0b1110000100101111111111110011;
2336 let Inst{3-0} = func;
2339 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2340 IIC_Br, "blx", "\t$func",
2341 [(ARMcall_pred GPR:$func)]>,
2342 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2344 let Inst{27-4} = 0b000100101111111111110011;
2345 let Inst{3-0} = func;
2349 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2350 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2351 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2352 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2355 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2356 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2357 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2359 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2360 // return stack predictor.
2361 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins arm_bl_target:$func),
2362 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2363 Requires<[IsARM]>, Sched<[WriteBr]>;
2366 let isBranch = 1, isTerminator = 1 in {
2367 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2368 // a two-value operand where a dag node expects two operands. :(
2369 def Bcc : ABI<0b1010, (outs), (ins arm_br_target:$target),
2370 IIC_Br, "b", "\t$target",
2371 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2374 let Inst{23-0} = target;
2375 let DecoderMethod = "DecodeBranchImmInstruction";
2378 let isBarrier = 1 in {
2379 // B is "predicable" since it's just a Bcc with an 'always' condition.
2380 let isPredicable = 1 in
2381 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2382 // should be sufficient.
2383 // FIXME: Is B really a Barrier? That doesn't seem right.
2384 def B : ARMPseudoExpand<(outs), (ins arm_br_target:$target), 4, IIC_Br,
2385 [(br bb:$target)], (Bcc arm_br_target:$target,
2386 (ops 14, zero_reg))>,
2389 let Size = 4, isNotDuplicable = 1, isIndirectBranch = 1 in {
2390 def BR_JTr : ARMPseudoInst<(outs),
2391 (ins GPR:$target, i32imm:$jt),
2393 [(ARMbrjt GPR:$target, tjumptable:$jt)]>,
2395 def BR_JTm_i12 : ARMPseudoInst<(outs),
2396 (ins addrmode_imm12:$target, i32imm:$jt),
2398 [(ARMbrjt (i32 (load addrmode_imm12:$target)),
2399 tjumptable:$jt)]>, Sched<[WriteBrTbl]>;
2400 def BR_JTm_rs : ARMPseudoInst<(outs),
2401 (ins ldst_so_reg:$target, i32imm:$jt),
2403 [(ARMbrjt (i32 (load ldst_so_reg:$target)),
2404 tjumptable:$jt)]>, Sched<[WriteBrTbl]>;
2405 def BR_JTadd : ARMPseudoInst<(outs),
2406 (ins GPR:$target, GPR:$idx, i32imm:$jt),
2408 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt)]>,
2409 Sched<[WriteBrTbl]>;
2410 } // isNotDuplicable = 1, isIndirectBranch = 1
2416 def BLXi : AXI<(outs), (ins arm_blx_target:$target), BrMiscFrm, NoItinerary,
2417 "blx\t$target", []>,
2418 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2419 let Inst{31-25} = 0b1111101;
2421 let Inst{23-0} = target{24-1};
2422 let Inst{24} = target{0};
2426 // Branch and Exchange Jazelle
2427 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2428 [/* pattern left blank */]>, Sched<[WriteBr]> {
2430 let Inst{23-20} = 0b0010;
2431 let Inst{19-8} = 0xfff;
2432 let Inst{7-4} = 0b0010;
2433 let Inst{3-0} = func;
2439 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2440 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2443 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2446 def TAILJMPd : ARMPseudoExpand<(outs), (ins arm_br_target:$dst),
2448 (Bcc arm_br_target:$dst, (ops 14, zero_reg))>,
2449 Requires<[IsARM]>, Sched<[WriteBr]>;
2451 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2453 (BX GPR:$dst)>, Sched<[WriteBr]>,
2454 Requires<[IsARM, HasV4T]>;
2457 // Secure Monitor Call is a system instruction.
2458 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2459 []>, Requires<[IsARM, HasTrustZone]> {
2461 let Inst{23-4} = 0b01100000000000000111;
2462 let Inst{3-0} = opt;
2464 def : MnemonicAlias<"smi", "smc">;
2466 // Supervisor Call (Software Interrupt)
2467 let isCall = 1, Uses = [SP] in {
2468 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2471 let Inst{23-0} = svc;
2475 // Store Return State
2476 class SRSI<bit wb, string asm>
2477 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2478 NoItinerary, asm, "", []> {
2480 let Inst{31-28} = 0b1111;
2481 let Inst{27-25} = 0b100;
2485 let Inst{19-16} = 0b1101; // SP
2486 let Inst{15-5} = 0b00000101000;
2487 let Inst{4-0} = mode;
2490 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2491 let Inst{24-23} = 0;
2493 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2494 let Inst{24-23} = 0;
2496 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2497 let Inst{24-23} = 0b10;
2499 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2500 let Inst{24-23} = 0b10;
2502 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2503 let Inst{24-23} = 0b01;
2505 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2506 let Inst{24-23} = 0b01;
2508 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2509 let Inst{24-23} = 0b11;
2511 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2512 let Inst{24-23} = 0b11;
2515 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2516 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2518 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2519 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2521 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2522 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2524 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2525 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2527 // Return From Exception
2528 class RFEI<bit wb, string asm>
2529 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2530 NoItinerary, asm, "", []> {
2532 let Inst{31-28} = 0b1111;
2533 let Inst{27-25} = 0b100;
2537 let Inst{19-16} = Rn;
2538 let Inst{15-0} = 0xa00;
2541 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2542 let Inst{24-23} = 0;
2544 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2545 let Inst{24-23} = 0;
2547 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2548 let Inst{24-23} = 0b10;
2550 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2551 let Inst{24-23} = 0b10;
2553 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2554 let Inst{24-23} = 0b01;
2556 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2557 let Inst{24-23} = 0b01;
2559 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2560 let Inst{24-23} = 0b11;
2562 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2563 let Inst{24-23} = 0b11;
2566 // Hypervisor Call is a system instruction
2568 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2569 "hvc", "\t$imm", []>,
2570 Requires<[IsARM, HasVirtualization]> {
2573 // Even though HVC isn't predicable, it's encoding includes a condition field.
2574 // The instruction is undefined if the condition field is 0xf otherwise it is
2575 // unpredictable if it isn't condition AL (0xe).
2576 let Inst{31-28} = 0b1110;
2577 let Unpredictable{31-28} = 0b1111;
2578 let Inst{27-24} = 0b0001;
2579 let Inst{23-20} = 0b0100;
2580 let Inst{19-8} = imm{15-4};
2581 let Inst{7-4} = 0b0111;
2582 let Inst{3-0} = imm{3-0};
2586 // Return from exception in Hypervisor mode.
2587 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2588 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2589 Requires<[IsARM, HasVirtualization]> {
2590 let Inst{23-0} = 0b011000000000000001101110;
2593 //===----------------------------------------------------------------------===//
2594 // Load / Store Instructions.
2600 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si, load>;
2601 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2603 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si, store>;
2604 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2607 // Special LDR for loads from non-pc-relative constpools.
2608 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2609 isReMaterializable = 1, isCodeGenOnly = 1 in
2610 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2611 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2615 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2616 let Inst{19-16} = 0b1111;
2617 let Inst{15-12} = Rt;
2618 let Inst{11-0} = addr{11-0}; // imm12
2621 // Loads with zero extension
2622 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2623 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2624 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2626 // Loads with sign extension
2627 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2628 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2629 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2631 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2632 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2633 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2635 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2637 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2638 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2639 Requires<[IsARM, HasV5TE]>;
2642 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2643 NoItinerary, "lda", "\t$Rt, $addr", []>;
2644 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2645 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2646 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2647 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2650 multiclass AI2_ldridx<bit isByte, string opc,
2651 InstrItinClass iii, InstrItinClass iir> {
2652 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2653 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2654 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2657 let Inst{23} = addr{12};
2658 let Inst{19-16} = addr{16-13};
2659 let Inst{11-0} = addr{11-0};
2660 let DecoderMethod = "DecodeLDRPreImm";
2663 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2664 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2665 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2668 let Inst{23} = addr{12};
2669 let Inst{19-16} = addr{16-13};
2670 let Inst{11-0} = addr{11-0};
2672 let DecoderMethod = "DecodeLDRPreReg";
2675 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2676 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2677 IndexModePost, LdFrm, iir,
2678 opc, "\t$Rt, $addr, $offset",
2679 "$addr.base = $Rn_wb", []> {
2685 let Inst{23} = offset{12};
2686 let Inst{19-16} = addr;
2687 let Inst{11-0} = offset{11-0};
2690 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2693 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2694 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2695 IndexModePost, LdFrm, iii,
2696 opc, "\t$Rt, $addr, $offset",
2697 "$addr.base = $Rn_wb", []> {
2703 let Inst{23} = offset{12};
2704 let Inst{19-16} = addr;
2705 let Inst{11-0} = offset{11-0};
2707 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2712 let mayLoad = 1, hasSideEffects = 0 in {
2713 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2714 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2715 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2716 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2719 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2720 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2721 (ins addrmode3_pre:$addr), IndexModePre,
2723 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2725 let Inst{23} = addr{8}; // U bit
2726 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2727 let Inst{19-16} = addr{12-9}; // Rn
2728 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2729 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2730 let DecoderMethod = "DecodeAddrMode3Instruction";
2732 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2733 (ins addr_offset_none:$addr, am3offset:$offset),
2734 IndexModePost, LdMiscFrm, itin,
2735 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2739 let Inst{23} = offset{8}; // U bit
2740 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2741 let Inst{19-16} = addr;
2742 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2743 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2744 let DecoderMethod = "DecodeAddrMode3Instruction";
2748 let mayLoad = 1, hasSideEffects = 0 in {
2749 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2750 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2751 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2752 let hasExtraDefRegAllocReq = 1 in {
2753 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2754 (ins addrmode3_pre:$addr), IndexModePre,
2755 LdMiscFrm, IIC_iLoad_d_ru,
2756 "ldrd", "\t$Rt, $Rt2, $addr!",
2757 "$addr.base = $Rn_wb", []> {
2759 let Inst{23} = addr{8}; // U bit
2760 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2761 let Inst{19-16} = addr{12-9}; // Rn
2762 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2763 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2764 let DecoderMethod = "DecodeAddrMode3Instruction";
2766 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2767 (ins addr_offset_none:$addr, am3offset:$offset),
2768 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2769 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2770 "$addr.base = $Rn_wb", []> {
2773 let Inst{23} = offset{8}; // U bit
2774 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2775 let Inst{19-16} = addr;
2776 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2777 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2778 let DecoderMethod = "DecodeAddrMode3Instruction";
2780 } // hasExtraDefRegAllocReq = 1
2781 } // mayLoad = 1, hasSideEffects = 0
2783 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2784 let mayLoad = 1, hasSideEffects = 0 in {
2785 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2786 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2787 IndexModePost, LdFrm, IIC_iLoad_ru,
2788 "ldrt", "\t$Rt, $addr, $offset",
2789 "$addr.base = $Rn_wb", []> {
2795 let Inst{23} = offset{12};
2796 let Inst{21} = 1; // overwrite
2797 let Inst{19-16} = addr;
2798 let Inst{11-5} = offset{11-5};
2800 let Inst{3-0} = offset{3-0};
2801 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2805 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2806 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2807 IndexModePost, LdFrm, IIC_iLoad_ru,
2808 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2814 let Inst{23} = offset{12};
2815 let Inst{21} = 1; // overwrite
2816 let Inst{19-16} = addr;
2817 let Inst{11-0} = offset{11-0};
2818 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2821 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2822 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2823 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2824 "ldrbt", "\t$Rt, $addr, $offset",
2825 "$addr.base = $Rn_wb", []> {
2831 let Inst{23} = offset{12};
2832 let Inst{21} = 1; // overwrite
2833 let Inst{19-16} = addr;
2834 let Inst{11-5} = offset{11-5};
2836 let Inst{3-0} = offset{3-0};
2837 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2841 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2842 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2843 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2844 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2850 let Inst{23} = offset{12};
2851 let Inst{21} = 1; // overwrite
2852 let Inst{19-16} = addr;
2853 let Inst{11-0} = offset{11-0};
2854 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2857 multiclass AI3ldrT<bits<4> op, string opc> {
2858 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2859 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2860 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2861 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2863 let Inst{23} = offset{8};
2865 let Inst{11-8} = offset{7-4};
2866 let Inst{3-0} = offset{3-0};
2868 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2869 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2870 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2871 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2873 let Inst{23} = Rm{4};
2876 let Unpredictable{11-8} = 0b1111;
2877 let Inst{3-0} = Rm{3-0};
2878 let DecoderMethod = "DecodeLDR";
2882 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2883 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2884 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2888 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2892 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2895 // Pseudo instruction ldr Rt, =immediate
2897 : ARMAsmPseudo<"ldr${q} $Rt, $immediate",
2898 (ins const_pool_asm_imm:$immediate, pred:$q),
2903 // Stores with truncate
2904 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2905 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2906 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2909 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2910 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2911 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2912 Requires<[IsARM, HasV5TE]> {
2918 multiclass AI2_stridx<bit isByte, string opc,
2919 InstrItinClass iii, InstrItinClass iir> {
2920 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2921 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
2923 opc, "\t$Rt, $addr!",
2924 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2927 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2928 let Inst{19-16} = addr{16-13}; // Rn
2929 let Inst{11-0} = addr{11-0}; // imm12
2930 let DecoderMethod = "DecodeSTRPreImm";
2933 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2934 (ins GPR:$Rt, ldst_so_reg:$addr),
2935 IndexModePre, StFrm, iir,
2936 opc, "\t$Rt, $addr!",
2937 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2940 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2941 let Inst{19-16} = addr{16-13}; // Rn
2942 let Inst{11-0} = addr{11-0};
2943 let Inst{4} = 0; // Inst{4} = 0
2944 let DecoderMethod = "DecodeSTRPreReg";
2946 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2947 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2948 IndexModePost, StFrm, iir,
2949 opc, "\t$Rt, $addr, $offset",
2950 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2956 let Inst{23} = offset{12};
2957 let Inst{19-16} = addr;
2958 let Inst{11-0} = offset{11-0};
2961 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2964 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2965 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2966 IndexModePost, StFrm, iii,
2967 opc, "\t$Rt, $addr, $offset",
2968 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2974 let Inst{23} = offset{12};
2975 let Inst{19-16} = addr;
2976 let Inst{11-0} = offset{11-0};
2978 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2982 let mayStore = 1, hasSideEffects = 0 in {
2983 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2984 // IIC_iStore_siu depending on whether it the offset register is shifted.
2985 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2986 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2989 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2990 am2offset_reg:$offset),
2991 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2992 am2offset_reg:$offset)>;
2993 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2994 am2offset_imm:$offset),
2995 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2996 am2offset_imm:$offset)>;
2997 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2998 am2offset_reg:$offset),
2999 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
3000 am2offset_reg:$offset)>;
3001 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
3002 am2offset_imm:$offset),
3003 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
3004 am2offset_imm:$offset)>;
3006 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
3007 // put the patterns on the instruction definitions directly as ISel wants
3008 // the address base and offset to be separate operands, not a single
3009 // complex operand like we represent the instructions themselves. The
3010 // pseudos map between the two.
3011 let usesCustomInserter = 1,
3012 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
3013 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3014 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
3017 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
3018 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3019 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
3022 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
3023 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3024 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
3027 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
3028 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3029 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
3032 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
3033 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3034 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
3037 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
3042 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
3043 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
3044 StMiscFrm, IIC_iStore_bh_ru,
3045 "strh", "\t$Rt, $addr!",
3046 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
3048 let Inst{23} = addr{8}; // U bit
3049 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
3050 let Inst{19-16} = addr{12-9}; // Rn
3051 let Inst{11-8} = addr{7-4}; // imm7_4/zero
3052 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
3053 let DecoderMethod = "DecodeAddrMode3Instruction";
3056 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
3057 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
3058 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
3059 "strh", "\t$Rt, $addr, $offset",
3060 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
3061 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
3062 addr_offset_none:$addr,
3063 am3offset:$offset))]> {
3066 let Inst{23} = offset{8}; // U bit
3067 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
3068 let Inst{19-16} = addr;
3069 let Inst{11-8} = offset{7-4}; // imm7_4/zero
3070 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
3071 let DecoderMethod = "DecodeAddrMode3Instruction";
3074 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
3075 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
3076 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
3077 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
3078 "strd", "\t$Rt, $Rt2, $addr!",
3079 "$addr.base = $Rn_wb", []> {
3081 let Inst{23} = addr{8}; // U bit
3082 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
3083 let Inst{19-16} = addr{12-9}; // Rn
3084 let Inst{11-8} = addr{7-4}; // imm7_4/zero
3085 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
3086 let DecoderMethod = "DecodeAddrMode3Instruction";
3089 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
3090 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
3092 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
3093 "strd", "\t$Rt, $Rt2, $addr, $offset",
3094 "$addr.base = $Rn_wb", []> {
3097 let Inst{23} = offset{8}; // U bit
3098 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
3099 let Inst{19-16} = addr;
3100 let Inst{11-8} = offset{7-4}; // imm7_4/zero
3101 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
3102 let DecoderMethod = "DecodeAddrMode3Instruction";
3104 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
3106 // STRT, STRBT, and STRHT
3108 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
3109 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3110 IndexModePost, StFrm, IIC_iStore_bh_ru,
3111 "strbt", "\t$Rt, $addr, $offset",
3112 "$addr.base = $Rn_wb", []> {
3118 let Inst{23} = offset{12};
3119 let Inst{21} = 1; // overwrite
3120 let Inst{19-16} = addr;
3121 let Inst{11-5} = offset{11-5};
3123 let Inst{3-0} = offset{3-0};
3124 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3128 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
3129 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3130 IndexModePost, StFrm, IIC_iStore_bh_ru,
3131 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3137 let Inst{23} = offset{12};
3138 let Inst{21} = 1; // overwrite
3139 let Inst{19-16} = addr;
3140 let Inst{11-0} = offset{11-0};
3141 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3145 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
3146 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3148 let mayStore = 1, hasSideEffects = 0 in {
3149 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3150 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3151 IndexModePost, StFrm, IIC_iStore_ru,
3152 "strt", "\t$Rt, $addr, $offset",
3153 "$addr.base = $Rn_wb", []> {
3159 let Inst{23} = offset{12};
3160 let Inst{21} = 1; // overwrite
3161 let Inst{19-16} = addr;
3162 let Inst{11-5} = offset{11-5};
3164 let Inst{3-0} = offset{3-0};
3165 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3169 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3170 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3171 IndexModePost, StFrm, IIC_iStore_ru,
3172 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3178 let Inst{23} = offset{12};
3179 let Inst{21} = 1; // overwrite
3180 let Inst{19-16} = addr;
3181 let Inst{11-0} = offset{11-0};
3182 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3187 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3188 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3190 multiclass AI3strT<bits<4> op, string opc> {
3191 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3192 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3193 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3194 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3196 let Inst{23} = offset{8};
3198 let Inst{11-8} = offset{7-4};
3199 let Inst{3-0} = offset{3-0};
3201 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3202 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3203 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3204 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3206 let Inst{23} = Rm{4};
3209 let Inst{3-0} = Rm{3-0};
3214 defm STRHT : AI3strT<0b1011, "strht">;
3216 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3217 NoItinerary, "stl", "\t$Rt, $addr", []>;
3218 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3219 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3220 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3221 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3223 //===----------------------------------------------------------------------===//
3224 // Load / store multiple Instructions.
3227 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3228 InstrItinClass itin, InstrItinClass itin_upd> {
3229 // IA is the default, so no need for an explicit suffix on the
3230 // mnemonic here. Without it is the canonical spelling.
3232 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3233 IndexModeNone, f, itin,
3234 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3235 let Inst{24-23} = 0b01; // Increment After
3236 let Inst{22} = P_bit;
3237 let Inst{21} = 0; // No writeback
3238 let Inst{20} = L_bit;
3241 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3242 IndexModeUpd, f, itin_upd,
3243 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3244 let Inst{24-23} = 0b01; // Increment After
3245 let Inst{22} = P_bit;
3246 let Inst{21} = 1; // Writeback
3247 let Inst{20} = L_bit;
3249 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3252 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3253 IndexModeNone, f, itin,
3254 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3255 let Inst{24-23} = 0b00; // Decrement After
3256 let Inst{22} = P_bit;
3257 let Inst{21} = 0; // No writeback
3258 let Inst{20} = L_bit;
3261 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3262 IndexModeUpd, f, itin_upd,
3263 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3264 let Inst{24-23} = 0b00; // Decrement After
3265 let Inst{22} = P_bit;
3266 let Inst{21} = 1; // Writeback
3267 let Inst{20} = L_bit;
3269 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3272 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3273 IndexModeNone, f, itin,
3274 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
3275 let Inst{24-23} = 0b10; // Decrement Before
3276 let Inst{22} = P_bit;
3277 let Inst{21} = 0; // No writeback
3278 let Inst{20} = L_bit;
3281 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3282 IndexModeUpd, f, itin_upd,
3283 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3284 let Inst{24-23} = 0b10; // Decrement Before
3285 let Inst{22} = P_bit;
3286 let Inst{21} = 1; // Writeback
3287 let Inst{20} = L_bit;
3289 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3292 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3293 IndexModeNone, f, itin,
3294 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
3295 let Inst{24-23} = 0b11; // Increment Before
3296 let Inst{22} = P_bit;
3297 let Inst{21} = 0; // No writeback
3298 let Inst{20} = L_bit;
3301 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3302 IndexModeUpd, f, itin_upd,
3303 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3304 let Inst{24-23} = 0b11; // Increment Before
3305 let Inst{22} = P_bit;
3306 let Inst{21} = 1; // Writeback
3307 let Inst{20} = L_bit;
3309 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3313 let hasSideEffects = 0 in {
3315 let mayLoad = 1, hasExtraDefRegAllocReq = 1, variadicOpsAreDefs = 1 in
3316 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3317 IIC_iLoad_mu>, ComplexDeprecationPredicate<"ARMLoad">;
3319 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3320 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3322 ComplexDeprecationPredicate<"ARMStore">;
3326 // FIXME: remove when we have a way to marking a MI with these properties.
3327 // FIXME: Should pc be an implicit operand like PICADD, etc?
3328 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3329 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3330 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3331 reglist:$regs, variable_ops),
3332 4, IIC_iLoad_mBr, [],
3333 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3334 RegConstraint<"$Rn = $wb">;
3336 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3337 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3340 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3341 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3346 //===----------------------------------------------------------------------===//
3347 // Move Instructions.
3350 let hasSideEffects = 0, isMoveReg = 1 in
3351 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3352 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3356 let Inst{19-16} = 0b0000;
3357 let Inst{11-4} = 0b00000000;
3360 let Inst{15-12} = Rd;
3363 // A version for the smaller set of tail call registers.
3364 let hasSideEffects = 0 in
3365 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3366 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3370 let Inst{11-4} = 0b00000000;
3373 let Inst{15-12} = Rd;
3376 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3377 DPSoRegRegFrm, IIC_iMOVsr,
3378 "mov", "\t$Rd, $src",
3379 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3383 let Inst{15-12} = Rd;
3384 let Inst{19-16} = 0b0000;
3385 let Inst{11-8} = src{11-8};
3387 let Inst{6-5} = src{6-5};
3389 let Inst{3-0} = src{3-0};
3393 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3394 DPSoRegImmFrm, IIC_iMOVsr,
3395 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3396 UnaryDP, Sched<[WriteALU]> {
3399 let Inst{15-12} = Rd;
3400 let Inst{19-16} = 0b0000;
3401 let Inst{11-5} = src{11-5};
3403 let Inst{3-0} = src{3-0};
3407 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3408 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3409 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3414 let Inst{15-12} = Rd;
3415 let Inst{19-16} = 0b0000;
3416 let Inst{11-0} = imm;
3419 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3420 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3422 "movw", "\t$Rd, $imm",
3423 [(set GPR:$Rd, imm0_65535:$imm)]>,
3424 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3427 let Inst{15-12} = Rd;
3428 let Inst{11-0} = imm{11-0};
3429 let Inst{19-16} = imm{15-12};
3432 let DecoderMethod = "DecodeArmMOVTWInstruction";
3435 def : InstAlias<"mov${p} $Rd, $imm",
3436 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p), 0>,
3437 Requires<[IsARM, HasV6T2]>;
3439 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3440 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3443 let Constraints = "$src = $Rd" in {
3444 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3445 (ins GPR:$src, imm0_65535_expr:$imm),
3447 "movt", "\t$Rd, $imm",
3449 (or (and GPR:$src, 0xffff),
3450 lo16AllZero:$imm))]>, UnaryDP,
3451 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3454 let Inst{15-12} = Rd;
3455 let Inst{11-0} = imm{11-0};
3456 let Inst{19-16} = imm{15-12};
3459 let DecoderMethod = "DecodeArmMOVTWInstruction";
3462 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3463 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3468 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3469 Requires<[IsARM, HasV6T2]>;
3471 let Uses = [CPSR] in
3472 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3473 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3474 Requires<[IsARM]>, Sched<[WriteALU]>;
3476 // These aren't really mov instructions, but we have to define them this way
3477 // due to flag operands.
3479 let Defs = [CPSR] in {
3480 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3481 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3482 Sched<[WriteALU]>, Requires<[IsARM]>;
3483 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3484 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3485 Sched<[WriteALU]>, Requires<[IsARM]>;
3488 //===----------------------------------------------------------------------===//
3489 // Extend Instructions.
3494 def SXTB : AI_ext_rrot<0b01101010,
3495 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3496 def SXTH : AI_ext_rrot<0b01101011,
3497 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3499 def SXTAB : AI_exta_rrot<0b01101010,
3500 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3501 def SXTAH : AI_exta_rrot<0b01101011,
3502 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3504 def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, rot_imm:$rot), i8)),
3505 (SXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3506 def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, imm8_or_16:$rot),
3508 (SXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3510 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3511 def : ARMV6Pat<(int_arm_sxtb16 GPR:$Src),
3512 (SXTB16 GPR:$Src, 0)>;
3513 def : ARMV6Pat<(int_arm_sxtb16 (rotr GPR:$Src, rot_imm:$rot)),
3514 (SXTB16 GPR:$Src, rot_imm:$rot)>;
3516 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3517 def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, GPR:$RHS),
3518 (SXTAB16 GPR:$LHS, GPR:$RHS, 0)>;
3519 def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)),
3520 (SXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>;
3524 let AddedComplexity = 16 in {
3525 def UXTB : AI_ext_rrot<0b01101110,
3526 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3527 def UXTH : AI_ext_rrot<0b01101111,
3528 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3529 def UXTB16 : AI_ext_rrot<0b01101100,
3530 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3532 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3533 // The transformation should probably be done as a combiner action
3534 // instead so we can include a check for masking back in the upper
3535 // eight bits of the source into the lower eight bits of the result.
3536 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3537 // (UXTB16r_rot GPR:$Src, 3)>;
3538 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3539 (UXTB16 GPR:$Src, 1)>;
3540 def : ARMV6Pat<(int_arm_uxtb16 GPR:$Src),
3541 (UXTB16 GPR:$Src, 0)>;
3542 def : ARMV6Pat<(int_arm_uxtb16 (rotr GPR:$Src, rot_imm:$rot)),
3543 (UXTB16 GPR:$Src, rot_imm:$rot)>;
3545 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3546 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3547 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3548 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3550 def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, rot_imm:$rot), 0xFF)),
3551 (UXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3552 def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, imm8_or_16:$rot), 0xFFFF)),
3553 (UXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3556 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3557 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3558 def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, GPR:$RHS),
3559 (UXTAB16 GPR:$LHS, GPR:$RHS, 0)>;
3560 def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)),
3561 (UXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>;
3564 def SBFX : I<(outs GPRnopc:$Rd),
3565 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3566 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3567 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3568 Requires<[IsARM, HasV6T2]> {
3573 let Inst{27-21} = 0b0111101;
3574 let Inst{6-4} = 0b101;
3575 let Inst{20-16} = width;
3576 let Inst{15-12} = Rd;
3577 let Inst{11-7} = lsb;
3581 def UBFX : I<(outs GPRnopc:$Rd),
3582 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3583 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3584 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3585 Requires<[IsARM, HasV6T2]> {
3590 let Inst{27-21} = 0b0111111;
3591 let Inst{6-4} = 0b101;
3592 let Inst{20-16} = width;
3593 let Inst{15-12} = Rd;
3594 let Inst{11-7} = lsb;
3598 //===----------------------------------------------------------------------===//
3599 // Arithmetic Instructions.
3603 defm ADD : AsI1_bin_irs<0b0100, "add",
3604 IIC_iALUi, IIC_iALUr, IIC_iALUsr, add, 1>;
3605 defm SUB : AsI1_bin_irs<0b0010, "sub",
3606 IIC_iALUi, IIC_iALUr, IIC_iALUsr, sub>;
3608 // ADD and SUB with 's' bit set.
3610 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3611 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3612 // AdjustInstrPostInstrSelection where we determine whether or not to
3613 // set the "s" bit based on CPSR liveness.
3615 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3616 // support for an optional CPSR definition that corresponds to the DAG
3617 // node's second value. We can then eliminate the implicit def of CPSR.
3619 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMaddc, 1>;
3620 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
3622 def : ARMPat<(ARMsubs GPR:$Rn, mod_imm:$imm), (SUBSri $Rn, mod_imm:$imm)>;
3623 def : ARMPat<(ARMsubs GPR:$Rn, GPR:$Rm), (SUBSrr $Rn, $Rm)>;
3624 def : ARMPat<(ARMsubs GPR:$Rn, so_reg_imm:$shift),
3625 (SUBSrsi $Rn, so_reg_imm:$shift)>;
3626 def : ARMPat<(ARMsubs GPR:$Rn, so_reg_reg:$shift),
3627 (SUBSrsr $Rn, so_reg_reg:$shift)>;
3631 defm ADC : AI1_adde_sube_irs<0b0101, "adc", ARMadde, 1>;
3632 defm SBC : AI1_adde_sube_irs<0b0110, "sbc", ARMsube>;
3634 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3635 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3638 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3639 // CPSR and the implicit def of CPSR is not needed.
3640 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
3642 defm RSC : AI1_rsc_irs<0b0111, "rsc", ARMsube>;
3644 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3645 // The assume-no-carry-in form uses the negation of the input since add/sub
3646 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3647 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3649 def : ARMPat<(add GPR:$src, mod_imm_neg:$imm),
3650 (SUBri GPR:$src, mod_imm_neg:$imm)>;
3651 def : ARMPat<(ARMaddc GPR:$src, mod_imm_neg:$imm),
3652 (SUBSri GPR:$src, mod_imm_neg:$imm)>;
3654 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3655 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3656 Requires<[IsARM, HasV6T2]>;
3657 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3658 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3659 Requires<[IsARM, HasV6T2]>;
3661 // The with-carry-in form matches bitwise not instead of the negation.
3662 // Effectively, the inverse interpretation of the carry flag already accounts
3663 // for part of the negation.
3664 def : ARMPat<(ARMadde GPR:$src, mod_imm_not:$imm, CPSR),
3665 (SBCri GPR:$src, mod_imm_not:$imm)>;
3666 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3667 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
3668 Requires<[IsARM, HasV6T2]>;
3670 // Note: These are implemented in C++ code, because they have to generate
3671 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3673 // (mul X, 2^n+1) -> (add (X << n), X)
3674 // (mul X, 2^n-1) -> (rsb X, (X << n))
3676 // ARM Arithmetic Instruction
3677 // GPR:$dst = GPR:$a op GPR:$b
3678 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3679 list<dag> pattern = [],
3680 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3681 string asm = "\t$Rd, $Rn, $Rm">
3682 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>,
3683 Sched<[WriteALU, ReadALU, ReadALU]> {
3687 let Inst{27-20} = op27_20;
3688 let Inst{11-4} = op11_4;
3689 let Inst{19-16} = Rn;
3690 let Inst{15-12} = Rd;
3693 let Unpredictable{11-8} = 0b1111;
3696 // Wrappers around the AAI class
3697 class AAIRevOpr<bits<8> op27_20, bits<8> op11_4, string opc,
3698 list<dag> pattern = []>
3699 : AAI<op27_20, op11_4, opc,
3701 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3704 class AAIIntrinsic<bits<8> op27_20, bits<8> op11_4, string opc,
3705 Intrinsic intrinsic>
3706 : AAI<op27_20, op11_4, opc,
3707 [(set GPRnopc:$Rd, (intrinsic GPRnopc:$Rn, GPRnopc:$Rm))]>;
3709 // Saturating add/subtract
3710 let hasSideEffects = 1 in {
3711 def QADD8 : AAIIntrinsic<0b01100010, 0b11111001, "qadd8", int_arm_qadd8>;
3712 def QADD16 : AAIIntrinsic<0b01100010, 0b11110001, "qadd16", int_arm_qadd16>;
3713 def QSUB16 : AAIIntrinsic<0b01100010, 0b11110111, "qsub16", int_arm_qsub16>;
3714 def QSUB8 : AAIIntrinsic<0b01100010, 0b11111111, "qsub8", int_arm_qsub8>;
3716 def QDADD : AAIRevOpr<0b00010100, 0b00000101, "qdadd",
3717 [(set GPRnopc:$Rd, (int_arm_qadd (int_arm_qadd GPRnopc:$Rm,
3720 def QDSUB : AAIRevOpr<0b00010110, 0b00000101, "qdsub",
3721 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm,
3722 (int_arm_qadd GPRnopc:$Rn, GPRnopc:$Rn)))]>;
3723 def QSUB : AAIRevOpr<0b00010010, 0b00000101, "qsub",
3724 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))]>;
3725 let DecoderMethod = "DecodeQADDInstruction" in
3726 def QADD : AAIRevOpr<0b00010000, 0b00000101, "qadd",
3727 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))]>;
3730 def UQADD16 : AAIIntrinsic<0b01100110, 0b11110001, "uqadd16", int_arm_uqadd16>;
3731 def UQADD8 : AAIIntrinsic<0b01100110, 0b11111001, "uqadd8", int_arm_uqadd8>;
3732 def UQSUB16 : AAIIntrinsic<0b01100110, 0b11110111, "uqsub16", int_arm_uqsub16>;
3733 def UQSUB8 : AAIIntrinsic<0b01100110, 0b11111111, "uqsub8", int_arm_uqsub8>;
3734 def QASX : AAIIntrinsic<0b01100010, 0b11110011, "qasx", int_arm_qasx>;
3735 def QSAX : AAIIntrinsic<0b01100010, 0b11110101, "qsax", int_arm_qsax>;
3736 def UQASX : AAIIntrinsic<0b01100110, 0b11110011, "uqasx", int_arm_uqasx>;
3737 def UQSAX : AAIIntrinsic<0b01100110, 0b11110101, "uqsax", int_arm_uqsax>;
3739 // Signed/Unsigned add/subtract
3741 def SASX : AAIIntrinsic<0b01100001, 0b11110011, "sasx", int_arm_sasx>;
3742 def SADD16 : AAIIntrinsic<0b01100001, 0b11110001, "sadd16", int_arm_sadd16>;
3743 def SADD8 : AAIIntrinsic<0b01100001, 0b11111001, "sadd8", int_arm_sadd8>;
3744 def SSAX : AAIIntrinsic<0b01100001, 0b11110101, "ssax", int_arm_ssax>;
3745 def SSUB16 : AAIIntrinsic<0b01100001, 0b11110111, "ssub16", int_arm_ssub16>;
3746 def SSUB8 : AAIIntrinsic<0b01100001, 0b11111111, "ssub8", int_arm_ssub8>;
3747 def UASX : AAIIntrinsic<0b01100101, 0b11110011, "uasx", int_arm_uasx>;
3748 def UADD16 : AAIIntrinsic<0b01100101, 0b11110001, "uadd16", int_arm_uadd16>;
3749 def UADD8 : AAIIntrinsic<0b01100101, 0b11111001, "uadd8", int_arm_uadd8>;
3750 def USAX : AAIIntrinsic<0b01100101, 0b11110101, "usax", int_arm_usax>;
3751 def USUB16 : AAIIntrinsic<0b01100101, 0b11110111, "usub16", int_arm_usub16>;
3752 def USUB8 : AAIIntrinsic<0b01100101, 0b11111111, "usub8", int_arm_usub8>;
3754 // Signed/Unsigned halving add/subtract
3756 def SHASX : AAIIntrinsic<0b01100011, 0b11110011, "shasx", int_arm_shasx>;
3757 def SHADD16 : AAIIntrinsic<0b01100011, 0b11110001, "shadd16", int_arm_shadd16>;
3758 def SHADD8 : AAIIntrinsic<0b01100011, 0b11111001, "shadd8", int_arm_shadd8>;
3759 def SHSAX : AAIIntrinsic<0b01100011, 0b11110101, "shsax", int_arm_shsax>;
3760 def SHSUB16 : AAIIntrinsic<0b01100011, 0b11110111, "shsub16", int_arm_shsub16>;
3761 def SHSUB8 : AAIIntrinsic<0b01100011, 0b11111111, "shsub8", int_arm_shsub8>;
3762 def UHASX : AAIIntrinsic<0b01100111, 0b11110011, "uhasx", int_arm_uhasx>;
3763 def UHADD16 : AAIIntrinsic<0b01100111, 0b11110001, "uhadd16", int_arm_uhadd16>;
3764 def UHADD8 : AAIIntrinsic<0b01100111, 0b11111001, "uhadd8", int_arm_uhadd8>;
3765 def UHSAX : AAIIntrinsic<0b01100111, 0b11110101, "uhsax", int_arm_uhsax>;
3766 def UHSUB16 : AAIIntrinsic<0b01100111, 0b11110111, "uhsub16", int_arm_uhsub16>;
3767 def UHSUB8 : AAIIntrinsic<0b01100111, 0b11111111, "uhsub8", int_arm_uhsub8>;
3769 // Unsigned Sum of Absolute Differences [and Accumulate].
3771 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3772 MulFrm /* for convenience */, NoItinerary, "usad8",
3774 [(set GPR:$Rd, (int_arm_usad8 GPR:$Rn, GPR:$Rm))]>,
3775 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> {
3779 let Inst{27-20} = 0b01111000;
3780 let Inst{15-12} = 0b1111;
3781 let Inst{7-4} = 0b0001;
3782 let Inst{19-16} = Rd;
3783 let Inst{11-8} = Rm;
3786 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3787 MulFrm /* for convenience */, NoItinerary, "usada8",
3788 "\t$Rd, $Rn, $Rm, $Ra",
3789 [(set GPR:$Rd, (int_arm_usada8 GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
3790 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{
3795 let Inst{27-20} = 0b01111000;
3796 let Inst{7-4} = 0b0001;
3797 let Inst{19-16} = Rd;
3798 let Inst{15-12} = Ra;
3799 let Inst{11-8} = Rm;
3803 // Signed/Unsigned saturate
3804 def SSAT : AI<(outs GPRnopc:$Rd),
3805 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3806 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []>,
3807 Requires<[IsARM,HasV6]>{
3812 let Inst{27-21} = 0b0110101;
3813 let Inst{5-4} = 0b01;
3814 let Inst{20-16} = sat_imm;
3815 let Inst{15-12} = Rd;
3816 let Inst{11-7} = sh{4-0};
3817 let Inst{6} = sh{5};
3821 def SSAT16 : AI<(outs GPRnopc:$Rd),
3822 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3823 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []>,
3824 Requires<[IsARM,HasV6]>{
3828 let Inst{27-20} = 0b01101010;
3829 let Inst{11-4} = 0b11110011;
3830 let Inst{15-12} = Rd;
3831 let Inst{19-16} = sat_imm;
3835 def USAT : AI<(outs GPRnopc:$Rd),
3836 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3837 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []>,
3838 Requires<[IsARM,HasV6]> {
3843 let Inst{27-21} = 0b0110111;
3844 let Inst{5-4} = 0b01;
3845 let Inst{15-12} = Rd;
3846 let Inst{11-7} = sh{4-0};
3847 let Inst{6} = sh{5};
3848 let Inst{20-16} = sat_imm;
3852 def USAT16 : AI<(outs GPRnopc:$Rd),
3853 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3854 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []>,
3855 Requires<[IsARM,HasV6]>{
3859 let Inst{27-20} = 0b01101110;
3860 let Inst{11-4} = 0b11110011;
3861 let Inst{15-12} = Rd;
3862 let Inst{19-16} = sat_imm;
3866 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm1_32:$pos),
3867 (SSAT imm1_32:$pos, GPRnopc:$a, 0)>;
3868 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm0_31:$pos),
3869 (USAT imm0_31:$pos, GPRnopc:$a, 0)>;
3870 def : ARMPat<(ARMssatnoshift GPRnopc:$Rn, imm0_31:$imm),
3871 (SSAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
3872 def : ARMPat<(ARMusatnoshift GPRnopc:$Rn, imm0_31:$imm),
3873 (USAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
3874 def : ARMV6Pat<(int_arm_ssat16 GPRnopc:$a, imm1_16:$pos),
3875 (SSAT16 imm1_16:$pos, GPRnopc:$a)>;
3876 def : ARMV6Pat<(int_arm_usat16 GPRnopc:$a, imm0_15:$pos),
3877 (USAT16 imm0_15:$pos, GPRnopc:$a)>;
3879 //===----------------------------------------------------------------------===//
3880 // Bitwise Instructions.
3883 defm AND : AsI1_bin_irs<0b0000, "and",
3884 IIC_iBITi, IIC_iBITr, IIC_iBITsr, and, 1>;
3885 defm ORR : AsI1_bin_irs<0b1100, "orr",
3886 IIC_iBITi, IIC_iBITr, IIC_iBITsr, or, 1>;
3887 defm EOR : AsI1_bin_irs<0b0001, "eor",
3888 IIC_iBITi, IIC_iBITr, IIC_iBITsr, xor, 1>;
3889 defm BIC : AsI1_bin_irs<0b1110, "bic",
3890 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3891 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3893 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3894 // like in the actual instruction encoding. The complexity of mapping the mask
3895 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3896 // instruction description.
3897 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3898 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3899 "bfc", "\t$Rd, $imm", "$src = $Rd",
3900 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3901 Requires<[IsARM, HasV6T2]> {
3904 let Inst{27-21} = 0b0111110;
3905 let Inst{6-0} = 0b0011111;
3906 let Inst{15-12} = Rd;
3907 let Inst{11-7} = imm{4-0}; // lsb
3908 let Inst{20-16} = imm{9-5}; // msb
3911 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3912 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3913 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3914 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3915 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3916 bf_inv_mask_imm:$imm))]>,
3917 Requires<[IsARM, HasV6T2]> {
3921 let Inst{27-21} = 0b0111110;
3922 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3923 let Inst{15-12} = Rd;
3924 let Inst{11-7} = imm{4-0}; // lsb
3925 let Inst{20-16} = imm{9-5}; // width
3929 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3930 "mvn", "\t$Rd, $Rm",
3931 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> {
3935 let Inst{19-16} = 0b0000;
3936 let Inst{11-4} = 0b00000000;
3937 let Inst{15-12} = Rd;
3940 let Unpredictable{19-16} = 0b1111;
3942 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3943 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3944 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP,
3949 let Inst{19-16} = 0b0000;
3950 let Inst{15-12} = Rd;
3951 let Inst{11-5} = shift{11-5};
3953 let Inst{3-0} = shift{3-0};
3955 let Unpredictable{19-16} = 0b1111;
3957 def MVNsr : AsI1<0b1111, (outs GPRnopc:$Rd), (ins so_reg_reg:$shift),
3958 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3959 [(set GPRnopc:$Rd, (not so_reg_reg:$shift))]>, UnaryDP,
3964 let Inst{19-16} = 0b0000;
3965 let Inst{15-12} = Rd;
3966 let Inst{11-8} = shift{11-8};
3968 let Inst{6-5} = shift{6-5};
3970 let Inst{3-0} = shift{3-0};
3972 let Unpredictable{19-16} = 0b1111;
3974 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3975 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm,
3976 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3977 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> {
3981 let Inst{19-16} = 0b0000;
3982 let Inst{15-12} = Rd;
3983 let Inst{11-0} = imm;
3986 let AddedComplexity = 1 in
3987 def : ARMPat<(and GPR:$src, mod_imm_not:$imm),
3988 (BICri GPR:$src, mod_imm_not:$imm)>;
3990 //===----------------------------------------------------------------------===//
3991 // Multiply Instructions.
3993 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3994 string opc, string asm, list<dag> pattern>
3995 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3999 let Inst{19-16} = Rd;
4000 let Inst{11-8} = Rm;
4003 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4004 string opc, string asm, list<dag> pattern>
4005 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4010 let Inst{19-16} = RdHi;
4011 let Inst{15-12} = RdLo;
4012 let Inst{11-8} = Rm;
4015 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4016 string opc, string asm, list<dag> pattern>
4017 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4022 let Inst{19-16} = RdHi;
4023 let Inst{15-12} = RdLo;
4024 let Inst{11-8} = Rm;
4028 // FIXME: The v5 pseudos are only necessary for the additional Constraint
4029 // property. Remove them when it's possible to add those properties
4030 // on an individual MachineInstr, not just an instruction description.
4031 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
4032 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
4033 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4034 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
4035 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
4036 Requires<[IsARM, HasV6]>,
4037 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4038 let Inst{15-12} = 0b0000;
4039 let Unpredictable{15-12} = 0b1111;
4042 let Constraints = "@earlyclobber $Rd" in
4043 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
4044 pred:$p, cc_out:$s),
4046 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
4047 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
4048 Requires<[IsARM, NoV6, UseMulOps]>,
4049 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4052 def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd),
4053 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra),
4054 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
4055 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>,
4056 Requires<[IsARM, HasV6, UseMulOps]>,
4057 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
4059 let Inst{15-12} = Ra;
4062 let Constraints = "@earlyclobber $Rd" in
4063 def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd),
4064 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
4065 pred:$p, cc_out:$s), 4, IIC_iMAC32,
4066 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))],
4067 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>,
4068 Requires<[IsARM, NoV6]>,
4069 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4071 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4072 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
4073 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
4074 Requires<[IsARM, HasV6T2, UseMulOps]>,
4075 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
4080 let Inst{19-16} = Rd;
4081 let Inst{15-12} = Ra;
4082 let Inst{11-8} = Rm;
4086 // Extra precision multiplies with low / high results
4087 let hasSideEffects = 0 in {
4088 let isCommutable = 1 in {
4089 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
4090 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
4091 "smull", "\t$RdLo, $RdHi, $Rn, $Rm",
4092 [(set GPR:$RdLo, GPR:$RdHi,
4093 (smullohi GPR:$Rn, GPR:$Rm))]>,
4094 Requires<[IsARM, HasV6]>,
4095 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4097 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
4098 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
4099 "umull", "\t$RdLo, $RdHi, $Rn, $Rm",
4100 [(set GPR:$RdLo, GPR:$RdHi,
4101 (umullohi GPR:$Rn, GPR:$Rm))]>,
4102 Requires<[IsARM, HasV6]>,
4103 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL]>;
4105 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
4106 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4107 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4109 [(set GPR:$RdLo, GPR:$RdHi,
4110 (smullohi GPR:$Rn, GPR:$Rm))],
4111 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4112 Requires<[IsARM, NoV6]>,
4113 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4115 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4116 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4118 [(set GPR:$RdLo, GPR:$RdHi,
4119 (umullohi GPR:$Rn, GPR:$Rm))],
4120 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4121 Requires<[IsARM, NoV6]>,
4122 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4126 // Multiply + accumulate
4127 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
4128 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
4129 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4130 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4131 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4132 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
4133 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
4134 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4135 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4136 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4138 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
4139 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4141 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4142 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4143 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]> {
4148 let Inst{19-16} = RdHi;
4149 let Inst{15-12} = RdLo;
4150 let Inst{11-8} = Rm;
4155 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in {
4156 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4157 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
4159 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
4160 pred:$p, cc_out:$s)>,
4161 Requires<[IsARM, NoV6]>,
4162 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4163 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4164 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
4166 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
4167 pred:$p, cc_out:$s)>,
4168 Requires<[IsARM, NoV6]>,
4169 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4174 // Most significant word multiply
4175 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4176 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
4177 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
4178 Requires<[IsARM, HasV6]>,
4179 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4180 let Inst{15-12} = 0b1111;
4183 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4184 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm",
4185 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, (i32 0)))]>,
4186 Requires<[IsARM, HasV6]>,
4187 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4188 let Inst{15-12} = 0b1111;
4191 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
4192 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4193 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
4194 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
4195 Requires<[IsARM, HasV6, UseMulOps]>,
4196 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4198 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
4199 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4200 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra",
4201 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
4202 Requires<[IsARM, HasV6]>,
4203 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4205 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
4206 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4207 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
4208 Requires<[IsARM, HasV6, UseMulOps]>,
4209 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4211 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
4212 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4213 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra",
4214 [(set GPR:$Rd, (ARMsmmlsr GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
4215 Requires<[IsARM, HasV6]>,
4216 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4218 multiclass AI_smul<string opc> {
4219 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4220 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
4221 [(set GPR:$Rd, (bb_mul GPR:$Rn, GPR:$Rm))]>,
4222 Requires<[IsARM, HasV5TE]>,
4223 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4225 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4226 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
4227 [(set GPR:$Rd, (bt_mul GPR:$Rn, GPR:$Rm))]>,
4228 Requires<[IsARM, HasV5TE]>,
4229 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4231 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4232 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
4233 [(set GPR:$Rd, (tb_mul GPR:$Rn, GPR:$Rm))]>,
4234 Requires<[IsARM, HasV5TE]>,
4235 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4237 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4238 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
4239 [(set GPR:$Rd, (tt_mul GPR:$Rn, GPR:$Rm))]>,
4240 Requires<[IsARM, HasV5TE]>,
4241 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4243 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4244 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
4245 [(set GPR:$Rd, (ARMsmulwb GPR:$Rn, GPR:$Rm))]>,
4246 Requires<[IsARM, HasV5TE]>,
4247 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4249 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4250 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
4251 [(set GPR:$Rd, (ARMsmulwt GPR:$Rn, GPR:$Rm))]>,
4252 Requires<[IsARM, HasV5TE]>,
4253 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4257 multiclass AI_smla<string opc> {
4258 let DecoderMethod = "DecodeSMLAInstruction" in {
4259 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
4260 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4261 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
4262 [(set GPRnopc:$Rd, (add GPR:$Ra,
4263 (bb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4264 Requires<[IsARM, HasV5TE, UseMulOps]>,
4265 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4267 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
4268 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4269 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
4270 [(set GPRnopc:$Rd, (add GPR:$Ra,
4271 (bt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4272 Requires<[IsARM, HasV5TE, UseMulOps]>,
4273 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4275 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
4276 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4277 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
4278 [(set GPRnopc:$Rd, (add GPR:$Ra,
4279 (tb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4280 Requires<[IsARM, HasV5TE, UseMulOps]>,
4281 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4283 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
4284 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4285 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
4286 [(set GPRnopc:$Rd, (add GPR:$Ra,
4287 (tt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4288 Requires<[IsARM, HasV5TE, UseMulOps]>,
4289 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4291 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
4292 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4293 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
4295 (add GPR:$Ra, (ARMsmulwb GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4296 Requires<[IsARM, HasV5TE, UseMulOps]>,
4297 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4299 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
4300 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4301 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
4303 (add GPR:$Ra, (ARMsmulwt GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4304 Requires<[IsARM, HasV5TE, UseMulOps]>,
4305 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4309 defm SMUL : AI_smul<"smul">;
4310 defm SMLA : AI_smla<"smla">;
4312 // Halfword multiply accumulate long: SMLAL<x><y>.
4313 class SMLAL<bits<2> opc1, string asm>
4314 : AMulxyI64<0b0001010, opc1,
4315 (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4316 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4317 IIC_iMAC64, asm, "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4318 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4319 Requires<[IsARM, HasV5TE]>,
4320 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4322 def SMLALBB : SMLAL<0b00, "smlalbb">;
4323 def SMLALBT : SMLAL<0b10, "smlalbt">;
4324 def SMLALTB : SMLAL<0b01, "smlaltb">;
4325 def SMLALTT : SMLAL<0b11, "smlaltt">;
4327 def : ARMV5TEPat<(ARMsmlalbb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4328 (SMLALBB $Rn, $Rm, $RLo, $RHi)>;
4329 def : ARMV5TEPat<(ARMsmlalbt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4330 (SMLALBT $Rn, $Rm, $RLo, $RHi)>;
4331 def : ARMV5TEPat<(ARMsmlaltb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4332 (SMLALTB $Rn, $Rm, $RLo, $RHi)>;
4333 def : ARMV5TEPat<(ARMsmlaltt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4334 (SMLALTT $Rn, $Rm, $RLo, $RHi)>;
4336 // Helper class for AI_smld.
4337 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
4338 InstrItinClass itin, string opc, string asm>
4339 : AI<oops, iops, MulFrm, itin, opc, asm, []>,
4340 Requires<[IsARM, HasV6]> {
4343 let Inst{27-23} = 0b01110;
4344 let Inst{22} = long;
4345 let Inst{21-20} = 0b00;
4346 let Inst{11-8} = Rm;
4353 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
4354 InstrItinClass itin, string opc, string asm>
4355 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4357 let Inst{15-12} = 0b1111;
4358 let Inst{19-16} = Rd;
4360 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
4361 InstrItinClass itin, string opc, string asm>
4362 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4365 let Inst{19-16} = Rd;
4366 let Inst{15-12} = Ra;
4368 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
4369 InstrItinClass itin, string opc, string asm>
4370 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4373 let Inst{19-16} = RdHi;
4374 let Inst{15-12} = RdLo;
4377 multiclass AI_smld<bit sub, string opc> {
4379 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
4380 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4381 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">,
4382 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4384 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
4385 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4386 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">,
4387 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4389 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4390 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4392 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">,
4393 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4394 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4396 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4397 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4399 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">,
4400 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4401 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4404 defm SMLA : AI_smld<0, "smla">;
4405 defm SMLS : AI_smld<1, "smls">;
4407 def : ARMV6Pat<(int_arm_smlad GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4408 (SMLAD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4409 def : ARMV6Pat<(int_arm_smladx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4410 (SMLADX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4411 def : ARMV6Pat<(int_arm_smlsd GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4412 (SMLSD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4413 def : ARMV6Pat<(int_arm_smlsdx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4414 (SMLSDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4415 def : ARMV6Pat<(ARMSmlald GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4416 (SMLALD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4417 def : ARMV6Pat<(ARMSmlaldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4418 (SMLALDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4419 def : ARMV6Pat<(ARMSmlsld GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4420 (SMLSLD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4421 def : ARMV6Pat<(ARMSmlsldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4422 (SMLSLDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4424 multiclass AI_sdml<bit sub, string opc> {
4426 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
4427 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">,
4428 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4429 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
4430 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">,
4431 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4434 defm SMUA : AI_sdml<0, "smua">;
4435 defm SMUS : AI_sdml<1, "smus">;
4437 def : ARMV6Pat<(int_arm_smuad GPRnopc:$Rn, GPRnopc:$Rm),
4438 (SMUAD GPRnopc:$Rn, GPRnopc:$Rm)>;
4439 def : ARMV6Pat<(int_arm_smuadx GPRnopc:$Rn, GPRnopc:$Rm),
4440 (SMUADX GPRnopc:$Rn, GPRnopc:$Rm)>;
4441 def : ARMV6Pat<(int_arm_smusd GPRnopc:$Rn, GPRnopc:$Rm),
4442 (SMUSD GPRnopc:$Rn, GPRnopc:$Rm)>;
4443 def : ARMV6Pat<(int_arm_smusdx GPRnopc:$Rn, GPRnopc:$Rm),
4444 (SMUSDX GPRnopc:$Rn, GPRnopc:$Rm)>;
4446 //===----------------------------------------------------------------------===//
4447 // Division Instructions (ARMv7-A with virtualization extension)
4449 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4450 "sdiv", "\t$Rd, $Rn, $Rm",
4451 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
4452 Requires<[IsARM, HasDivideInARM]>,
4455 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4456 "udiv", "\t$Rd, $Rn, $Rm",
4457 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
4458 Requires<[IsARM, HasDivideInARM]>,
4461 //===----------------------------------------------------------------------===//
4462 // Misc. Arithmetic Instructions.
4465 def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
4466 IIC_iUNAr, "clz", "\t$Rd, $Rm",
4467 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>,
4470 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4471 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
4472 [(set GPR:$Rd, (bitreverse GPR:$Rm))]>,
4473 Requires<[IsARM, HasV6T2]>,
4476 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4477 IIC_iUNAr, "rev", "\t$Rd, $Rm",
4478 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>,
4481 let AddedComplexity = 5 in
4482 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4483 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
4484 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
4485 Requires<[IsARM, HasV6]>,
4488 def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)),
4489 (REV16 (LDRH addrmode3:$addr))>;
4490 def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr),
4491 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>;
4493 let AddedComplexity = 5 in
4494 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4495 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
4496 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
4497 Requires<[IsARM, HasV6]>,
4500 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
4501 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
4504 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
4505 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
4506 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
4507 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
4508 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
4510 Requires<[IsARM, HasV6]>,
4511 Sched<[WriteALUsi, ReadALU]>;
4513 // Alternate cases for PKHBT where identities eliminate some nodes.
4514 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
4515 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
4516 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
4517 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
4519 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
4520 // will match the pattern below.
4521 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
4522 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
4523 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
4524 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
4525 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
4527 Requires<[IsARM, HasV6]>,
4528 Sched<[WriteALUsi, ReadALU]>;
4530 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
4531 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
4532 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
4533 // pkhtb src1, src2, asr (17..31).
4534 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4535 (srl GPRnopc:$src2, imm16:$sh)),
4536 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>;
4537 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4538 (sra GPRnopc:$src2, imm16_31:$sh)),
4539 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
4540 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4541 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
4542 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
4544 //===----------------------------------------------------------------------===//
4548 // + CRC32{B,H,W} 0x04C11DB7
4549 // + CRC32C{B,H,W} 0x1EDC6F41
4552 class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
4553 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary,
4554 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm",
4555 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>,
4556 Requires<[IsARM, HasV8, HasCRC]> {
4561 let Inst{31-28} = 0b1110;
4562 let Inst{27-23} = 0b00010;
4563 let Inst{22-21} = sz;
4565 let Inst{19-16} = Rn;
4566 let Inst{15-12} = Rd;
4567 let Inst{11-10} = 0b00;
4570 let Inst{7-4} = 0b0100;
4573 let Unpredictable{11-8} = 0b1101;
4576 def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>;
4577 def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>;
4578 def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>;
4579 def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>;
4580 def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>;
4581 def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>;
4583 //===----------------------------------------------------------------------===//
4584 // ARMv8.1a Privilege Access Never extension
4588 def SETPAN : AInoP<(outs), (ins imm0_1:$imm), MiscFrm, NoItinerary, "setpan",
4589 "\t$imm", []>, Requires<[IsARM, HasV8, HasV8_1a]> {
4592 let Inst{31-28} = 0b1111;
4593 let Inst{27-20} = 0b00010001;
4594 let Inst{19-16} = 0b0000;
4595 let Inst{15-10} = 0b000000;
4598 let Inst{7-4} = 0b0000;
4599 let Inst{3-0} = 0b0000;
4601 let Unpredictable{19-16} = 0b1111;
4602 let Unpredictable{15-10} = 0b111111;
4603 let Unpredictable{8} = 0b1;
4604 let Unpredictable{3-0} = 0b1111;
4607 //===----------------------------------------------------------------------===//
4608 // Comparison Instructions...
4611 defm CMP : AI1_cmp_irs<0b1010, "cmp",
4612 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, ARMcmp>;
4614 // ARMcmpZ can re-use the above instruction definitions.
4615 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm:$imm),
4616 (CMPri GPR:$src, mod_imm:$imm)>;
4617 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
4618 (CMPrr GPR:$src, GPR:$rhs)>;
4619 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
4620 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
4621 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
4622 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
4624 // CMN register-integer
4625 let isCompare = 1, Defs = [CPSR] in {
4626 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi,
4627 "cmn", "\t$Rn, $imm",
4628 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>,
4629 Sched<[WriteCMP, ReadALU]> {
4634 let Inst{19-16} = Rn;
4635 let Inst{15-12} = 0b0000;
4636 let Inst{11-0} = imm;
4638 let Unpredictable{15-12} = 0b1111;
4641 // CMN register-register/shift
4642 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
4643 "cmn", "\t$Rn, $Rm",
4644 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4645 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> {
4648 let isCommutable = 1;
4651 let Inst{19-16} = Rn;
4652 let Inst{15-12} = 0b0000;
4653 let Inst{11-4} = 0b00000000;
4656 let Unpredictable{15-12} = 0b1111;
4659 def CMNzrsi : AI1<0b1011, (outs),
4660 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
4661 "cmn", "\t$Rn, $shift",
4662 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4663 GPR:$Rn, so_reg_imm:$shift)]>,
4664 Sched<[WriteCMPsi, ReadALU]> {
4669 let Inst{19-16} = Rn;
4670 let Inst{15-12} = 0b0000;
4671 let Inst{11-5} = shift{11-5};
4673 let Inst{3-0} = shift{3-0};
4675 let Unpredictable{15-12} = 0b1111;
4678 def CMNzrsr : AI1<0b1011, (outs),
4679 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
4680 "cmn", "\t$Rn, $shift",
4681 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4682 GPRnopc:$Rn, so_reg_reg:$shift)]>,
4683 Sched<[WriteCMPsr, ReadALU]> {
4688 let Inst{19-16} = Rn;
4689 let Inst{15-12} = 0b0000;
4690 let Inst{11-8} = shift{11-8};
4692 let Inst{6-5} = shift{6-5};
4694 let Inst{3-0} = shift{3-0};
4696 let Unpredictable{15-12} = 0b1111;
4701 def : ARMPat<(ARMcmp GPR:$src, mod_imm_neg:$imm),
4702 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4704 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm_neg:$imm),
4705 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4707 // Note that TST/TEQ don't set all the same flags that CMP does!
4708 defm TST : AI1_cmp_irs<0b1000, "tst",
4709 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4710 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1,
4711 "DecodeTSTInstruction">;
4712 defm TEQ : AI1_cmp_irs<0b1001, "teq",
4713 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4714 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
4716 // Pseudo i64 compares for some floating point compares.
4717 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4719 def BCCi64 : PseudoInst<(outs),
4720 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4722 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>,
4725 def BCCZi64 : PseudoInst<(outs),
4726 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4727 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>,
4729 } // usesCustomInserter
4732 // Conditional moves
4733 let hasSideEffects = 0 in {
4735 let isCommutable = 1, isSelect = 1 in
4736 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd),
4737 (ins GPR:$false, GPR:$Rm, cmovpred:$p),
4739 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm,
4741 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4743 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4744 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p),
4747 (ARMcmov GPR:$false, so_reg_imm:$shift,
4749 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4750 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4751 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p),
4753 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4755 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4758 let isMoveImm = 1 in
4760 : ARMPseudoInst<(outs GPR:$Rd),
4761 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p),
4763 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm,
4765 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
4768 let isMoveImm = 1 in
4769 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4770 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4772 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm:$imm,
4774 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4776 // Two instruction predicate mov immediate.
4777 let isMoveImm = 1 in
4779 : ARMPseudoInst<(outs GPR:$Rd),
4780 (ins GPR:$false, i32imm:$src, cmovpred:$p),
4782 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src,
4784 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4786 let isMoveImm = 1 in
4787 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4788 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4790 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm_not:$imm,
4792 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4797 //===----------------------------------------------------------------------===//
4798 // Atomic operations intrinsics
4801 def MemBarrierOptOperand : AsmOperandClass {
4802 let Name = "MemBarrierOpt";
4803 let ParserMethod = "parseMemBarrierOptOperand";
4805 def memb_opt : Operand<i32> {
4806 let PrintMethod = "printMemBOption";
4807 let ParserMatchClass = MemBarrierOptOperand;
4808 let DecoderMethod = "DecodeMemBarrierOption";
4811 def InstSyncBarrierOptOperand : AsmOperandClass {
4812 let Name = "InstSyncBarrierOpt";
4813 let ParserMethod = "parseInstSyncBarrierOptOperand";
4815 def instsyncb_opt : Operand<i32> {
4816 let PrintMethod = "printInstSyncBOption";
4817 let ParserMatchClass = InstSyncBarrierOptOperand;
4818 let DecoderMethod = "DecodeInstSyncBarrierOption";
4821 def TraceSyncBarrierOptOperand : AsmOperandClass {
4822 let Name = "TraceSyncBarrierOpt";
4823 let ParserMethod = "parseTraceSyncBarrierOptOperand";
4825 def tsb_opt : Operand<i32> {
4826 let PrintMethod = "printTraceSyncBOption";
4827 let ParserMatchClass = TraceSyncBarrierOptOperand;
4830 // Memory barriers protect the atomic sequences
4831 let hasSideEffects = 1 in {
4832 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4833 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
4834 Requires<[IsARM, HasDB]> {
4836 let Inst{31-4} = 0xf57ff05;
4837 let Inst{3-0} = opt;
4840 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4841 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
4842 Requires<[IsARM, HasDB]> {
4844 let Inst{31-4} = 0xf57ff04;
4845 let Inst{3-0} = opt;
4848 // ISB has only full system option
4849 def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary,
4850 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
4851 Requires<[IsARM, HasDB]> {
4853 let Inst{31-4} = 0xf57ff06;
4854 let Inst{3-0} = opt;
4857 let hasNoSchedulingInfo = 1 in
4858 def TSB : AInoP<(outs), (ins tsb_opt:$opt), MiscFrm, NoItinerary,
4859 "tsb", "\t$opt", []>, Requires<[IsARM, HasV8_4a]> {
4860 let Inst{31-0} = 0xe320f012;
4865 // Armv8.5-A speculation barrier
4866 def SB : AInoP<(outs), (ins), MiscFrm, NoItinerary, "sb", "", []>,
4867 Requires<[IsARM, HasSB]>, Sched<[]> {
4868 let Inst{31-0} = 0xf57ff070;
4869 let Unpredictable = 0x000fff0f;
4870 let hasSideEffects = 1;
4873 let usesCustomInserter = 1, Defs = [CPSR] in {
4875 // Pseudo instruction that combines movs + predicated rsbmi
4876 // to implement integer ABS
4877 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4880 let usesCustomInserter = 1, Defs = [CPSR] in {
4881 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4882 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4884 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4887 let hasPostISelHook = 1, Constraints = "$newdst = $dst, $newsrc = $src" in {
4888 // %newsrc, %newdst = MEMCPY %dst, %src, N, ...N scratch regs...
4889 // Copies N registers worth of memory from address %src to address %dst
4890 // and returns the incremented addresses. N scratch register will
4891 // be attached for the copy to use.
4892 def MEMCPY : PseudoInst<
4893 (outs GPR:$newdst, GPR:$newsrc),
4894 (ins GPR:$dst, GPR:$src, i32imm:$nreg, variable_ops),
4896 [(set GPR:$newdst, GPR:$newsrc,
4897 (ARMmemcopy GPR:$dst, GPR:$src, imm:$nreg))]>;
4900 def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4901 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4904 def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4905 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4908 def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4909 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4912 def strex_1 : PatFrag<(ops node:$val, node:$ptr),
4913 (int_arm_strex node:$val, node:$ptr), [{
4914 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4917 def strex_2 : PatFrag<(ops node:$val, node:$ptr),
4918 (int_arm_strex node:$val, node:$ptr), [{
4919 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4922 def strex_4 : PatFrag<(ops node:$val, node:$ptr),
4923 (int_arm_strex node:$val, node:$ptr), [{
4924 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4927 def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4928 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4931 def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4932 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4935 def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4936 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4939 def stlex_1 : PatFrag<(ops node:$val, node:$ptr),
4940 (int_arm_stlex node:$val, node:$ptr), [{
4941 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4944 def stlex_2 : PatFrag<(ops node:$val, node:$ptr),
4945 (int_arm_stlex node:$val, node:$ptr), [{
4946 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4949 def stlex_4 : PatFrag<(ops node:$val, node:$ptr),
4950 (int_arm_stlex node:$val, node:$ptr), [{
4951 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4954 let mayLoad = 1 in {
4955 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4956 NoItinerary, "ldrexb", "\t$Rt, $addr",
4957 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>;
4958 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4959 NoItinerary, "ldrexh", "\t$Rt, $addr",
4960 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>;
4961 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4962 NoItinerary, "ldrex", "\t$Rt, $addr",
4963 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>;
4964 let hasExtraDefRegAllocReq = 1 in
4965 def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4966 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
4967 let DecoderMethod = "DecodeDoubleRegLoad";
4970 def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4971 NoItinerary, "ldaexb", "\t$Rt, $addr",
4972 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>;
4973 def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4974 NoItinerary, "ldaexh", "\t$Rt, $addr",
4975 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>;
4976 def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4977 NoItinerary, "ldaex", "\t$Rt, $addr",
4978 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>;
4979 let hasExtraDefRegAllocReq = 1 in
4980 def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4981 NoItinerary, "ldaexd", "\t$Rt, $addr", []> {
4982 let DecoderMethod = "DecodeDoubleRegLoad";
4986 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4987 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4988 NoItinerary, "strexb", "\t$Rd, $Rt, $addr",
4989 [(set GPR:$Rd, (strex_1 GPR:$Rt,
4990 addr_offset_none:$addr))]>;
4991 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4992 NoItinerary, "strexh", "\t$Rd, $Rt, $addr",
4993 [(set GPR:$Rd, (strex_2 GPR:$Rt,
4994 addr_offset_none:$addr))]>;
4995 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4996 NoItinerary, "strex", "\t$Rd, $Rt, $addr",
4997 [(set GPR:$Rd, (strex_4 GPR:$Rt,
4998 addr_offset_none:$addr))]>;
4999 let hasExtraSrcRegAllocReq = 1 in
5000 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
5001 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
5002 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
5003 let DecoderMethod = "DecodeDoubleRegStore";
5005 def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5006 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr",
5008 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>;
5009 def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5010 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr",
5012 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>;
5013 def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5014 NoItinerary, "stlex", "\t$Rd, $Rt, $addr",
5016 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>;
5017 let hasExtraSrcRegAllocReq = 1 in
5018 def STLEXD : AIstlex<0b01, (outs GPR:$Rd),
5019 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
5020 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> {
5021 let DecoderMethod = "DecodeDoubleRegStore";
5025 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
5027 Requires<[IsARM, HasV6K]> {
5028 let Inst{31-0} = 0b11110101011111111111000000011111;
5031 def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
5032 (STREXB GPR:$Rt, addr_offset_none:$addr)>;
5033 def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
5034 (STREXH GPR:$Rt, addr_offset_none:$addr)>;
5036 def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
5037 (STLEXB GPR:$Rt, addr_offset_none:$addr)>;
5038 def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
5039 (STLEXH GPR:$Rt, addr_offset_none:$addr)>;
5041 class acquiring_load<PatFrag base>
5042 : PatFrag<(ops node:$ptr), (base node:$ptr), [{
5043 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
5044 return isAcquireOrStronger(Ordering);
5047 def atomic_load_acquire_8 : acquiring_load<atomic_load_8>;
5048 def atomic_load_acquire_16 : acquiring_load<atomic_load_16>;
5049 def atomic_load_acquire_32 : acquiring_load<atomic_load_32>;
5051 class releasing_store<PatFrag base>
5052 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{
5053 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
5054 return isReleaseOrStronger(Ordering);
5057 def atomic_store_release_8 : releasing_store<atomic_store_8>;
5058 def atomic_store_release_16 : releasing_store<atomic_store_16>;
5059 def atomic_store_release_32 : releasing_store<atomic_store_32>;
5061 let AddedComplexity = 8 in {
5062 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>;
5063 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>;
5064 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>;
5065 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>;
5066 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>;
5067 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>;
5070 // SWP/SWPB are deprecated in V6/V7 and optional in v7VE.
5071 // FIXME Use InstAlias to generate LDREX/STREX pairs instead.
5072 let mayLoad = 1, mayStore = 1 in {
5073 def SWP : AIswp<0, (outs GPRnopc:$Rt),
5074 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>,
5075 Requires<[IsARM,PreV8]>;
5076 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
5077 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>,
5078 Requires<[IsARM,PreV8]>;
5081 //===----------------------------------------------------------------------===//
5082 // Coprocessor Instructions.
5085 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5086 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
5087 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
5088 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
5089 imm:$CRm, imm:$opc2)]>,
5090 Requires<[IsARM,PreV8]> {
5098 let Inst{3-0} = CRm;
5100 let Inst{7-5} = opc2;
5101 let Inst{11-8} = cop;
5102 let Inst{15-12} = CRd;
5103 let Inst{19-16} = CRn;
5104 let Inst{23-20} = opc1;
5106 let DecoderNamespace = "CoProc";
5109 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5110 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
5111 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
5112 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
5113 imm:$CRm, imm:$opc2)]>,
5114 Requires<[IsARM,PreV8]> {
5115 let Inst{31-28} = 0b1111;
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 class ACI<dag oops, dag iops, string opc, string asm,
5135 list<dag> pattern, IndexMode im = IndexModeNone>
5136 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
5137 opc, asm, "", pattern> {
5138 let Inst{27-25} = 0b110;
5140 class ACInoP<dag oops, dag iops, string opc, string asm,
5141 list<dag> pattern, IndexMode im = IndexModeNone>
5142 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
5143 opc, asm, "", pattern> {
5144 let Inst{31-28} = 0b1111;
5145 let Inst{27-25} = 0b110;
5148 let DecoderNamespace = "CoProc" in {
5149 multiclass LdStCop<bit load, bit Dbit, string asm, list<dag> pattern> {
5150 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
5151 asm, "\t$cop, $CRd, $addr", pattern> {
5155 let Inst{24} = 1; // P = 1
5156 let Inst{23} = addr{8};
5157 let Inst{22} = Dbit;
5158 let Inst{21} = 0; // W = 0
5159 let Inst{20} = load;
5160 let Inst{19-16} = addr{12-9};
5161 let Inst{15-12} = CRd;
5162 let Inst{11-8} = cop;
5163 let Inst{7-0} = addr{7-0};
5164 let DecoderMethod = "DecodeCopMemInstruction";
5166 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
5167 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> {
5171 let Inst{24} = 1; // P = 1
5172 let Inst{23} = addr{8};
5173 let Inst{22} = Dbit;
5174 let Inst{21} = 1; // W = 1
5175 let Inst{20} = load;
5176 let Inst{19-16} = addr{12-9};
5177 let Inst{15-12} = CRd;
5178 let Inst{11-8} = cop;
5179 let Inst{7-0} = addr{7-0};
5180 let DecoderMethod = "DecodeCopMemInstruction";
5182 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5183 postidx_imm8s4:$offset),
5184 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> {
5189 let Inst{24} = 0; // P = 0
5190 let Inst{23} = offset{8};
5191 let Inst{22} = Dbit;
5192 let Inst{21} = 1; // W = 1
5193 let Inst{20} = load;
5194 let Inst{19-16} = addr;
5195 let Inst{15-12} = CRd;
5196 let Inst{11-8} = cop;
5197 let Inst{7-0} = offset{7-0};
5198 let DecoderMethod = "DecodeCopMemInstruction";
5200 def _OPTION : ACI<(outs),
5201 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5202 coproc_option_imm:$option),
5203 asm, "\t$cop, $CRd, $addr, $option", []> {
5208 let Inst{24} = 0; // P = 0
5209 let Inst{23} = 1; // U = 1
5210 let Inst{22} = Dbit;
5211 let Inst{21} = 0; // W = 0
5212 let Inst{20} = load;
5213 let Inst{19-16} = addr;
5214 let Inst{15-12} = CRd;
5215 let Inst{11-8} = cop;
5216 let Inst{7-0} = option;
5217 let DecoderMethod = "DecodeCopMemInstruction";
5220 multiclass LdSt2Cop<bit load, bit Dbit, string asm, list<dag> pattern> {
5221 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
5222 asm, "\t$cop, $CRd, $addr", pattern> {
5226 let Inst{24} = 1; // P = 1
5227 let Inst{23} = addr{8};
5228 let Inst{22} = Dbit;
5229 let Inst{21} = 0; // W = 0
5230 let Inst{20} = load;
5231 let Inst{19-16} = addr{12-9};
5232 let Inst{15-12} = CRd;
5233 let Inst{11-8} = cop;
5234 let Inst{7-0} = addr{7-0};
5235 let DecoderMethod = "DecodeCopMemInstruction";
5237 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
5238 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> {
5242 let Inst{24} = 1; // P = 1
5243 let Inst{23} = addr{8};
5244 let Inst{22} = Dbit;
5245 let Inst{21} = 1; // W = 1
5246 let Inst{20} = load;
5247 let Inst{19-16} = addr{12-9};
5248 let Inst{15-12} = CRd;
5249 let Inst{11-8} = cop;
5250 let Inst{7-0} = addr{7-0};
5251 let DecoderMethod = "DecodeCopMemInstruction";
5253 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5254 postidx_imm8s4:$offset),
5255 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> {
5260 let Inst{24} = 0; // P = 0
5261 let Inst{23} = offset{8};
5262 let Inst{22} = Dbit;
5263 let Inst{21} = 1; // W = 1
5264 let Inst{20} = load;
5265 let Inst{19-16} = addr;
5266 let Inst{15-12} = CRd;
5267 let Inst{11-8} = cop;
5268 let Inst{7-0} = offset{7-0};
5269 let DecoderMethod = "DecodeCopMemInstruction";
5271 def _OPTION : ACInoP<(outs),
5272 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5273 coproc_option_imm:$option),
5274 asm, "\t$cop, $CRd, $addr, $option", []> {
5279 let Inst{24} = 0; // P = 0
5280 let Inst{23} = 1; // U = 1
5281 let Inst{22} = Dbit;
5282 let Inst{21} = 0; // W = 0
5283 let Inst{20} = load;
5284 let Inst{19-16} = addr;
5285 let Inst{15-12} = CRd;
5286 let Inst{11-8} = cop;
5287 let Inst{7-0} = option;
5288 let DecoderMethod = "DecodeCopMemInstruction";
5292 defm LDC : LdStCop <1, 0, "ldc", [(int_arm_ldc imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5293 defm LDCL : LdStCop <1, 1, "ldcl", [(int_arm_ldcl imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5294 defm LDC2 : LdSt2Cop<1, 0, "ldc2", [(int_arm_ldc2 imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5295 defm LDC2L : LdSt2Cop<1, 1, "ldc2l", [(int_arm_ldc2l imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5297 defm STC : LdStCop <0, 0, "stc", [(int_arm_stc imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5298 defm STCL : LdStCop <0, 1, "stcl", [(int_arm_stcl imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5299 defm STC2 : LdSt2Cop<0, 0, "stc2", [(int_arm_stc2 imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5300 defm STC2L : LdSt2Cop<0, 1, "stc2l", [(int_arm_stc2l imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5302 } // DecoderNamespace = "CoProc"
5304 //===----------------------------------------------------------------------===//
5305 // Move between coprocessor and ARM core register.
5308 class MovRCopro<string opc, bit direction, dag oops, dag iops,
5310 : ABI<0b1110, oops, iops, NoItinerary, opc,
5311 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
5312 let Inst{20} = direction;
5322 let Inst{15-12} = Rt;
5323 let Inst{11-8} = cop;
5324 let Inst{23-21} = opc1;
5325 let Inst{7-5} = opc2;
5326 let Inst{3-0} = CRm;
5327 let Inst{19-16} = CRn;
5329 let DecoderNamespace = "CoProc";
5332 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
5334 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5335 c_imm:$CRm, imm0_7:$opc2),
5336 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5337 imm:$CRm, imm:$opc2)]>,
5338 ComplexDeprecationPredicate<"MCR">;
5339 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
5340 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5341 c_imm:$CRm, 0, pred:$p)>;
5342 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
5343 (outs GPRwithAPSR:$Rt),
5344 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5346 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
5347 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5348 c_imm:$CRm, 0, pred:$p)>;
5350 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
5351 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5353 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
5355 : ABXI<0b1110, oops, iops, NoItinerary,
5356 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
5357 let Inst{31-24} = 0b11111110;
5358 let Inst{20} = direction;
5368 let Inst{15-12} = Rt;
5369 let Inst{11-8} = cop;
5370 let Inst{23-21} = opc1;
5371 let Inst{7-5} = opc2;
5372 let Inst{3-0} = CRm;
5373 let Inst{19-16} = CRn;
5375 let DecoderNamespace = "CoProc";
5378 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
5380 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5381 c_imm:$CRm, imm0_7:$opc2),
5382 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5383 imm:$CRm, imm:$opc2)]>,
5384 Requires<[IsARM,PreV8]>;
5385 def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
5386 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5388 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
5389 (outs GPRwithAPSR:$Rt),
5390 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5392 Requires<[IsARM,PreV8]>;
5393 def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
5394 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5397 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
5398 imm:$CRm, imm:$opc2),
5399 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5401 class MovRRCopro<string opc, bit direction, dag oops, dag iops, list<dag>
5403 : ABI<0b1100, oops, iops, NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm",
5406 let Inst{23-21} = 0b010;
5407 let Inst{20} = direction;
5415 let Inst{15-12} = Rt;
5416 let Inst{19-16} = Rt2;
5417 let Inst{11-8} = cop;
5418 let Inst{7-4} = opc1;
5419 let Inst{3-0} = CRm;
5422 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
5423 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt,
5424 GPRnopc:$Rt2, c_imm:$CRm),
5425 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
5426 GPRnopc:$Rt2, imm:$CRm)]>;
5427 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */,
5428 (outs GPRnopc:$Rt, GPRnopc:$Rt2),
5429 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>;
5431 class MovRRCopro2<string opc, bit direction, dag oops, dag iops,
5432 list<dag> pattern = []>
5433 : ABXI<0b1100, oops, iops, NoItinerary,
5434 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>,
5435 Requires<[IsARM,PreV8]> {
5436 let Inst{31-28} = 0b1111;
5437 let Inst{23-21} = 0b010;
5438 let Inst{20} = direction;
5446 let Inst{15-12} = Rt;
5447 let Inst{19-16} = Rt2;
5448 let Inst{11-8} = cop;
5449 let Inst{7-4} = opc1;
5450 let Inst{3-0} = CRm;
5452 let DecoderMethod = "DecoderForMRRC2AndMCRR2";
5455 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
5456 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt,
5457 GPRnopc:$Rt2, c_imm:$CRm),
5458 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
5459 GPRnopc:$Rt2, imm:$CRm)]>;
5461 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */,
5462 (outs GPRnopc:$Rt, GPRnopc:$Rt2),
5463 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>;
5465 //===----------------------------------------------------------------------===//
5466 // Move between special register and ARM core register
5469 // Move to ARM core register from Special Register
5470 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5471 "mrs", "\t$Rd, apsr", []> {
5473 let Inst{23-16} = 0b00001111;
5474 let Unpredictable{19-17} = 0b111;
5476 let Inst{15-12} = Rd;
5478 let Inst{11-0} = 0b000000000000;
5479 let Unpredictable{11-0} = 0b110100001111;
5482 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p), 0>,
5485 // The MRSsys instruction is the MRS instruction from the ARM ARM,
5486 // section B9.3.9, with the R bit set to 1.
5487 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5488 "mrs", "\t$Rd, spsr", []> {
5490 let Inst{23-16} = 0b01001111;
5491 let Unpredictable{19-16} = 0b1111;
5493 let Inst{15-12} = Rd;
5495 let Inst{11-0} = 0b000000000000;
5496 let Unpredictable{11-0} = 0b110100001111;
5499 // However, the MRS (banked register) system instruction (ARMv7VE) *does* have a
5500 // separate encoding (distinguished by bit 5.
5501 def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked),
5502 NoItinerary, "mrs", "\t$Rd, $banked", []>,
5503 Requires<[IsARM, HasVirtualization]> {
5508 let Inst{22} = banked{5}; // R bit
5509 let Inst{21-20} = 0b00;
5510 let Inst{19-16} = banked{3-0};
5511 let Inst{15-12} = Rd;
5512 let Inst{11-9} = 0b001;
5513 let Inst{8} = banked{4};
5514 let Inst{7-0} = 0b00000000;
5517 // Move from ARM core register to Special Register
5519 // No need to have both system and application versions of MSR (immediate) or
5520 // MSR (register), the encodings are the same and the assembly parser has no way
5521 // to distinguish between them. The mask operand contains the special register
5522 // (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be
5523 // accessed in the special register.
5524 let Defs = [CPSR] in
5525 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
5526 "msr", "\t$mask, $Rn", []> {
5531 let Inst{22} = mask{4}; // R bit
5532 let Inst{21-20} = 0b10;
5533 let Inst{19-16} = mask{3-0};
5534 let Inst{15-12} = 0b1111;
5535 let Inst{11-4} = 0b00000000;
5539 let Defs = [CPSR] in
5540 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary,
5541 "msr", "\t$mask, $imm", []> {
5546 let Inst{22} = mask{4}; // R bit
5547 let Inst{21-20} = 0b10;
5548 let Inst{19-16} = mask{3-0};
5549 let Inst{15-12} = 0b1111;
5550 let Inst{11-0} = imm;
5553 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
5554 // separate encoding (distinguished by bit 5.
5555 def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn),
5556 NoItinerary, "msr", "\t$banked, $Rn", []>,
5557 Requires<[IsARM, HasVirtualization]> {
5562 let Inst{22} = banked{5}; // R bit
5563 let Inst{21-20} = 0b10;
5564 let Inst{19-16} = banked{3-0};
5565 let Inst{15-12} = 0b1111;
5566 let Inst{11-9} = 0b001;
5567 let Inst{8} = banked{4};
5568 let Inst{7-4} = 0b0000;
5572 // Dynamic stack allocation yields a _chkstk for Windows targets. These calls
5573 // are needed to probe the stack when allocating more than
5574 // 4k bytes in one go. Touching the stack at 4K increments is necessary to
5575 // ensure that the guard pages used by the OS virtual memory manager are
5576 // allocated in correct sequence.
5577 // The main point of having separate instruction are extra unmodelled effects
5578 // (compared to ordinary calls) like stack pointer change.
5580 def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone,
5581 [SDNPHasChain, SDNPSideEffect]>;
5582 let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP] in
5583 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>;
5585 def win__dbzchk : SDNode<"ARMISD::WIN__DBZCHK", SDT_WIN__DBZCHK,
5586 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
5587 let usesCustomInserter = 1, Defs = [CPSR] in
5588 def WIN__DBZCHK : PseudoInst<(outs), (ins tGPR:$divisor), NoItinerary,
5589 [(win__dbzchk tGPR:$divisor)]>;
5591 //===----------------------------------------------------------------------===//
5595 // __aeabi_read_tp preserves the registers r1-r3.
5596 // This is a pseudo inst so that we can get the encoding right,
5597 // complete with fixup for the aeabi_read_tp function.
5598 // TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern
5599 // is defined in "ARMInstrThumb.td".
5601 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
5602 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br,
5603 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>,
5604 Requires<[IsARM, IsReadTPSoft]>;
5607 // Reading thread pointer from coprocessor register
5608 def : ARMPat<(ARMthread_pointer), (MRC 15, 0, 13, 0, 3)>,
5609 Requires<[IsARM, IsReadTPHard]>;
5611 //===----------------------------------------------------------------------===//
5612 // SJLJ Exception handling intrinsics
5613 // eh_sjlj_setjmp() is an instruction sequence to store the return
5614 // address and save #0 in R0 for the non-longjmp case.
5615 // Since by its nature we may be coming from some other function to get
5616 // here, and we're using the stack frame for the containing function to
5617 // save/restore registers, we can't keep anything live in regs across
5618 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
5619 // when we get here from a longjmp(). We force everything out of registers
5620 // except for our own input by listing the relevant registers in Defs. By
5621 // doing so, we also cause the prologue/epilogue code to actively preserve
5622 // all of the callee-saved resgisters, which is exactly what we want.
5623 // A constant value is passed in $val, and we use the location as a scratch.
5625 // These are pseudo-instructions and are lowered to individual MC-insts, so
5626 // no encoding information is necessary.
5628 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
5629 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
5630 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5631 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5633 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5634 Requires<[IsARM, HasVFP2]>;
5638 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
5639 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5640 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5642 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5643 Requires<[IsARM, NoVFP]>;
5646 // FIXME: Non-IOS version(s)
5647 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
5648 Defs = [ R7, LR, SP ] in {
5649 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
5651 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
5655 let isBarrier = 1, hasSideEffects = 1, usesCustomInserter = 1 in
5656 def Int_eh_sjlj_setup_dispatch : PseudoInst<(outs), (ins), NoItinerary,
5657 [(ARMeh_sjlj_setup_dispatch)]>;
5659 // eh.sjlj.dispatchsetup pseudo-instruction.
5660 // This pseudo is used for both ARM and Thumb. Any differences are handled when
5661 // the pseudo is expanded (which happens before any passes that need the
5662 // instruction size).
5663 let isBarrier = 1 in
5664 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
5667 //===----------------------------------------------------------------------===//
5668 // Non-Instruction Patterns
5671 // ARMv4 indirect branch using (MOVr PC, dst)
5672 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
5673 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
5674 4, IIC_Br, [(brind GPR:$dst)],
5675 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5676 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5678 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in
5679 def TAILJMPr4 : ARMPseudoExpand<(outs), (ins GPR:$dst),
5681 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5682 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5684 // Large immediate handling.
5686 // 32-bit immediate using two piece mod_imms or movw + movt.
5687 // This is a single pseudo instruction, the benefit is that it can be remat'd
5688 // as a single unit instead of having to handle reg inputs.
5689 // FIXME: Remove this when we can do generalized remat.
5690 let isReMaterializable = 1, isMoveImm = 1 in
5691 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
5692 [(set GPR:$dst, (arm_i32imm:$src))]>,
5695 def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i,
5696 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>,
5697 Requires<[IsARM, DontUseMovt]>;
5699 // Pseudo instruction that combines movw + movt + add pc (if PIC).
5700 // It also makes it possible to rematerialize the instructions.
5701 // FIXME: Remove this when we can do generalized remat and when machine licm
5702 // can properly the instructions.
5703 let isReMaterializable = 1 in {
5704 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5706 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
5707 Requires<[IsARM, UseMovtInPic]>;
5709 def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5712 (ARMWrapperPIC tglobaladdr:$addr))]>,
5713 Requires<[IsARM, DontUseMovtInPic]>;
5715 let AddedComplexity = 10 in
5716 def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5719 (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5720 Requires<[IsARM, DontUseMovtInPic]>;
5722 let AddedComplexity = 10 in
5723 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5725 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5726 Requires<[IsARM, UseMovtInPic]>;
5727 } // isReMaterializable
5729 // The many different faces of TLS access.
5730 def : ARMPat<(ARMWrapper tglobaltlsaddr :$dst),
5731 (MOVi32imm tglobaltlsaddr :$dst)>,
5732 Requires<[IsARM, UseMovt]>;
5734 def : Pat<(ARMWrapper tglobaltlsaddr:$src),
5735 (LDRLIT_ga_abs tglobaltlsaddr:$src)>,
5736 Requires<[IsARM, DontUseMovt]>;
5738 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
5739 (MOV_ga_pcrel tglobaltlsaddr:$addr)>, Requires<[IsARM, UseMovtInPic]>;
5741 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
5742 (LDRLIT_ga_pcrel tglobaltlsaddr:$addr)>,
5743 Requires<[IsARM, DontUseMovtInPic]>;
5744 let AddedComplexity = 10 in
5745 def : Pat<(load (ARMWrapperPIC tglobaltlsaddr:$addr)),
5746 (MOV_ga_pcrel_ldr tglobaltlsaddr:$addr)>,
5747 Requires<[IsARM, UseMovtInPic]>;
5750 // ConstantPool, GlobalAddress, and JumpTable
5751 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
5752 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
5753 Requires<[IsARM, UseMovt]>;
5754 def : ARMPat<(ARMWrapper texternalsym :$dst), (MOVi32imm texternalsym :$dst)>,
5755 Requires<[IsARM, UseMovt]>;
5756 def : ARMPat<(ARMWrapperJT tjumptable:$dst),
5757 (LEApcrelJT tjumptable:$dst)>;
5759 // TODO: add,sub,and, 3-instr forms?
5761 // Tail calls. These patterns also apply to Thumb mode.
5762 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
5763 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
5764 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
5767 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
5768 def : ARMPat<(ARMcall_nolink texternalsym:$func),
5769 (BMOVPCB_CALL texternalsym:$func)>;
5771 // zextload i1 -> zextload i8
5772 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5773 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5775 // extload -> zextload
5776 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5777 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5778 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5779 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5781 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
5783 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
5784 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
5787 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
5788 (SMULBB GPR:$a, GPR:$b)>;
5789 def : ARMV5TEPat<(mul sext_16_node:$a, (sext_bottom_16 GPR:$b)),
5790 (SMULBB GPR:$a, GPR:$b)>;
5791 def : ARMV5TEPat<(mul sext_16_node:$a, (sext_top_16 GPR:$b)),
5792 (SMULBT GPR:$a, GPR:$b)>;
5793 def : ARMV5TEPat<(mul (sext_top_16 GPR:$a), sext_16_node:$b),
5794 (SMULTB GPR:$a, GPR:$b)>;
5795 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, sext_16_node:$b)),
5796 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5797 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_bottom_16 GPR:$b))),
5798 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5799 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_top_16 GPR:$b))),
5800 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5801 def : ARMV5MOPat<(add GPR:$acc, (mul (sext_top_16 GPR:$a), sext_16_node:$b)),
5802 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5804 def : ARMV5TEPat<(int_arm_smulbb GPR:$a, GPR:$b),
5805 (SMULBB GPR:$a, GPR:$b)>;
5806 def : ARMV5TEPat<(int_arm_smulbt GPR:$a, GPR:$b),
5807 (SMULBT GPR:$a, GPR:$b)>;
5808 def : ARMV5TEPat<(int_arm_smultb GPR:$a, GPR:$b),
5809 (SMULTB GPR:$a, GPR:$b)>;
5810 def : ARMV5TEPat<(int_arm_smultt GPR:$a, GPR:$b),
5811 (SMULTT GPR:$a, GPR:$b)>;
5812 def : ARMV5TEPat<(int_arm_smulwb GPR:$a, GPR:$b),
5813 (SMULWB GPR:$a, GPR:$b)>;
5814 def : ARMV5TEPat<(int_arm_smulwt GPR:$a, GPR:$b),
5815 (SMULWT GPR:$a, GPR:$b)>;
5817 def : ARMV5TEPat<(int_arm_smlabb GPR:$a, GPR:$b, GPR:$acc),
5818 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5819 def : ARMV5TEPat<(int_arm_smlabt GPR:$a, GPR:$b, GPR:$acc),
5820 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5821 def : ARMV5TEPat<(int_arm_smlatb GPR:$a, GPR:$b, GPR:$acc),
5822 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5823 def : ARMV5TEPat<(int_arm_smlatt GPR:$a, GPR:$b, GPR:$acc),
5824 (SMLATT GPR:$a, GPR:$b, GPR:$acc)>;
5825 def : ARMV5TEPat<(int_arm_smlawb GPR:$a, GPR:$b, GPR:$acc),
5826 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
5827 def : ARMV5TEPat<(int_arm_smlawt GPR:$a, GPR:$b, GPR:$acc),
5828 (SMLAWT GPR:$a, GPR:$b, GPR:$acc)>;
5830 // Pre-v7 uses MCR for synchronization barriers.
5831 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
5832 Requires<[IsARM, HasV6]>;
5834 // SXT/UXT with no rotate
5835 let AddedComplexity = 16 in {
5836 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
5837 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
5838 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
5839 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
5840 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
5841 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
5842 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
5845 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
5846 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
5848 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
5849 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
5850 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
5851 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
5853 // Atomic load/store patterns
5854 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
5855 (LDRBrs ldst_so_reg:$src)>;
5856 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
5857 (LDRBi12 addrmode_imm12:$src)>;
5858 def : ARMPat<(atomic_load_16 addrmode3:$src),
5859 (LDRH addrmode3:$src)>;
5860 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
5861 (LDRrs ldst_so_reg:$src)>;
5862 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
5863 (LDRi12 addrmode_imm12:$src)>;
5864 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
5865 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
5866 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
5867 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
5868 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
5869 (STRH GPR:$val, addrmode3:$ptr)>;
5870 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
5871 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
5872 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
5873 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
5876 //===----------------------------------------------------------------------===//
5880 include "ARMInstrThumb.td"
5882 //===----------------------------------------------------------------------===//
5886 include "ARMInstrThumb2.td"
5888 //===----------------------------------------------------------------------===//
5889 // Floating Point Support
5892 include "ARMInstrVFP.td"
5894 //===----------------------------------------------------------------------===//
5895 // Advanced SIMD (NEON) Support
5898 include "ARMInstrNEON.td"
5900 //===----------------------------------------------------------------------===//
5904 include "ARMInstrMVE.td"
5906 //===----------------------------------------------------------------------===//
5907 // Assembler aliases
5911 def : InstAlias<"dmb", (DMB 0xf), 0>, Requires<[IsARM, HasDB]>;
5912 def : InstAlias<"dsb", (DSB 0xf), 0>, Requires<[IsARM, HasDB]>;
5913 def : InstAlias<"ssbb", (DSB 0x0), 1>, Requires<[IsARM, HasDB]>;
5914 def : InstAlias<"pssbb", (DSB 0x4), 1>, Requires<[IsARM, HasDB]>;
5915 def : InstAlias<"isb", (ISB 0xf), 0>, Requires<[IsARM, HasDB]>;
5916 // Armv8-R 'Data Full Barrier'
5917 def : InstAlias<"dfb", (DSB 0xc), 1>, Requires<[IsARM, HasDFB]>;
5919 // System instructions
5920 def : MnemonicAlias<"swi", "svc">;
5922 // Load / Store Multiple
5923 def : MnemonicAlias<"ldmfd", "ldm">;
5924 def : MnemonicAlias<"ldmia", "ldm">;
5925 def : MnemonicAlias<"ldmea", "ldmdb">;
5926 def : MnemonicAlias<"stmfd", "stmdb">;
5927 def : MnemonicAlias<"stmia", "stm">;
5928 def : MnemonicAlias<"stmea", "stm">;
5930 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT with the
5931 // input operands swapped when the shift amount is zero (i.e., unspecified).
5932 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5933 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p), 0>,
5934 Requires<[IsARM, HasV6]>;
5935 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5936 (PKHBT GPRnopc:$Rd, GPRnopc:$Rm, GPRnopc:$Rn, 0, pred:$p), 0>,
5937 Requires<[IsARM, HasV6]>;
5939 // PUSH/POP aliases for STM/LDM
5940 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5941 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5943 // SSAT/USAT optional shift operand.
5944 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5945 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5946 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5947 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5950 // Extend instruction optional rotate operand.
5951 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5952 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5953 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5954 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5955 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5956 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5957 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5958 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5959 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5960 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5961 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5962 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5964 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5965 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5966 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5967 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5968 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5969 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5970 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5971 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5972 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5973 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5974 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
5975 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5979 def : MnemonicAlias<"rfefa", "rfeda">;
5980 def : MnemonicAlias<"rfeea", "rfedb">;
5981 def : MnemonicAlias<"rfefd", "rfeia">;
5982 def : MnemonicAlias<"rfeed", "rfeib">;
5983 def : MnemonicAlias<"rfe", "rfeia">;
5986 def : MnemonicAlias<"srsfa", "srsib">;
5987 def : MnemonicAlias<"srsea", "srsia">;
5988 def : MnemonicAlias<"srsfd", "srsdb">;
5989 def : MnemonicAlias<"srsed", "srsda">;
5990 def : MnemonicAlias<"srs", "srsia">;
5993 def : MnemonicAlias<"qsubaddx", "qsax">;
5995 def : MnemonicAlias<"saddsubx", "sasx">;
5996 // SHASX == SHADDSUBX
5997 def : MnemonicAlias<"shaddsubx", "shasx">;
5998 // SHSAX == SHSUBADDX
5999 def : MnemonicAlias<"shsubaddx", "shsax">;
6001 def : MnemonicAlias<"ssubaddx", "ssax">;
6003 def : MnemonicAlias<"uaddsubx", "uasx">;
6004 // UHASX == UHADDSUBX
6005 def : MnemonicAlias<"uhaddsubx", "uhasx">;
6006 // UHSAX == UHSUBADDX
6007 def : MnemonicAlias<"uhsubaddx", "uhsax">;
6008 // UQASX == UQADDSUBX
6009 def : MnemonicAlias<"uqaddsubx", "uqasx">;
6010 // UQSAX == UQSUBADDX
6011 def : MnemonicAlias<"uqsubaddx", "uqsax">;
6013 def : MnemonicAlias<"usubaddx", "usax">;
6015 // "mov Rd, mod_imm_not" can be handled via "mvn" in assembly, just like
6017 def : ARMInstSubst<"mov${s}${p} $Rd, $imm",
6018 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6019 def : ARMInstSubst<"mvn${s}${p} $Rd, $imm",
6020 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6021 // Same for AND <--> BIC
6022 def : ARMInstSubst<"bic${s}${p} $Rd, $Rn, $imm",
6023 (ANDri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm,
6024 pred:$p, cc_out:$s)>;
6025 def : ARMInstSubst<"bic${s}${p} $Rdn, $imm",
6026 (ANDri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm,
6027 pred:$p, cc_out:$s)>;
6028 def : ARMInstSubst<"and${s}${p} $Rd, $Rn, $imm",
6029 (BICri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm,
6030 pred:$p, cc_out:$s)>;
6031 def : ARMInstSubst<"and${s}${p} $Rdn, $imm",
6032 (BICri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm,
6033 pred:$p, cc_out:$s)>;
6035 // Likewise, "add Rd, mod_imm_neg" -> sub
6036 def : ARMInstSubst<"add${s}${p} $Rd, $Rn, $imm",
6037 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6038 def : ARMInstSubst<"add${s}${p} $Rd, $imm",
6039 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6040 // Likewise, "sub Rd, mod_imm_neg" -> add
6041 def : ARMInstSubst<"sub${s}${p} $Rd, $Rn, $imm",
6042 (ADDri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6043 def : ARMInstSubst<"sub${s}${p} $Rd, $imm",
6044 (ADDri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6047 def : ARMInstSubst<"adc${s}${p} $Rd, $Rn, $imm",
6048 (SBCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6049 def : ARMInstSubst<"adc${s}${p} $Rdn, $imm",
6050 (SBCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6051 def : ARMInstSubst<"sbc${s}${p} $Rd, $Rn, $imm",
6052 (ADCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6053 def : ARMInstSubst<"sbc${s}${p} $Rdn, $imm",
6054 (ADCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6056 // Same for CMP <--> CMN via mod_imm_neg
6057 def : ARMInstSubst<"cmp${p} $Rd, $imm",
6058 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
6059 def : ARMInstSubst<"cmn${p} $Rd, $imm",
6060 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
6062 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
6063 // LSR, ROR, and RRX instructions.
6064 // FIXME: We need C++ parser hooks to map the alias to the MOV
6065 // encoding. It seems we should be able to do that sort of thing
6066 // in tblgen, but it could get ugly.
6067 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
6068 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
6069 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
6071 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
6072 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
6074 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
6075 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
6077 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
6078 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
6081 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
6082 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>;
6083 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
6084 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
6085 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6087 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
6088 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6090 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
6091 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6093 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
6094 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6098 // "neg" is and alias for "rsb rd, rn, #0"
6099 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
6100 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
6102 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
6103 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
6104 Requires<[IsARM, NoV6]>;
6106 // MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but
6107 // the instruction definitions need difference constraints pre-v6.
6108 // Use these aliases for the assembly parsing on pre-v6.
6109 def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm",
6110 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s), 0>,
6111 Requires<[IsARM, NoV6]>;
6112 def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra",
6113 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
6114 pred:$p, cc_out:$s), 0>,
6115 Requires<[IsARM, NoV6]>;
6116 def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6117 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6118 Requires<[IsARM, NoV6]>;
6119 def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6120 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6121 Requires<[IsARM, NoV6]>;
6122 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6123 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6124 Requires<[IsARM, NoV6]>;
6125 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6126 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6127 Requires<[IsARM, NoV6]>;
6129 // 'it' blocks in ARM mode just validate the predicates. The IT itself
6131 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>,
6132 ComplexDeprecationPredicate<"IT">;
6134 let mayLoad = 1, mayStore =1, hasSideEffects = 1 in
6135 def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn),
6137 [(set GPR:$Rd, (int_arm_space imm:$size, GPR:$Rn))]>;
6139 //===----------------------------------
6140 // Atomic cmpxchg for -O0
6141 //===----------------------------------
6143 // The fast register allocator used during -O0 inserts spills to cover any VRegs
6144 // live across basic block boundaries. When this happens between an LDXR and an
6145 // STXR it can clear the exclusive monitor, causing all cmpxchg attempts to
6148 // Unfortunately, this means we have to have an alternative (expanded
6149 // post-regalloc) path for -O0 compilations. Fortunately this path can be
6150 // significantly more naive than the standard expansion: we conservatively
6151 // assume seq_cst, strong cmpxchg and omit clrex on failure.
6153 let Constraints = "@earlyclobber $Rd,@earlyclobber $temp",
6154 mayLoad = 1, mayStore = 1 in {
6155 def CMP_SWAP_8 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6156 (ins GPR:$addr, GPR:$desired, GPR:$new),
6157 NoItinerary, []>, Sched<[]>;
6159 def CMP_SWAP_16 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6160 (ins GPR:$addr, GPR:$desired, GPR:$new),
6161 NoItinerary, []>, Sched<[]>;
6163 def CMP_SWAP_32 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6164 (ins GPR:$addr, GPR:$desired, GPR:$new),
6165 NoItinerary, []>, Sched<[]>;
6167 def CMP_SWAP_64 : PseudoInst<(outs GPRPair:$Rd, GPR:$temp),
6168 (ins GPR:$addr, GPRPair:$desired, GPRPair:$new),
6169 NoItinerary, []>, Sched<[]>;
6172 def CompilerBarrier : PseudoInst<(outs), (ins i32imm:$ordering), NoItinerary,
6173 [(atomic_fence imm:$ordering, 0)]> {
6174 let hasSideEffects = 1;
6176 let AsmString = "@ COMPILER BARRIER";