1//===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===// 2// 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 6// 7//===----------------------------------------------------------------------===// 8// 9// This file describes the ARM instructions in TableGen format. 10// 11//===----------------------------------------------------------------------===// 12 13//===----------------------------------------------------------------------===// 14// ARM specific DAG Nodes. 15// 16 17// Type profiles. 18def SDT_ARMCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>, 19 SDTCisVT<1, i32> ]>; 20def SDT_ARMCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, SDTCisVT<1, i32> ]>; 21def SDT_ARMStructByVal : SDTypeProfile<0, 4, 22 [SDTCisVT<0, i32>, SDTCisVT<1, i32>, 23 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>; 24 25def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>; 26 27def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>; 28 29def SDT_ARMCMov : SDTypeProfile<1, 3, 30 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, 31 SDTCisVT<3, i32>]>; 32 33def SDT_ARMBrcond : SDTypeProfile<0, 2, 34 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>; 35 36def SDT_ARMBrJT : SDTypeProfile<0, 2, 37 [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>; 38 39def SDT_ARMBr2JT : SDTypeProfile<0, 3, 40 [SDTCisPtrTy<0>, SDTCisVT<1, i32>, 41 SDTCisVT<2, i32>]>; 42 43def SDT_ARMBCC_i64 : SDTypeProfile<0, 6, 44 [SDTCisVT<0, i32>, 45 SDTCisVT<1, i32>, SDTCisVT<2, i32>, 46 SDTCisVT<3, i32>, SDTCisVT<4, i32>, 47 SDTCisVT<5, OtherVT>]>; 48 49def SDT_ARMAnd : SDTypeProfile<1, 2, 50 [SDTCisVT<0, i32>, SDTCisVT<1, i32>, 51 SDTCisVT<2, i32>]>; 52 53def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>; 54 55def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>, 56 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>; 57 58def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>; 59def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>, 60 SDTCisInt<2>]>; 61def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>; 62def SDT_ARMEH_SJLJ_SetupDispatch: SDTypeProfile<0, 0, []>; 63 64def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>; 65 66def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>, 67 SDTCisInt<1>]>; 68 69def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>; 70 71def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>, 72 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>; 73 74def SDT_WIN__DBZCHK : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>; 75 76def SDT_ARMMEMCPY : SDTypeProfile<2, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>, 77 SDTCisVT<2, i32>, SDTCisVT<3, i32>, 78 SDTCisVT<4, i32>]>; 79 80def SDTBinaryArithWithFlags : SDTypeProfile<2, 2, 81 [SDTCisSameAs<0, 2>, 82 SDTCisSameAs<0, 3>, 83 SDTCisInt<0>, SDTCisVT<1, i32>]>; 84 85// SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR 86def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3, 87 [SDTCisSameAs<0, 2>, 88 SDTCisSameAs<0, 3>, 89 SDTCisInt<0>, 90 SDTCisVT<1, i32>, 91 SDTCisVT<4, i32>]>; 92 93def SDT_LongMac : SDTypeProfile<2, 4, [SDTCisVT<0, i32>, 94 SDTCisSameAs<0, 1>, 95 SDTCisSameAs<0, 2>, 96 SDTCisSameAs<0, 3>, 97 SDTCisSameAs<0, 4>, 98 SDTCisSameAs<0, 5>]>; 99 100// ARMlsll, ARMlsrl, ARMasrl 101def SDT_ARMIntShiftParts : SDTypeProfile<2, 3, [SDTCisSameAs<0, 1>, 102 SDTCisSameAs<0, 2>, 103 SDTCisSameAs<0, 3>, 104 SDTCisInt<0>, 105 SDTCisInt<4>]>; 106 107// TODO Add another operand for 'Size' so that we can re-use this node when we 108// start supporting *TP versions. 109def SDT_ARMLoLoop : SDTypeProfile<0, 2, [SDTCisVT<0, i32>, 110 SDTCisVT<1, OtherVT>]>; 111 112def ARMSmlald : SDNode<"ARMISD::SMLALD", SDT_LongMac>; 113def ARMSmlaldx : SDNode<"ARMISD::SMLALDX", SDT_LongMac>; 114def ARMSmlsld : SDNode<"ARMISD::SMLSLD", SDT_LongMac>; 115def ARMSmlsldx : SDNode<"ARMISD::SMLSLDX", SDT_LongMac>; 116 117def SDT_ARMCSel : SDTypeProfile<1, 3, 118 [SDTCisSameAs<0, 1>, 119 SDTCisSameAs<0, 2>, 120 SDTCisInt<3>, 121 SDTCisVT<3, i32>]>; 122 123def ARMcsinv : SDNode<"ARMISD::CSINV", SDT_ARMCSel, [SDNPOptInGlue]>; 124def ARMcsneg : SDNode<"ARMISD::CSNEG", SDT_ARMCSel, [SDNPOptInGlue]>; 125def ARMcsinc : SDNode<"ARMISD::CSINC", SDT_ARMCSel, [SDNPOptInGlue]>; 126 127def SDT_MulHSR : SDTypeProfile<1, 3, [SDTCisVT<0,i32>, 128 SDTCisSameAs<0, 1>, 129 SDTCisSameAs<0, 2>, 130 SDTCisSameAs<0, 3>]>; 131 132def ARMsmmlar : SDNode<"ARMISD::SMMLAR", SDT_MulHSR>; 133def ARMsmmlsr : SDNode<"ARMISD::SMMLSR", SDT_MulHSR>; 134 135// Node definitions. 136def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>; 137def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>; 138def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntUnaryOp>; 139 140def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart, 141 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>; 142def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd, 143 [SDNPHasChain, SDNPSideEffect, 144 SDNPOptInGlue, SDNPOutGlue]>; 145def ARMcopystructbyval : SDNode<"ARMISD::COPY_STRUCT_BYVAL" , 146 SDT_ARMStructByVal, 147 [SDNPHasChain, SDNPInGlue, SDNPOutGlue, 148 SDNPMayStore, SDNPMayLoad]>; 149 150def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall, 151 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 152 SDNPVariadic]>; 153def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall, 154 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 155 SDNPVariadic]>; 156def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall, 157 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 158 SDNPVariadic]>; 159 160def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone, 161 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 162def ARMintretflag : SDNode<"ARMISD::INTRET_FLAG", SDT_ARMcall, 163 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 164def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov, 165 [SDNPInGlue]>; 166def ARMsubs : SDNode<"ARMISD::SUBS", SDTIntBinOp, [SDNPOutGlue]>; 167 168def ARMssatnoshift : SDNode<"ARMISD::SSAT", SDTIntSatNoShOp, []>; 169 170def ARMusatnoshift : SDNode<"ARMISD::USAT", SDTIntSatNoShOp, []>; 171 172def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond, 173 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>; 174 175def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT, 176 [SDNPHasChain]>; 177def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT, 178 [SDNPHasChain]>; 179 180def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64, 181 [SDNPHasChain]>; 182 183def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp, 184 [SDNPOutGlue]>; 185 186def ARMcmn : SDNode<"ARMISD::CMN", SDT_ARMCmp, 187 [SDNPOutGlue]>; 188 189def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp, 190 [SDNPOutGlue, SDNPCommutative]>; 191 192def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>; 193 194def ARMasrl : SDNode<"ARMISD::ASRL", SDT_ARMIntShiftParts, []>; 195def ARMlsrl : SDNode<"ARMISD::LSRL", SDT_ARMIntShiftParts, []>; 196def ARMlsll : SDNode<"ARMISD::LSLL", SDT_ARMIntShiftParts, []>; 197 198def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>; 199def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>; 200def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>; 201 202def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags, 203 [SDNPCommutative]>; 204def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>; 205def ARMlsls : SDNode<"ARMISD::LSLS", SDTBinaryArithWithFlags>; 206def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>; 207def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>; 208 209def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>; 210def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP", 211 SDT_ARMEH_SJLJ_Setjmp, 212 [SDNPHasChain, SDNPSideEffect]>; 213def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP", 214 SDT_ARMEH_SJLJ_Longjmp, 215 [SDNPHasChain, SDNPSideEffect]>; 216def ARMeh_sjlj_setup_dispatch: SDNode<"ARMISD::EH_SJLJ_SETUP_DISPATCH", 217 SDT_ARMEH_SJLJ_SetupDispatch, 218 [SDNPHasChain, SDNPSideEffect]>; 219 220def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER, 221 [SDNPHasChain, SDNPSideEffect]>; 222def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH, 223 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>; 224 225def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET, 226 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 227 228def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>; 229 230def ARMmemcopy : SDNode<"ARMISD::MEMCPY", SDT_ARMMEMCPY, 231 [SDNPHasChain, SDNPInGlue, SDNPOutGlue, 232 SDNPMayStore, SDNPMayLoad]>; 233 234def ARMsmulwb : SDNode<"ARMISD::SMULWB", SDTIntBinOp, []>; 235def ARMsmulwt : SDNode<"ARMISD::SMULWT", SDTIntBinOp, []>; 236def ARMsmlalbb : SDNode<"ARMISD::SMLALBB", SDT_LongMac, []>; 237def ARMsmlalbt : SDNode<"ARMISD::SMLALBT", SDT_LongMac, []>; 238def ARMsmlaltb : SDNode<"ARMISD::SMLALTB", SDT_LongMac, []>; 239def ARMsmlaltt : SDNode<"ARMISD::SMLALTT", SDT_LongMac, []>; 240 241def ARMqadd8b : SDNode<"ARMISD::QADD8b", SDT_ARMAnd, []>; 242def ARMqsub8b : SDNode<"ARMISD::QSUB8b", SDT_ARMAnd, []>; 243def ARMqadd16b : SDNode<"ARMISD::QADD16b", SDT_ARMAnd, []>; 244def ARMqsub16b : SDNode<"ARMISD::QSUB16b", SDT_ARMAnd, []>; 245 246// Vector operations shared between NEON and MVE 247 248def ARMvdup : SDNode<"ARMISD::VDUP", SDTypeProfile<1, 1, [SDTCisVec<0>]>>; 249 250// VDUPLANE can produce a quad-register result from a double-register source, 251// so the result is not constrained to match the source. 252def ARMvduplane : SDNode<"ARMISD::VDUPLANE", 253 SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>, 254 SDTCisVT<2, i32>]>>; 255 256def SDTARMVSHUF : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0, 1>]>; 257def ARMvrev64 : SDNode<"ARMISD::VREV64", SDTARMVSHUF>; 258def ARMvrev32 : SDNode<"ARMISD::VREV32", SDTARMVSHUF>; 259def ARMvrev16 : SDNode<"ARMISD::VREV16", SDTARMVSHUF>; 260 261def SDTARMVGETLN : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisInt<1>, 262 SDTCisVT<2, i32>]>; 263def ARMvgetlaneu : SDNode<"ARMISD::VGETLANEu", SDTARMVGETLN>; 264def ARMvgetlanes : SDNode<"ARMISD::VGETLANEs", SDTARMVGETLN>; 265 266def SDTARMVMOVIMM : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVT<1, i32>]>; 267def ARMvmovImm : SDNode<"ARMISD::VMOVIMM", SDTARMVMOVIMM>; 268def ARMvmvnImm : SDNode<"ARMISD::VMVNIMM", SDTARMVMOVIMM>; 269def ARMvmovFPImm : SDNode<"ARMISD::VMOVFPIMM", SDTARMVMOVIMM>; 270 271 272def SDTARMVSHIMM : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>, 273 SDTCisVT<2, i32>]>; 274def SDTARMVSH : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>, 275 SDTCisSameAs<0, 2>,]>; 276def ARMvshlImm : SDNode<"ARMISD::VSHLIMM", SDTARMVSHIMM>; 277def ARMvshrsImm : SDNode<"ARMISD::VSHRsIMM", SDTARMVSHIMM>; 278def ARMvshruImm : SDNode<"ARMISD::VSHRuIMM", SDTARMVSHIMM>; 279def ARMvshls : SDNode<"ARMISD::VSHLs", SDTARMVSH>; 280def ARMvshlu : SDNode<"ARMISD::VSHLu", SDTARMVSH>; 281 282def SDTARMVCMP : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<1, 2>, 283 SDTCisInt<3>]>; 284def SDTARMVCMPZ : SDTypeProfile<1, 2, [SDTCisInt<2>]>; 285 286def ARMvcmp : SDNode<"ARMISD::VCMP", SDTARMVCMP>; 287def ARMvcmpz : SDNode<"ARMISD::VCMPZ", SDTARMVCMPZ>; 288 289def ARMWLS : SDNode<"ARMISD::WLS", SDT_ARMLoLoop, [SDNPHasChain]>; 290def ARMLE : SDNode<"ARMISD::LE", SDT_ARMLoLoop, [SDNPHasChain]>; 291def ARMLoopDec : SDNode<"ARMISD::LOOP_DEC", SDTIntBinOp, [SDNPHasChain]>; 292 293//===----------------------------------------------------------------------===// 294// ARM Flag Definitions. 295 296class RegConstraint<string C> { 297 string Constraints = C; 298} 299 300// ARMCC condition codes. See ARMCC::CondCodes 301def ARMCCeq : PatLeaf<(i32 0)>; 302def ARMCCne : PatLeaf<(i32 1)>; 303def ARMCChs : PatLeaf<(i32 2)>; 304def ARMCClo : PatLeaf<(i32 3)>; 305def ARMCCmi : PatLeaf<(i32 4)>; 306def ARMCCpl : PatLeaf<(i32 5)>; 307def ARMCCvs : PatLeaf<(i32 6)>; 308def ARMCCvc : PatLeaf<(i32 7)>; 309def ARMCChi : PatLeaf<(i32 8)>; 310def ARMCCls : PatLeaf<(i32 9)>; 311def ARMCCge : PatLeaf<(i32 10)>; 312def ARMCClt : PatLeaf<(i32 11)>; 313def ARMCCgt : PatLeaf<(i32 12)>; 314def ARMCCle : PatLeaf<(i32 13)>; 315def ARMCCal : PatLeaf<(i32 14)>; 316 317// VCC predicates. See ARMVCC::VPTCodes 318def ARMVCCNone : PatLeaf<(i32 0)>; 319def ARMVCCThen : PatLeaf<(i32 1)>; 320def ARMVCCElse : PatLeaf<(i32 2)>; 321 322//===----------------------------------------------------------------------===// 323// ARM specific transformation functions and pattern fragments. 324// 325 326// imm_neg_XFORM - Return the negation of an i32 immediate value. 327def imm_neg_XFORM : SDNodeXForm<imm, [{ 328 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), SDLoc(N), MVT::i32); 329}]>; 330 331// imm_not_XFORM - Return the complement of a i32 immediate value. 332def imm_not_XFORM : SDNodeXForm<imm, [{ 333 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), SDLoc(N), MVT::i32); 334}]>; 335 336/// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31]. 337def imm16_31 : ImmLeaf<i32, [{ 338 return (int32_t)Imm >= 16 && (int32_t)Imm < 32; 339}]>; 340 341// sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits. 342def sext_16_node : PatLeaf<(i32 GPR:$a), [{ 343 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17; 344}]>; 345 346def sext_bottom_16 : PatFrag<(ops node:$a), 347 (sext_inreg node:$a, i16)>; 348def sext_top_16 : PatFrag<(ops node:$a), 349 (i32 (sra node:$a, (i32 16)))>; 350 351def bb_mul : PatFrag<(ops node:$a, node:$b), 352 (mul (sext_bottom_16 node:$a), (sext_bottom_16 node:$b))>; 353def bt_mul : PatFrag<(ops node:$a, node:$b), 354 (mul (sext_bottom_16 node:$a), (sra node:$b, (i32 16)))>; 355def tb_mul : PatFrag<(ops node:$a, node:$b), 356 (mul (sra node:$a, (i32 16)), (sext_bottom_16 node:$b))>; 357def tt_mul : PatFrag<(ops node:$a, node:$b), 358 (mul (sra node:$a, (i32 16)), (sra node:$b, (i32 16)))>; 359 360/// Split a 32-bit immediate into two 16 bit parts. 361def hi16 : SDNodeXForm<imm, [{ 362 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, SDLoc(N), 363 MVT::i32); 364}]>; 365 366def lo16AllZero : PatLeaf<(i32 imm), [{ 367 // Returns true if all low 16-bits are 0. 368 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0; 369}], hi16>; 370 371class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>; 372class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>; 373 374// An 'and' node with a single use. 375def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{ 376 return N->hasOneUse(); 377}]>; 378 379// An 'xor' node with a single use. 380def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{ 381 return N->hasOneUse(); 382}]>; 383 384// An 'fmul' node with a single use. 385def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{ 386 return N->hasOneUse(); 387}]>; 388 389// An 'fadd' node which checks for single non-hazardous use. 390def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{ 391 return hasNoVMLxHazardUse(N); 392}]>; 393 394// An 'fsub' node which checks for single non-hazardous use. 395def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{ 396 return hasNoVMLxHazardUse(N); 397}]>; 398 399//===----------------------------------------------------------------------===// 400// Operand Definitions. 401// 402 403// Immediate operands with a shared generic asm render method. 404class ImmAsmOperand<int Low, int High> : AsmOperandClass { 405 let RenderMethod = "addImmOperands"; 406 let PredicateMethod = "isImmediate<" # Low # "," # High # ">"; 407 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]"; 408} 409 410class ImmAsmOperandMinusOne<int Low, int High> : AsmOperandClass { 411 let PredicateMethod = "isImmediate<" # Low # "," # High # ">"; 412 let DiagnosticType = "ImmRange" # Low # "_" # High; 413 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]"; 414} 415 416// Operands that are part of a memory addressing mode. 417class MemOperand : Operand<i32> { let OperandType = "OPERAND_MEMORY"; } 418 419// Branch target. 420// FIXME: rename brtarget to t2_brtarget 421def brtarget : Operand<OtherVT> { 422 let EncoderMethod = "getBranchTargetOpValue"; 423 let OperandType = "OPERAND_PCREL"; 424 let DecoderMethod = "DecodeT2BROperand"; 425} 426 427// Branches targeting ARM-mode must be divisible by 4 if they're a raw 428// immediate. 429def ARMBranchTarget : AsmOperandClass { 430 let Name = "ARMBranchTarget"; 431} 432 433// Branches targeting Thumb-mode must be divisible by 2 if they're a raw 434// immediate. 435def ThumbBranchTarget : AsmOperandClass { 436 let Name = "ThumbBranchTarget"; 437} 438 439def arm_br_target : Operand<OtherVT> { 440 let ParserMatchClass = ARMBranchTarget; 441 let EncoderMethod = "getARMBranchTargetOpValue"; 442 let OperandType = "OPERAND_PCREL"; 443} 444 445// Call target for ARM. Handles conditional/unconditional 446// FIXME: rename bl_target to t2_bltarget? 447def arm_bl_target : Operand<i32> { 448 let ParserMatchClass = ARMBranchTarget; 449 let EncoderMethod = "getARMBLTargetOpValue"; 450 let OperandType = "OPERAND_PCREL"; 451} 452 453// Target for BLX *from* ARM mode. 454def arm_blx_target : Operand<i32> { 455 let ParserMatchClass = ThumbBranchTarget; 456 let EncoderMethod = "getARMBLXTargetOpValue"; 457 let OperandType = "OPERAND_PCREL"; 458} 459 460// A list of registers separated by comma. Used by load/store multiple. 461def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; } 462def reglist : Operand<i32> { 463 let EncoderMethod = "getRegisterListOpValue"; 464 let ParserMatchClass = RegListAsmOperand; 465 let PrintMethod = "printRegisterList"; 466 let DecoderMethod = "DecodeRegListOperand"; 467} 468 469// A list of general purpose registers and APSR separated by comma. 470// Used by CLRM 471def RegListWithAPSRAsmOperand : AsmOperandClass { let Name = "RegListWithAPSR"; } 472def reglist_with_apsr : Operand<i32> { 473 let EncoderMethod = "getRegisterListOpValue"; 474 let ParserMatchClass = RegListWithAPSRAsmOperand; 475 let PrintMethod = "printRegisterList"; 476 let DecoderMethod = "DecodeRegListOperand"; 477} 478 479def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">; 480 481def DPRRegListAsmOperand : AsmOperandClass { 482 let Name = "DPRRegList"; 483 let DiagnosticType = "DPR_RegList"; 484} 485def dpr_reglist : Operand<i32> { 486 let EncoderMethod = "getRegisterListOpValue"; 487 let ParserMatchClass = DPRRegListAsmOperand; 488 let PrintMethod = "printRegisterList"; 489 let DecoderMethod = "DecodeDPRRegListOperand"; 490} 491 492def SPRRegListAsmOperand : AsmOperandClass { 493 let Name = "SPRRegList"; 494 let DiagnosticString = "operand must be a list of registers in range [s0, s31]"; 495} 496def spr_reglist : Operand<i32> { 497 let EncoderMethod = "getRegisterListOpValue"; 498 let ParserMatchClass = SPRRegListAsmOperand; 499 let PrintMethod = "printRegisterList"; 500 let DecoderMethod = "DecodeSPRRegListOperand"; 501} 502 503def FPSRegListWithVPRAsmOperand : AsmOperandClass { let Name = 504 "FPSRegListWithVPR"; } 505def fp_sreglist_with_vpr : Operand<i32> { 506 let EncoderMethod = "getRegisterListOpValue"; 507 let ParserMatchClass = FPSRegListWithVPRAsmOperand; 508 let PrintMethod = "printRegisterList"; 509} 510def FPDRegListWithVPRAsmOperand : AsmOperandClass { let Name = 511 "FPDRegListWithVPR"; } 512def fp_dreglist_with_vpr : Operand<i32> { 513 let EncoderMethod = "getRegisterListOpValue"; 514 let ParserMatchClass = FPDRegListWithVPRAsmOperand; 515 let PrintMethod = "printRegisterList"; 516} 517 518// An operand for the CONSTPOOL_ENTRY pseudo-instruction. 519def cpinst_operand : Operand<i32> { 520 let PrintMethod = "printCPInstOperand"; 521} 522 523// Local PC labels. 524def pclabel : Operand<i32> { 525 let PrintMethod = "printPCLabel"; 526} 527 528// ADR instruction labels. 529def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; } 530def adrlabel : Operand<i32> { 531 let EncoderMethod = "getAdrLabelOpValue"; 532 let ParserMatchClass = AdrLabelAsmOperand; 533 let PrintMethod = "printAdrLabelOperand<0>"; 534} 535 536def neon_vcvt_imm32 : Operand<i32> { 537 let EncoderMethod = "getNEONVcvtImm32OpValue"; 538 let DecoderMethod = "DecodeVCVTImmOperand"; 539} 540 541// rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24. 542def rot_imm_XFORM: SDNodeXForm<imm, [{ 543 switch (N->getZExtValue()){ 544 default: llvm_unreachable(nullptr); 545 case 0: return CurDAG->getTargetConstant(0, SDLoc(N), MVT::i32); 546 case 8: return CurDAG->getTargetConstant(1, SDLoc(N), MVT::i32); 547 case 16: return CurDAG->getTargetConstant(2, SDLoc(N), MVT::i32); 548 case 24: return CurDAG->getTargetConstant(3, SDLoc(N), MVT::i32); 549 } 550}]>; 551def RotImmAsmOperand : AsmOperandClass { 552 let Name = "RotImm"; 553 let ParserMethod = "parseRotImm"; 554} 555def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{ 556 int32_t v = N->getZExtValue(); 557 return v == 8 || v == 16 || v == 24; }], 558 rot_imm_XFORM> { 559 let PrintMethod = "printRotImmOperand"; 560 let ParserMatchClass = RotImmAsmOperand; 561} 562 563// Power-of-two operand for MVE VIDUP and friends, which encode 564// {1,2,4,8} as its log to base 2, i.e. as {0,1,2,3} respectively 565def MVE_VIDUP_imm_asmoperand : AsmOperandClass { 566 let Name = "VIDUP_imm"; 567 let PredicateMethod = "isPowerTwoInRange<1,8>"; 568 let RenderMethod = "addPowerTwoOperands"; 569 let DiagnosticString = "vector increment immediate must be 1, 2, 4 or 8"; 570} 571def MVE_VIDUP_imm : Operand<i32> { 572 let EncoderMethod = "getPowerTwoOpValue"; 573 let DecoderMethod = "DecodePowerTwoOperand<0,3>"; 574 let ParserMatchClass = MVE_VIDUP_imm_asmoperand; 575} 576 577// Pair vector indexing 578class MVEPairVectorIndexOperand<string start, string end> : AsmOperandClass { 579 let Name = "MVEPairVectorIndex"#start; 580 let RenderMethod = "addMVEPairVectorIndexOperands"; 581 let PredicateMethod = "isMVEPairVectorIndex<"#start#", "#end#">"; 582} 583 584class MVEPairVectorIndex<string opval> : Operand<i32> { 585 let PrintMethod = "printVectorIndex"; 586 let EncoderMethod = "getMVEPairVectorIndexOpValue<"#opval#">"; 587 let DecoderMethod = "DecodeMVEPairVectorIndexOperand<"#opval#">"; 588 let MIOperandInfo = (ops i32imm); 589} 590 591def MVEPairVectorIndex0 : MVEPairVectorIndex<"0"> { 592 let ParserMatchClass = MVEPairVectorIndexOperand<"0", "1">; 593} 594 595def MVEPairVectorIndex2 : MVEPairVectorIndex<"2"> { 596 let ParserMatchClass = MVEPairVectorIndexOperand<"2", "3">; 597} 598 599// Vector indexing 600class MVEVectorIndexOperand<int NumLanes> : AsmOperandClass { 601 let Name = "MVEVectorIndex"#NumLanes; 602 let RenderMethod = "addMVEVectorIndexOperands"; 603 let PredicateMethod = "isVectorIndexInRange<"#NumLanes#">"; 604} 605 606class MVEVectorIndex<int NumLanes> : Operand<i32> { 607 let PrintMethod = "printVectorIndex"; 608 let ParserMatchClass = MVEVectorIndexOperand<NumLanes>; 609 let MIOperandInfo = (ops i32imm); 610} 611 612// shift_imm: An integer that encodes a shift amount and the type of shift 613// (asr or lsl). The 6-bit immediate encodes as: 614// {5} 0 ==> lsl 615// 1 asr 616// {4-0} imm5 shift amount. 617// asr #32 encoded as imm5 == 0. 618def ShifterImmAsmOperand : AsmOperandClass { 619 let Name = "ShifterImm"; 620 let ParserMethod = "parseShifterImm"; 621} 622def shift_imm : Operand<i32> { 623 let PrintMethod = "printShiftImmOperand"; 624 let ParserMatchClass = ShifterImmAsmOperand; 625} 626 627// shifter_operand operands: so_reg_reg, so_reg_imm, and mod_imm. 628def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; } 629def so_reg_reg : Operand<i32>, // reg reg imm 630 ComplexPattern<i32, 3, "SelectRegShifterOperand", 631 [shl, srl, sra, rotr]> { 632 let EncoderMethod = "getSORegRegOpValue"; 633 let PrintMethod = "printSORegRegOperand"; 634 let DecoderMethod = "DecodeSORegRegOperand"; 635 let ParserMatchClass = ShiftedRegAsmOperand; 636 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm); 637} 638 639def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; } 640def so_reg_imm : Operand<i32>, // reg imm 641 ComplexPattern<i32, 2, "SelectImmShifterOperand", 642 [shl, srl, sra, rotr]> { 643 let EncoderMethod = "getSORegImmOpValue"; 644 let PrintMethod = "printSORegImmOperand"; 645 let DecoderMethod = "DecodeSORegImmOperand"; 646 let ParserMatchClass = ShiftedImmAsmOperand; 647 let MIOperandInfo = (ops GPR, i32imm); 648} 649 650// FIXME: Does this need to be distinct from so_reg? 651def shift_so_reg_reg : Operand<i32>, // reg reg imm 652 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand", 653 [shl,srl,sra,rotr]> { 654 let EncoderMethod = "getSORegRegOpValue"; 655 let PrintMethod = "printSORegRegOperand"; 656 let DecoderMethod = "DecodeSORegRegOperand"; 657 let ParserMatchClass = ShiftedRegAsmOperand; 658 let MIOperandInfo = (ops GPR, GPR, i32imm); 659} 660 661// FIXME: Does this need to be distinct from so_reg? 662def shift_so_reg_imm : Operand<i32>, // reg reg imm 663 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand", 664 [shl,srl,sra,rotr]> { 665 let EncoderMethod = "getSORegImmOpValue"; 666 let PrintMethod = "printSORegImmOperand"; 667 let DecoderMethod = "DecodeSORegImmOperand"; 668 let ParserMatchClass = ShiftedImmAsmOperand; 669 let MIOperandInfo = (ops GPR, i32imm); 670} 671 672// mod_imm: match a 32-bit immediate operand, which can be encoded into 673// a 12-bit immediate; an 8-bit integer and a 4-bit rotator (See ARMARM 674// - "Modified Immediate Constants"). Within the MC layer we keep this 675// immediate in its encoded form. 676def ModImmAsmOperand: AsmOperandClass { 677 let Name = "ModImm"; 678 let ParserMethod = "parseModImm"; 679} 680def mod_imm : Operand<i32>, ImmLeaf<i32, [{ 681 return ARM_AM::getSOImmVal(Imm) != -1; 682 }]> { 683 let EncoderMethod = "getModImmOpValue"; 684 let PrintMethod = "printModImmOperand"; 685 let ParserMatchClass = ModImmAsmOperand; 686} 687 688// Note: the patterns mod_imm_not and mod_imm_neg do not require an encoder 689// method and such, as they are only used on aliases (Pat<> and InstAlias<>). 690// The actual parsing, encoding, decoding are handled by the destination 691// instructions, which use mod_imm. 692 693def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; } 694def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{ 695 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1; 696 }], imm_not_XFORM> { 697 let ParserMatchClass = ModImmNotAsmOperand; 698} 699 700def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; } 701def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{ 702 unsigned Value = -(unsigned)N->getZExtValue(); 703 return Value && ARM_AM::getSOImmVal(Value) != -1; 704 }], imm_neg_XFORM> { 705 let ParserMatchClass = ModImmNegAsmOperand; 706} 707 708/// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal() 709def arm_i32imm : IntImmLeaf<i32, [{ 710 if (Subtarget->useMovt()) 711 return true; 712 return ARM_AM::isSOImmTwoPartVal(Imm.getZExtValue()); 713}]>; 714 715/// imm0_1 predicate - Immediate in the range [0,1]. 716def Imm0_1AsmOperand: ImmAsmOperand<0,1> { let Name = "Imm0_1"; } 717def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; } 718 719/// imm0_3 predicate - Immediate in the range [0,3]. 720def Imm0_3AsmOperand: ImmAsmOperand<0,3> { let Name = "Imm0_3"; } 721def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; } 722 723/// imm0_7 predicate - Immediate in the range [0,7]. 724def Imm0_7AsmOperand: ImmAsmOperand<0,7> { 725 let Name = "Imm0_7"; 726} 727def imm0_7 : Operand<i32>, ImmLeaf<i32, [{ 728 return Imm >= 0 && Imm < 8; 729}]> { 730 let ParserMatchClass = Imm0_7AsmOperand; 731} 732 733/// imm8_255 predicate - Immediate in the range [8,255]. 734def Imm8_255AsmOperand: ImmAsmOperand<8,255> { let Name = "Imm8_255"; } 735def imm8_255 : Operand<i32>, ImmLeaf<i32, [{ 736 return Imm >= 8 && Imm < 256; 737}]> { 738 let ParserMatchClass = Imm8_255AsmOperand; 739} 740 741/// imm8 predicate - Immediate is exactly 8. 742def Imm8AsmOperand: ImmAsmOperand<8,8> { let Name = "Imm8"; } 743def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> { 744 let ParserMatchClass = Imm8AsmOperand; 745} 746 747/// imm16 predicate - Immediate is exactly 16. 748def Imm16AsmOperand: ImmAsmOperand<16,16> { let Name = "Imm16"; } 749def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> { 750 let ParserMatchClass = Imm16AsmOperand; 751} 752 753/// imm32 predicate - Immediate is exactly 32. 754def Imm32AsmOperand: ImmAsmOperand<32,32> { let Name = "Imm32"; } 755def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> { 756 let ParserMatchClass = Imm32AsmOperand; 757} 758 759def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>; 760 761/// imm1_7 predicate - Immediate in the range [1,7]. 762def Imm1_7AsmOperand: ImmAsmOperand<1,7> { let Name = "Imm1_7"; } 763def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> { 764 let ParserMatchClass = Imm1_7AsmOperand; 765} 766 767/// imm1_15 predicate - Immediate in the range [1,15]. 768def Imm1_15AsmOperand: ImmAsmOperand<1,15> { let Name = "Imm1_15"; } 769def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> { 770 let ParserMatchClass = Imm1_15AsmOperand; 771} 772 773/// imm1_31 predicate - Immediate in the range [1,31]. 774def Imm1_31AsmOperand: ImmAsmOperand<1,31> { let Name = "Imm1_31"; } 775def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> { 776 let ParserMatchClass = Imm1_31AsmOperand; 777} 778 779/// imm0_15 predicate - Immediate in the range [0,15]. 780def Imm0_15AsmOperand: ImmAsmOperand<0,15> { 781 let Name = "Imm0_15"; 782} 783def imm0_15 : Operand<i32>, ImmLeaf<i32, [{ 784 return Imm >= 0 && Imm < 16; 785}]> { 786 let ParserMatchClass = Imm0_15AsmOperand; 787} 788 789/// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31]. 790def Imm0_31AsmOperand: ImmAsmOperand<0,31> { let Name = "Imm0_31"; } 791def imm0_31 : Operand<i32>, ImmLeaf<i32, [{ 792 return Imm >= 0 && Imm < 32; 793}]> { 794 let ParserMatchClass = Imm0_31AsmOperand; 795} 796 797/// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32]. 798def Imm0_32AsmOperand: ImmAsmOperand<0,32> { let Name = "Imm0_32"; } 799def imm0_32 : Operand<i32>, ImmLeaf<i32, [{ 800 return Imm >= 0 && Imm < 33; 801}]> { 802 let ParserMatchClass = Imm0_32AsmOperand; 803} 804 805/// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63]. 806def Imm0_63AsmOperand: ImmAsmOperand<0,63> { let Name = "Imm0_63"; } 807def imm0_63 : Operand<i32>, ImmLeaf<i32, [{ 808 return Imm >= 0 && Imm < 64; 809}]> { 810 let ParserMatchClass = Imm0_63AsmOperand; 811} 812 813/// imm0_239 predicate - Immediate in the range [0,239]. 814def Imm0_239AsmOperand : ImmAsmOperand<0,239> { 815 let Name = "Imm0_239"; 816} 817def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> { 818 let ParserMatchClass = Imm0_239AsmOperand; 819} 820 821/// imm0_255 predicate - Immediate in the range [0,255]. 822def Imm0_255AsmOperand : ImmAsmOperand<0,255> { let Name = "Imm0_255"; } 823def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> { 824 let ParserMatchClass = Imm0_255AsmOperand; 825} 826 827/// imm0_65535 - An immediate is in the range [0,65535]. 828def Imm0_65535AsmOperand: ImmAsmOperand<0,65535> { let Name = "Imm0_65535"; } 829def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{ 830 return Imm >= 0 && Imm < 65536; 831}]> { 832 let ParserMatchClass = Imm0_65535AsmOperand; 833} 834 835// imm0_65535_neg - An immediate whose negative value is in the range [0.65535]. 836def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{ 837 return -Imm >= 0 && -Imm < 65536; 838}]>; 839 840// imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference 841// a relocatable expression. 842// 843// FIXME: This really needs a Thumb version separate from the ARM version. 844// While the range is the same, and can thus use the same match class, 845// the encoding is different so it should have a different encoder method. 846def Imm0_65535ExprAsmOperand: AsmOperandClass { 847 let Name = "Imm0_65535Expr"; 848 let RenderMethod = "addImmOperands"; 849 let DiagnosticString = "operand must be an immediate in the range [0,0xffff] or a relocatable expression"; 850} 851 852def imm0_65535_expr : Operand<i32> { 853 let EncoderMethod = "getHiLo16ImmOpValue"; 854 let ParserMatchClass = Imm0_65535ExprAsmOperand; 855} 856 857def Imm256_65535ExprAsmOperand: ImmAsmOperand<256,65535> { let Name = "Imm256_65535Expr"; } 858def imm256_65535_expr : Operand<i32> { 859 let ParserMatchClass = Imm256_65535ExprAsmOperand; 860} 861 862/// imm24b - True if the 32-bit immediate is encodable in 24 bits. 863def Imm24bitAsmOperand: ImmAsmOperand<0,0xffffff> { 864 let Name = "Imm24bit"; 865 let DiagnosticString = "operand must be an immediate in the range [0,0xffffff]"; 866} 867def imm24b : Operand<i32>, ImmLeaf<i32, [{ 868 return Imm >= 0 && Imm <= 0xffffff; 869}]> { 870 let ParserMatchClass = Imm24bitAsmOperand; 871} 872 873 874/// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield 875/// e.g., 0xf000ffff 876def BitfieldAsmOperand : AsmOperandClass { 877 let Name = "Bitfield"; 878 let ParserMethod = "parseBitfield"; 879} 880 881def bf_inv_mask_imm : Operand<i32>, 882 PatLeaf<(imm), [{ 883 return ARM::isBitFieldInvertedMask(N->getZExtValue()); 884}] > { 885 let EncoderMethod = "getBitfieldInvertedMaskOpValue"; 886 let PrintMethod = "printBitfieldInvMaskImmOperand"; 887 let DecoderMethod = "DecodeBitfieldMaskOperand"; 888 let ParserMatchClass = BitfieldAsmOperand; 889 let GISelPredicateCode = [{ 890 // There's better methods of implementing this check. IntImmLeaf<> would be 891 // equivalent and have less boilerplate but we need a test for C++ 892 // predicates and this one causes new rules to be imported into GlobalISel 893 // without requiring additional features first. 894 const auto &MO = MI.getOperand(1); 895 if (!MO.isCImm()) 896 return false; 897 return ARM::isBitFieldInvertedMask(MO.getCImm()->getZExtValue()); 898 }]; 899} 900 901def imm1_32_XFORM: SDNodeXForm<imm, [{ 902 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N), 903 MVT::i32); 904}]>; 905def Imm1_32AsmOperand: ImmAsmOperandMinusOne<1,32> { 906 let Name = "Imm1_32"; 907} 908def imm1_32 : Operand<i32>, PatLeaf<(imm), [{ 909 uint64_t Imm = N->getZExtValue(); 910 return Imm > 0 && Imm <= 32; 911 }], 912 imm1_32_XFORM> { 913 let PrintMethod = "printImmPlusOneOperand"; 914 let ParserMatchClass = Imm1_32AsmOperand; 915} 916 917def imm1_16_XFORM: SDNodeXForm<imm, [{ 918 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N), 919 MVT::i32); 920}]>; 921def Imm1_16AsmOperand: ImmAsmOperandMinusOne<1,16> { let Name = "Imm1_16"; } 922def imm1_16 : Operand<i32>, ImmLeaf<i32, [{ 923 return Imm > 0 && Imm <= 16; 924 }], 925 imm1_16_XFORM> { 926 let PrintMethod = "printImmPlusOneOperand"; 927 let ParserMatchClass = Imm1_16AsmOperand; 928} 929 930def MVEShiftImm1_7AsmOperand: ImmAsmOperand<1,7> { 931 let Name = "MVEShiftImm1_7"; 932 // Reason we're doing this is because instruction vshll.s8 t1 encoding 933 // accepts 1,7 but the t2 encoding accepts 8. By doing this we can get a 934 // better diagnostic message if someone uses bigger immediate than the t1/t2 935 // encodings allow. 936 let DiagnosticString = "operand must be an immediate in the range [1,8]"; 937} 938def mve_shift_imm1_7 : Operand<i32>, 939 // SelectImmediateInRange / isScaledConstantInRange uses a 940 // half-open interval, so the parameters <1,8> mean 1-7 inclusive 941 ComplexPattern<i32, 1, "SelectImmediateInRange<1,8>", [], []> { 942 let ParserMatchClass = MVEShiftImm1_7AsmOperand; 943 let EncoderMethod = "getMVEShiftImmOpValue"; 944} 945 946def MVEShiftImm1_15AsmOperand: ImmAsmOperand<1,15> { 947 let Name = "MVEShiftImm1_15"; 948 // Reason we're doing this is because instruction vshll.s16 t1 encoding 949 // accepts 1,15 but the t2 encoding accepts 16. By doing this we can get a 950 // better diagnostic message if someone uses bigger immediate than the t1/t2 951 // encodings allow. 952 let DiagnosticString = "operand must be an immediate in the range [1,16]"; 953} 954def mve_shift_imm1_15 : Operand<i32>, 955 // SelectImmediateInRange / isScaledConstantInRange uses a 956 // half-open interval, so the parameters <1,16> mean 1-15 inclusive 957 ComplexPattern<i32, 1, "SelectImmediateInRange<1,16>", [], []> { 958 let ParserMatchClass = MVEShiftImm1_15AsmOperand; 959 let EncoderMethod = "getMVEShiftImmOpValue"; 960} 961 962// Define ARM specific addressing modes. 963// addrmode_imm12 := reg +/- imm12 964// 965def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; } 966class AddrMode_Imm12 : MemOperand, 967 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> { 968 // 12-bit immediate operand. Note that instructions using this encode 969 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other 970 // immediate values are as normal. 971 972 let EncoderMethod = "getAddrModeImm12OpValue"; 973 let DecoderMethod = "DecodeAddrModeImm12Operand"; 974 let ParserMatchClass = MemImm12OffsetAsmOperand; 975 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm); 976} 977 978def addrmode_imm12 : AddrMode_Imm12 { 979 let PrintMethod = "printAddrModeImm12Operand<false>"; 980} 981 982def addrmode_imm12_pre : AddrMode_Imm12 { 983 let PrintMethod = "printAddrModeImm12Operand<true>"; 984} 985 986// ldst_so_reg := reg +/- reg shop imm 987// 988def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; } 989def ldst_so_reg : MemOperand, 990 ComplexPattern<i32, 3, "SelectLdStSOReg", []> { 991 let EncoderMethod = "getLdStSORegOpValue"; 992 // FIXME: Simplify the printer 993 let PrintMethod = "printAddrMode2Operand"; 994 let DecoderMethod = "DecodeSORegMemOperand"; 995 let ParserMatchClass = MemRegOffsetAsmOperand; 996 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift); 997} 998 999// postidx_imm8 := +/- [0,255] 1000// 1001// 9 bit value: 1002// {8} 1 is imm8 is non-negative. 0 otherwise. 1003// {7-0} [0,255] imm8 value. 1004def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; } 1005def postidx_imm8 : MemOperand { 1006 let PrintMethod = "printPostIdxImm8Operand"; 1007 let ParserMatchClass = PostIdxImm8AsmOperand; 1008 let MIOperandInfo = (ops i32imm); 1009} 1010 1011// postidx_imm8s4 := +/- [0,1020] 1012// 1013// 9 bit value: 1014// {8} 1 is imm8 is non-negative. 0 otherwise. 1015// {7-0} [0,255] imm8 value, scaled by 4. 1016def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; } 1017def postidx_imm8s4 : MemOperand { 1018 let PrintMethod = "printPostIdxImm8s4Operand"; 1019 let ParserMatchClass = PostIdxImm8s4AsmOperand; 1020 let MIOperandInfo = (ops i32imm); 1021} 1022 1023 1024// postidx_reg := +/- reg 1025// 1026def PostIdxRegAsmOperand : AsmOperandClass { 1027 let Name = "PostIdxReg"; 1028 let ParserMethod = "parsePostIdxReg"; 1029} 1030def postidx_reg : MemOperand { 1031 let EncoderMethod = "getPostIdxRegOpValue"; 1032 let DecoderMethod = "DecodePostIdxReg"; 1033 let PrintMethod = "printPostIdxRegOperand"; 1034 let ParserMatchClass = PostIdxRegAsmOperand; 1035 let MIOperandInfo = (ops GPRnopc, i32imm); 1036} 1037 1038def PostIdxRegShiftedAsmOperand : AsmOperandClass { 1039 let Name = "PostIdxRegShifted"; 1040 let ParserMethod = "parsePostIdxReg"; 1041} 1042def am2offset_reg : MemOperand, 1043 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg", 1044 [], [SDNPWantRoot]> { 1045 let EncoderMethod = "getAddrMode2OffsetOpValue"; 1046 let PrintMethod = "printAddrMode2OffsetOperand"; 1047 // When using this for assembly, it's always as a post-index offset. 1048 let ParserMatchClass = PostIdxRegShiftedAsmOperand; 1049 let MIOperandInfo = (ops GPRnopc, i32imm); 1050} 1051 1052// FIXME: am2offset_imm should only need the immediate, not the GPR. Having 1053// the GPR is purely vestigal at this point. 1054def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; } 1055def am2offset_imm : MemOperand, 1056 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm", 1057 [], [SDNPWantRoot]> { 1058 let EncoderMethod = "getAddrMode2OffsetOpValue"; 1059 let PrintMethod = "printAddrMode2OffsetOperand"; 1060 let ParserMatchClass = AM2OffsetImmAsmOperand; 1061 let MIOperandInfo = (ops GPRnopc, i32imm); 1062} 1063 1064 1065// addrmode3 := reg +/- reg 1066// addrmode3 := reg +/- imm8 1067// 1068// FIXME: split into imm vs. reg versions. 1069def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; } 1070class AddrMode3 : MemOperand, 1071 ComplexPattern<i32, 3, "SelectAddrMode3", []> { 1072 let EncoderMethod = "getAddrMode3OpValue"; 1073 let ParserMatchClass = AddrMode3AsmOperand; 1074 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm); 1075} 1076 1077def addrmode3 : AddrMode3 1078{ 1079 let PrintMethod = "printAddrMode3Operand<false>"; 1080} 1081 1082def addrmode3_pre : AddrMode3 1083{ 1084 let PrintMethod = "printAddrMode3Operand<true>"; 1085} 1086 1087// FIXME: split into imm vs. reg versions. 1088// FIXME: parser method to handle +/- register. 1089def AM3OffsetAsmOperand : AsmOperandClass { 1090 let Name = "AM3Offset"; 1091 let ParserMethod = "parseAM3Offset"; 1092} 1093def am3offset : MemOperand, 1094 ComplexPattern<i32, 2, "SelectAddrMode3Offset", 1095 [], [SDNPWantRoot]> { 1096 let EncoderMethod = "getAddrMode3OffsetOpValue"; 1097 let PrintMethod = "printAddrMode3OffsetOperand"; 1098 let ParserMatchClass = AM3OffsetAsmOperand; 1099 let MIOperandInfo = (ops GPR, i32imm); 1100} 1101 1102// ldstm_mode := {ia, ib, da, db} 1103// 1104def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> { 1105 let EncoderMethod = "getLdStmModeOpValue"; 1106 let PrintMethod = "printLdStmModeOperand"; 1107} 1108 1109// addrmode5 := reg +/- imm8*4 1110// 1111def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; } 1112class AddrMode5 : MemOperand, 1113 ComplexPattern<i32, 2, "SelectAddrMode5", []> { 1114 let EncoderMethod = "getAddrMode5OpValue"; 1115 let DecoderMethod = "DecodeAddrMode5Operand"; 1116 let ParserMatchClass = AddrMode5AsmOperand; 1117 let MIOperandInfo = (ops GPR:$base, i32imm); 1118} 1119 1120def addrmode5 : AddrMode5 { 1121 let PrintMethod = "printAddrMode5Operand<false>"; 1122} 1123 1124def addrmode5_pre : AddrMode5 { 1125 let PrintMethod = "printAddrMode5Operand<true>"; 1126} 1127 1128// addrmode5fp16 := reg +/- imm8*2 1129// 1130def AddrMode5FP16AsmOperand : AsmOperandClass { let Name = "AddrMode5FP16"; } 1131class AddrMode5FP16 : Operand<i32>, 1132 ComplexPattern<i32, 2, "SelectAddrMode5FP16", []> { 1133 let EncoderMethod = "getAddrMode5FP16OpValue"; 1134 let DecoderMethod = "DecodeAddrMode5FP16Operand"; 1135 let ParserMatchClass = AddrMode5FP16AsmOperand; 1136 let MIOperandInfo = (ops GPR:$base, i32imm); 1137} 1138 1139def addrmode5fp16 : AddrMode5FP16 { 1140 let PrintMethod = "printAddrMode5FP16Operand<false>"; 1141} 1142 1143// addrmode6 := reg with optional alignment 1144// 1145def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; } 1146def addrmode6 : MemOperand, 1147 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{ 1148 let PrintMethod = "printAddrMode6Operand"; 1149 let MIOperandInfo = (ops GPR:$addr, i32imm:$align); 1150 let EncoderMethod = "getAddrMode6AddressOpValue"; 1151 let DecoderMethod = "DecodeAddrMode6Operand"; 1152 let ParserMatchClass = AddrMode6AsmOperand; 1153} 1154 1155def am6offset : MemOperand, 1156 ComplexPattern<i32, 1, "SelectAddrMode6Offset", 1157 [], [SDNPWantRoot]> { 1158 let PrintMethod = "printAddrMode6OffsetOperand"; 1159 let MIOperandInfo = (ops GPR); 1160 let EncoderMethod = "getAddrMode6OffsetOpValue"; 1161 let DecoderMethod = "DecodeGPRRegisterClass"; 1162} 1163 1164// Special version of addrmode6 to handle alignment encoding for VST1/VLD1 1165// (single element from one lane) for size 32. 1166def addrmode6oneL32 : MemOperand, 1167 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{ 1168 let PrintMethod = "printAddrMode6Operand"; 1169 let MIOperandInfo = (ops GPR:$addr, i32imm); 1170 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue"; 1171} 1172 1173// Base class for addrmode6 with specific alignment restrictions. 1174class AddrMode6Align : MemOperand, 1175 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{ 1176 let PrintMethod = "printAddrMode6Operand"; 1177 let MIOperandInfo = (ops GPR:$addr, i32imm:$align); 1178 let EncoderMethod = "getAddrMode6AddressOpValue"; 1179 let DecoderMethod = "DecodeAddrMode6Operand"; 1180} 1181 1182// Special version of addrmode6 to handle no allowed alignment encoding for 1183// VLD/VST instructions and checking the alignment is not specified. 1184def AddrMode6AlignNoneAsmOperand : AsmOperandClass { 1185 let Name = "AlignedMemoryNone"; 1186 let DiagnosticString = "alignment must be omitted"; 1187} 1188def addrmode6alignNone : AddrMode6Align { 1189 // The alignment specifier can only be omitted. 1190 let ParserMatchClass = AddrMode6AlignNoneAsmOperand; 1191} 1192 1193// Special version of addrmode6 to handle 16-bit alignment encoding for 1194// VLD/VST instructions and checking the alignment value. 1195def AddrMode6Align16AsmOperand : AsmOperandClass { 1196 let Name = "AlignedMemory16"; 1197 let DiagnosticString = "alignment must be 16 or omitted"; 1198} 1199def addrmode6align16 : AddrMode6Align { 1200 // The alignment specifier can only be 16 or omitted. 1201 let ParserMatchClass = AddrMode6Align16AsmOperand; 1202} 1203 1204// Special version of addrmode6 to handle 32-bit alignment encoding for 1205// VLD/VST instructions and checking the alignment value. 1206def AddrMode6Align32AsmOperand : AsmOperandClass { 1207 let Name = "AlignedMemory32"; 1208 let DiagnosticString = "alignment must be 32 or omitted"; 1209} 1210def addrmode6align32 : AddrMode6Align { 1211 // The alignment specifier can only be 32 or omitted. 1212 let ParserMatchClass = AddrMode6Align32AsmOperand; 1213} 1214 1215// Special version of addrmode6 to handle 64-bit alignment encoding for 1216// VLD/VST instructions and checking the alignment value. 1217def AddrMode6Align64AsmOperand : AsmOperandClass { 1218 let Name = "AlignedMemory64"; 1219 let DiagnosticString = "alignment must be 64 or omitted"; 1220} 1221def addrmode6align64 : AddrMode6Align { 1222 // The alignment specifier can only be 64 or omitted. 1223 let ParserMatchClass = AddrMode6Align64AsmOperand; 1224} 1225 1226// Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding 1227// for VLD/VST instructions and checking the alignment value. 1228def AddrMode6Align64or128AsmOperand : AsmOperandClass { 1229 let Name = "AlignedMemory64or128"; 1230 let DiagnosticString = "alignment must be 64, 128 or omitted"; 1231} 1232def addrmode6align64or128 : AddrMode6Align { 1233 // The alignment specifier can only be 64, 128 or omitted. 1234 let ParserMatchClass = AddrMode6Align64or128AsmOperand; 1235} 1236 1237// Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment 1238// encoding for VLD/VST instructions and checking the alignment value. 1239def AddrMode6Align64or128or256AsmOperand : AsmOperandClass { 1240 let Name = "AlignedMemory64or128or256"; 1241 let DiagnosticString = "alignment must be 64, 128, 256 or omitted"; 1242} 1243def addrmode6align64or128or256 : AddrMode6Align { 1244 // The alignment specifier can only be 64, 128, 256 or omitted. 1245 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand; 1246} 1247 1248// Special version of addrmode6 to handle alignment encoding for VLD-dup 1249// instructions, specifically VLD4-dup. 1250def addrmode6dup : MemOperand, 1251 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{ 1252 let PrintMethod = "printAddrMode6Operand"; 1253 let MIOperandInfo = (ops GPR:$addr, i32imm); 1254 let EncoderMethod = "getAddrMode6DupAddressOpValue"; 1255 // FIXME: This is close, but not quite right. The alignment specifier is 1256 // different. 1257 let ParserMatchClass = AddrMode6AsmOperand; 1258} 1259 1260// Base class for addrmode6dup with specific alignment restrictions. 1261class AddrMode6DupAlign : MemOperand, 1262 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{ 1263 let PrintMethod = "printAddrMode6Operand"; 1264 let MIOperandInfo = (ops GPR:$addr, i32imm); 1265 let EncoderMethod = "getAddrMode6DupAddressOpValue"; 1266} 1267 1268// Special version of addrmode6 to handle no allowed alignment encoding for 1269// VLD-dup instruction and checking the alignment is not specified. 1270def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass { 1271 let Name = "DupAlignedMemoryNone"; 1272 let DiagnosticString = "alignment must be omitted"; 1273} 1274def addrmode6dupalignNone : AddrMode6DupAlign { 1275 // The alignment specifier can only be omitted. 1276 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand; 1277} 1278 1279// Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup 1280// instruction and checking the alignment value. 1281def AddrMode6dupAlign16AsmOperand : AsmOperandClass { 1282 let Name = "DupAlignedMemory16"; 1283 let DiagnosticString = "alignment must be 16 or omitted"; 1284} 1285def addrmode6dupalign16 : AddrMode6DupAlign { 1286 // The alignment specifier can only be 16 or omitted. 1287 let ParserMatchClass = AddrMode6dupAlign16AsmOperand; 1288} 1289 1290// Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup 1291// instruction and checking the alignment value. 1292def AddrMode6dupAlign32AsmOperand : AsmOperandClass { 1293 let Name = "DupAlignedMemory32"; 1294 let DiagnosticString = "alignment must be 32 or omitted"; 1295} 1296def addrmode6dupalign32 : AddrMode6DupAlign { 1297 // The alignment specifier can only be 32 or omitted. 1298 let ParserMatchClass = AddrMode6dupAlign32AsmOperand; 1299} 1300 1301// Special version of addrmode6 to handle 64-bit alignment encoding for VLD 1302// instructions and checking the alignment value. 1303def AddrMode6dupAlign64AsmOperand : AsmOperandClass { 1304 let Name = "DupAlignedMemory64"; 1305 let DiagnosticString = "alignment must be 64 or omitted"; 1306} 1307def addrmode6dupalign64 : AddrMode6DupAlign { 1308 // The alignment specifier can only be 64 or omitted. 1309 let ParserMatchClass = AddrMode6dupAlign64AsmOperand; 1310} 1311 1312// Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding 1313// for VLD instructions and checking the alignment value. 1314def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass { 1315 let Name = "DupAlignedMemory64or128"; 1316 let DiagnosticString = "alignment must be 64, 128 or omitted"; 1317} 1318def addrmode6dupalign64or128 : AddrMode6DupAlign { 1319 // The alignment specifier can only be 64, 128 or omitted. 1320 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand; 1321} 1322 1323// addrmodepc := pc + reg 1324// 1325def addrmodepc : MemOperand, 1326 ComplexPattern<i32, 2, "SelectAddrModePC", []> { 1327 let PrintMethod = "printAddrModePCOperand"; 1328 let MIOperandInfo = (ops GPR, i32imm); 1329} 1330 1331// addr_offset_none := reg 1332// 1333def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; } 1334def addr_offset_none : MemOperand, 1335 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> { 1336 let PrintMethod = "printAddrMode7Operand"; 1337 let DecoderMethod = "DecodeAddrMode7Operand"; 1338 let ParserMatchClass = MemNoOffsetAsmOperand; 1339 let MIOperandInfo = (ops GPR:$base); 1340} 1341 1342// t_addr_offset_none := reg [r0-r7] 1343def MemNoOffsetTAsmOperand : AsmOperandClass { let Name = "MemNoOffsetT"; } 1344def t_addr_offset_none : MemOperand { 1345 let PrintMethod = "printAddrMode7Operand"; 1346 let DecoderMethod = "DecodetGPRRegisterClass"; 1347 let ParserMatchClass = MemNoOffsetTAsmOperand; 1348 let MIOperandInfo = (ops tGPR:$base); 1349} 1350 1351def nohash_imm : Operand<i32> { 1352 let PrintMethod = "printNoHashImmediate"; 1353} 1354 1355def CoprocNumAsmOperand : AsmOperandClass { 1356 let Name = "CoprocNum"; 1357 let ParserMethod = "parseCoprocNumOperand"; 1358} 1359def p_imm : Operand<i32> { 1360 let PrintMethod = "printPImmediate"; 1361 let ParserMatchClass = CoprocNumAsmOperand; 1362 let DecoderMethod = "DecodeCoprocessor"; 1363} 1364 1365def CoprocRegAsmOperand : AsmOperandClass { 1366 let Name = "CoprocReg"; 1367 let ParserMethod = "parseCoprocRegOperand"; 1368} 1369def c_imm : Operand<i32> { 1370 let PrintMethod = "printCImmediate"; 1371 let ParserMatchClass = CoprocRegAsmOperand; 1372} 1373def CoprocOptionAsmOperand : AsmOperandClass { 1374 let Name = "CoprocOption"; 1375 let ParserMethod = "parseCoprocOptionOperand"; 1376} 1377def coproc_option_imm : Operand<i32> { 1378 let PrintMethod = "printCoprocOptionImm"; 1379 let ParserMatchClass = CoprocOptionAsmOperand; 1380} 1381 1382//===----------------------------------------------------------------------===// 1383 1384include "ARMInstrFormats.td" 1385 1386//===----------------------------------------------------------------------===// 1387// Multiclass helpers... 1388// 1389 1390/// AsI1_bin_irs - Defines a set of (op r, {mod_imm|r|so_reg}) patterns for a 1391/// binop that produces a value. 1392let TwoOperandAliasConstraint = "$Rn = $Rd" in 1393multiclass AsI1_bin_irs<bits<4> opcod, string opc, 1394 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis, 1395 SDPatternOperator opnode, bit Commutable = 0> { 1396 // The register-immediate version is re-materializable. This is useful 1397 // in particular for taking the address of a local. 1398 let isReMaterializable = 1 in { 1399 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm, 1400 iii, opc, "\t$Rd, $Rn, $imm", 1401 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>, 1402 Sched<[WriteALU, ReadALU]> { 1403 bits<4> Rd; 1404 bits<4> Rn; 1405 bits<12> imm; 1406 let Inst{25} = 1; 1407 let Inst{19-16} = Rn; 1408 let Inst{15-12} = Rd; 1409 let Inst{11-0} = imm; 1410 } 1411 } 1412 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, 1413 iir, opc, "\t$Rd, $Rn, $Rm", 1414 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>, 1415 Sched<[WriteALU, ReadALU, ReadALU]> { 1416 bits<4> Rd; 1417 bits<4> Rn; 1418 bits<4> Rm; 1419 let Inst{25} = 0; 1420 let isCommutable = Commutable; 1421 let Inst{19-16} = Rn; 1422 let Inst{15-12} = Rd; 1423 let Inst{11-4} = 0b00000000; 1424 let Inst{3-0} = Rm; 1425 } 1426 1427 def rsi : AsI1<opcod, (outs GPR:$Rd), 1428 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, 1429 iis, opc, "\t$Rd, $Rn, $shift", 1430 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>, 1431 Sched<[WriteALUsi, ReadALU]> { 1432 bits<4> Rd; 1433 bits<4> Rn; 1434 bits<12> shift; 1435 let Inst{25} = 0; 1436 let Inst{19-16} = Rn; 1437 let Inst{15-12} = Rd; 1438 let Inst{11-5} = shift{11-5}; 1439 let Inst{4} = 0; 1440 let Inst{3-0} = shift{3-0}; 1441 } 1442 1443 def rsr : AsI1<opcod, (outs GPR:$Rd), 1444 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, 1445 iis, opc, "\t$Rd, $Rn, $shift", 1446 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>, 1447 Sched<[WriteALUsr, ReadALUsr]> { 1448 bits<4> Rd; 1449 bits<4> Rn; 1450 bits<12> shift; 1451 let Inst{25} = 0; 1452 let Inst{19-16} = Rn; 1453 let Inst{15-12} = Rd; 1454 let Inst{11-8} = shift{11-8}; 1455 let Inst{7} = 0; 1456 let Inst{6-5} = shift{6-5}; 1457 let Inst{4} = 1; 1458 let Inst{3-0} = shift{3-0}; 1459 } 1460} 1461 1462/// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are 1463/// reversed. The 'rr' form is only defined for the disassembler; for codegen 1464/// it is equivalent to the AsI1_bin_irs counterpart. 1465let TwoOperandAliasConstraint = "$Rn = $Rd" in 1466multiclass AsI1_rbin_irs<bits<4> opcod, string opc, 1467 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis, 1468 SDNode opnode, bit Commutable = 0> { 1469 // The register-immediate version is re-materializable. This is useful 1470 // in particular for taking the address of a local. 1471 let isReMaterializable = 1 in { 1472 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm, 1473 iii, opc, "\t$Rd, $Rn, $imm", 1474 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>, 1475 Sched<[WriteALU, ReadALU]> { 1476 bits<4> Rd; 1477 bits<4> Rn; 1478 bits<12> imm; 1479 let Inst{25} = 1; 1480 let Inst{19-16} = Rn; 1481 let Inst{15-12} = Rd; 1482 let Inst{11-0} = imm; 1483 } 1484 } 1485 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, 1486 iir, opc, "\t$Rd, $Rn, $Rm", 1487 [/* pattern left blank */]>, 1488 Sched<[WriteALU, ReadALU, ReadALU]> { 1489 bits<4> Rd; 1490 bits<4> Rn; 1491 bits<4> Rm; 1492 let Inst{11-4} = 0b00000000; 1493 let Inst{25} = 0; 1494 let Inst{3-0} = Rm; 1495 let Inst{15-12} = Rd; 1496 let Inst{19-16} = Rn; 1497 } 1498 1499 def rsi : AsI1<opcod, (outs GPR:$Rd), 1500 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, 1501 iis, opc, "\t$Rd, $Rn, $shift", 1502 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>, 1503 Sched<[WriteALUsi, ReadALU]> { 1504 bits<4> Rd; 1505 bits<4> Rn; 1506 bits<12> shift; 1507 let Inst{25} = 0; 1508 let Inst{19-16} = Rn; 1509 let Inst{15-12} = Rd; 1510 let Inst{11-5} = shift{11-5}; 1511 let Inst{4} = 0; 1512 let Inst{3-0} = shift{3-0}; 1513 } 1514 1515 def rsr : AsI1<opcod, (outs GPR:$Rd), 1516 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, 1517 iis, opc, "\t$Rd, $Rn, $shift", 1518 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>, 1519 Sched<[WriteALUsr, ReadALUsr]> { 1520 bits<4> Rd; 1521 bits<4> Rn; 1522 bits<12> shift; 1523 let Inst{25} = 0; 1524 let Inst{19-16} = Rn; 1525 let Inst{15-12} = Rd; 1526 let Inst{11-8} = shift{11-8}; 1527 let Inst{7} = 0; 1528 let Inst{6-5} = shift{6-5}; 1529 let Inst{4} = 1; 1530 let Inst{3-0} = shift{3-0}; 1531 } 1532} 1533 1534/// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default. 1535/// 1536/// These opcodes will be converted to the real non-S opcodes by 1537/// AdjustInstrPostInstrSelection after giving them an optional CPSR operand. 1538let hasPostISelHook = 1, Defs = [CPSR] in { 1539multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir, 1540 InstrItinClass iis, SDNode opnode, 1541 bit Commutable = 0> { 1542 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p), 1543 4, iii, 1544 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>, 1545 Sched<[WriteALU, ReadALU]>; 1546 1547 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p), 1548 4, iir, 1549 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>, 1550 Sched<[WriteALU, ReadALU, ReadALU]> { 1551 let isCommutable = Commutable; 1552 } 1553 def rsi : ARMPseudoInst<(outs GPR:$Rd), 1554 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p), 1555 4, iis, 1556 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, 1557 so_reg_imm:$shift))]>, 1558 Sched<[WriteALUsi, ReadALU]>; 1559 1560 def rsr : ARMPseudoInst<(outs GPR:$Rd), 1561 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p), 1562 4, iis, 1563 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, 1564 so_reg_reg:$shift))]>, 1565 Sched<[WriteALUSsr, ReadALUsr]>; 1566} 1567} 1568 1569/// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG 1570/// operands are reversed. 1571let hasPostISelHook = 1, Defs = [CPSR] in { 1572multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir, 1573 InstrItinClass iis, SDNode opnode, 1574 bit Commutable = 0> { 1575 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p), 1576 4, iii, 1577 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>, 1578 Sched<[WriteALU, ReadALU]>; 1579 1580 def rsi : ARMPseudoInst<(outs GPR:$Rd), 1581 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p), 1582 4, iis, 1583 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, 1584 GPR:$Rn))]>, 1585 Sched<[WriteALUsi, ReadALU]>; 1586 1587 def rsr : ARMPseudoInst<(outs GPR:$Rd), 1588 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p), 1589 4, iis, 1590 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, 1591 GPR:$Rn))]>, 1592 Sched<[WriteALUSsr, ReadALUsr]>; 1593} 1594} 1595 1596/// AI1_cmp_irs - Defines a set of (op r, {mod_imm|r|so_reg}) cmp / test 1597/// patterns. Similar to AsI1_bin_irs except the instruction does not produce 1598/// a explicit result, only implicitly set CPSR. 1599let isCompare = 1, Defs = [CPSR] in { 1600multiclass AI1_cmp_irs<bits<4> opcod, string opc, 1601 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis, 1602 SDPatternOperator opnode, bit Commutable = 0, 1603 string rrDecoderMethod = ""> { 1604 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii, 1605 opc, "\t$Rn, $imm", 1606 [(opnode GPR:$Rn, mod_imm:$imm)]>, 1607 Sched<[WriteCMP, ReadALU]> { 1608 bits<4> Rn; 1609 bits<12> imm; 1610 let Inst{25} = 1; 1611 let Inst{20} = 1; 1612 let Inst{19-16} = Rn; 1613 let Inst{15-12} = 0b0000; 1614 let Inst{11-0} = imm; 1615 1616 let Unpredictable{15-12} = 0b1111; 1617 } 1618 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir, 1619 opc, "\t$Rn, $Rm", 1620 [(opnode GPR:$Rn, GPR:$Rm)]>, 1621 Sched<[WriteCMP, ReadALU, ReadALU]> { 1622 bits<4> Rn; 1623 bits<4> Rm; 1624 let isCommutable = Commutable; 1625 let Inst{25} = 0; 1626 let Inst{20} = 1; 1627 let Inst{19-16} = Rn; 1628 let Inst{15-12} = 0b0000; 1629 let Inst{11-4} = 0b00000000; 1630 let Inst{3-0} = Rm; 1631 let DecoderMethod = rrDecoderMethod; 1632 1633 let Unpredictable{15-12} = 0b1111; 1634 } 1635 def rsi : AI1<opcod, (outs), 1636 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis, 1637 opc, "\t$Rn, $shift", 1638 [(opnode GPR:$Rn, so_reg_imm:$shift)]>, 1639 Sched<[WriteCMPsi, ReadALU]> { 1640 bits<4> Rn; 1641 bits<12> shift; 1642 let Inst{25} = 0; 1643 let Inst{20} = 1; 1644 let Inst{19-16} = Rn; 1645 let Inst{15-12} = 0b0000; 1646 let Inst{11-5} = shift{11-5}; 1647 let Inst{4} = 0; 1648 let Inst{3-0} = shift{3-0}; 1649 1650 let Unpredictable{15-12} = 0b1111; 1651 } 1652 def rsr : AI1<opcod, (outs), 1653 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis, 1654 opc, "\t$Rn, $shift", 1655 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>, 1656 Sched<[WriteCMPsr, ReadALU]> { 1657 bits<4> Rn; 1658 bits<12> shift; 1659 let Inst{25} = 0; 1660 let Inst{20} = 1; 1661 let Inst{19-16} = Rn; 1662 let Inst{15-12} = 0b0000; 1663 let Inst{11-8} = shift{11-8}; 1664 let Inst{7} = 0; 1665 let Inst{6-5} = shift{6-5}; 1666 let Inst{4} = 1; 1667 let Inst{3-0} = shift{3-0}; 1668 1669 let Unpredictable{15-12} = 0b1111; 1670 } 1671 1672} 1673} 1674 1675/// AI_ext_rrot - A unary operation with two forms: one whose operand is a 1676/// register and one whose operand is a register rotated by 8/16/24. 1677/// FIXME: Remove the 'r' variant. Its rot_imm is zero. 1678class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode> 1679 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot), 1680 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", 1681 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>, 1682 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> { 1683 bits<4> Rd; 1684 bits<4> Rm; 1685 bits<2> rot; 1686 let Inst{19-16} = 0b1111; 1687 let Inst{15-12} = Rd; 1688 let Inst{11-10} = rot; 1689 let Inst{3-0} = Rm; 1690} 1691 1692class AI_ext_rrot_np<bits<8> opcod, string opc> 1693 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot), 1694 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>, 1695 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> { 1696 bits<2> rot; 1697 let Inst{19-16} = 0b1111; 1698 let Inst{11-10} = rot; 1699 } 1700 1701/// AI_exta_rrot - A binary operation with two forms: one whose operand is a 1702/// register and one whose operand is a register rotated by 8/16/24. 1703class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode> 1704 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot), 1705 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", 1706 [(set GPRnopc:$Rd, (opnode GPR:$Rn, 1707 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>, 1708 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> { 1709 bits<4> Rd; 1710 bits<4> Rm; 1711 bits<4> Rn; 1712 bits<2> rot; 1713 let Inst{19-16} = Rn; 1714 let Inst{15-12} = Rd; 1715 let Inst{11-10} = rot; 1716 let Inst{9-4} = 0b000111; 1717 let Inst{3-0} = Rm; 1718} 1719 1720class AI_exta_rrot_np<bits<8> opcod, string opc> 1721 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot), 1722 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>, 1723 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> { 1724 bits<4> Rn; 1725 bits<2> rot; 1726 let Inst{19-16} = Rn; 1727 let Inst{11-10} = rot; 1728} 1729 1730/// AI1_adde_sube_irs - Define instructions and patterns for adde and sube. 1731let TwoOperandAliasConstraint = "$Rn = $Rd" in 1732multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, SDNode opnode, 1733 bit Commutable = 0> { 1734 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in { 1735 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), 1736 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm", 1737 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>, 1738 Requires<[IsARM]>, 1739 Sched<[WriteALU, ReadALU]> { 1740 bits<4> Rd; 1741 bits<4> Rn; 1742 bits<12> imm; 1743 let Inst{25} = 1; 1744 let Inst{15-12} = Rd; 1745 let Inst{19-16} = Rn; 1746 let Inst{11-0} = imm; 1747 } 1748 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), 1749 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm", 1750 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>, 1751 Requires<[IsARM]>, 1752 Sched<[WriteALU, ReadALU, ReadALU]> { 1753 bits<4> Rd; 1754 bits<4> Rn; 1755 bits<4> Rm; 1756 let Inst{11-4} = 0b00000000; 1757 let Inst{25} = 0; 1758 let isCommutable = Commutable; 1759 let Inst{3-0} = Rm; 1760 let Inst{15-12} = Rd; 1761 let Inst{19-16} = Rn; 1762 } 1763 def rsi : AsI1<opcod, (outs GPR:$Rd), 1764 (ins GPR:$Rn, so_reg_imm:$shift), 1765 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift", 1766 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>, 1767 Requires<[IsARM]>, 1768 Sched<[WriteALUsi, ReadALU]> { 1769 bits<4> Rd; 1770 bits<4> Rn; 1771 bits<12> shift; 1772 let Inst{25} = 0; 1773 let Inst{19-16} = Rn; 1774 let Inst{15-12} = Rd; 1775 let Inst{11-5} = shift{11-5}; 1776 let Inst{4} = 0; 1777 let Inst{3-0} = shift{3-0}; 1778 } 1779 def rsr : AsI1<opcod, (outs GPRnopc:$Rd), 1780 (ins GPRnopc:$Rn, so_reg_reg:$shift), 1781 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift", 1782 [(set GPRnopc:$Rd, CPSR, 1783 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>, 1784 Requires<[IsARM]>, 1785 Sched<[WriteALUsr, ReadALUsr]> { 1786 bits<4> Rd; 1787 bits<4> Rn; 1788 bits<12> shift; 1789 let Inst{25} = 0; 1790 let Inst{19-16} = Rn; 1791 let Inst{15-12} = Rd; 1792 let Inst{11-8} = shift{11-8}; 1793 let Inst{7} = 0; 1794 let Inst{6-5} = shift{6-5}; 1795 let Inst{4} = 1; 1796 let Inst{3-0} = shift{3-0}; 1797 } 1798 } 1799} 1800 1801/// AI1_rsc_irs - Define instructions and patterns for rsc 1802let TwoOperandAliasConstraint = "$Rn = $Rd" in 1803multiclass AI1_rsc_irs<bits<4> opcod, string opc, SDNode opnode> { 1804 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in { 1805 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), 1806 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm", 1807 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>, 1808 Requires<[IsARM]>, 1809 Sched<[WriteALU, ReadALU]> { 1810 bits<4> Rd; 1811 bits<4> Rn; 1812 bits<12> imm; 1813 let Inst{25} = 1; 1814 let Inst{15-12} = Rd; 1815 let Inst{19-16} = Rn; 1816 let Inst{11-0} = imm; 1817 } 1818 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), 1819 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm", 1820 [/* pattern left blank */]>, 1821 Sched<[WriteALU, ReadALU, ReadALU]> { 1822 bits<4> Rd; 1823 bits<4> Rn; 1824 bits<4> Rm; 1825 let Inst{11-4} = 0b00000000; 1826 let Inst{25} = 0; 1827 let Inst{3-0} = Rm; 1828 let Inst{15-12} = Rd; 1829 let Inst{19-16} = Rn; 1830 } 1831 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift), 1832 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift", 1833 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>, 1834 Requires<[IsARM]>, 1835 Sched<[WriteALUsi, ReadALU]> { 1836 bits<4> Rd; 1837 bits<4> Rn; 1838 bits<12> shift; 1839 let Inst{25} = 0; 1840 let Inst{19-16} = Rn; 1841 let Inst{15-12} = Rd; 1842 let Inst{11-5} = shift{11-5}; 1843 let Inst{4} = 0; 1844 let Inst{3-0} = shift{3-0}; 1845 } 1846 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift), 1847 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift", 1848 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>, 1849 Requires<[IsARM]>, 1850 Sched<[WriteALUsr, ReadALUsr]> { 1851 bits<4> Rd; 1852 bits<4> Rn; 1853 bits<12> shift; 1854 let Inst{25} = 0; 1855 let Inst{19-16} = Rn; 1856 let Inst{15-12} = Rd; 1857 let Inst{11-8} = shift{11-8}; 1858 let Inst{7} = 0; 1859 let Inst{6-5} = shift{6-5}; 1860 let Inst{4} = 1; 1861 let Inst{3-0} = shift{3-0}; 1862 } 1863 } 1864} 1865 1866let canFoldAsLoad = 1, isReMaterializable = 1 in { 1867multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii, 1868 InstrItinClass iir, PatFrag opnode> { 1869 // Note: We use the complex addrmode_imm12 rather than just an input 1870 // GPR and a constrained immediate so that we can use this to match 1871 // frame index references and avoid matching constant pool references. 1872 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr), 1873 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr", 1874 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> { 1875 bits<4> Rt; 1876 bits<17> addr; 1877 let Inst{23} = addr{12}; // U (add = ('U' == 1)) 1878 let Inst{19-16} = addr{16-13}; // Rn 1879 let Inst{15-12} = Rt; 1880 let Inst{11-0} = addr{11-0}; // imm12 1881 } 1882 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift), 1883 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift", 1884 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> { 1885 bits<4> Rt; 1886 bits<17> shift; 1887 let shift{4} = 0; // Inst{4} = 0 1888 let Inst{23} = shift{12}; // U (add = ('U' == 1)) 1889 let Inst{19-16} = shift{16-13}; // Rn 1890 let Inst{15-12} = Rt; 1891 let Inst{11-0} = shift{11-0}; 1892 } 1893} 1894} 1895 1896let canFoldAsLoad = 1, isReMaterializable = 1 in { 1897multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii, 1898 InstrItinClass iir, PatFrag opnode> { 1899 // Note: We use the complex addrmode_imm12 rather than just an input 1900 // GPR and a constrained immediate so that we can use this to match 1901 // frame index references and avoid matching constant pool references. 1902 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt), 1903 (ins addrmode_imm12:$addr), 1904 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr", 1905 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> { 1906 bits<4> Rt; 1907 bits<17> addr; 1908 let Inst{23} = addr{12}; // U (add = ('U' == 1)) 1909 let Inst{19-16} = addr{16-13}; // Rn 1910 let Inst{15-12} = Rt; 1911 let Inst{11-0} = addr{11-0}; // imm12 1912 } 1913 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt), 1914 (ins ldst_so_reg:$shift), 1915 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift", 1916 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> { 1917 bits<4> Rt; 1918 bits<17> shift; 1919 let shift{4} = 0; // Inst{4} = 0 1920 let Inst{23} = shift{12}; // U (add = ('U' == 1)) 1921 let Inst{19-16} = shift{16-13}; // Rn 1922 let Inst{15-12} = Rt; 1923 let Inst{11-0} = shift{11-0}; 1924 } 1925} 1926} 1927 1928 1929multiclass AI_str1<bit isByte, string opc, InstrItinClass iii, 1930 InstrItinClass iir, PatFrag opnode> { 1931 // Note: We use the complex addrmode_imm12 rather than just an input 1932 // GPR and a constrained immediate so that we can use this to match 1933 // frame index references and avoid matching constant pool references. 1934 def i12 : AI2ldst<0b010, 0, isByte, (outs), 1935 (ins GPR:$Rt, addrmode_imm12:$addr), 1936 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr", 1937 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> { 1938 bits<4> Rt; 1939 bits<17> addr; 1940 let Inst{23} = addr{12}; // U (add = ('U' == 1)) 1941 let Inst{19-16} = addr{16-13}; // Rn 1942 let Inst{15-12} = Rt; 1943 let Inst{11-0} = addr{11-0}; // imm12 1944 } 1945 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift), 1946 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift", 1947 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> { 1948 bits<4> Rt; 1949 bits<17> shift; 1950 let shift{4} = 0; // Inst{4} = 0 1951 let Inst{23} = shift{12}; // U (add = ('U' == 1)) 1952 let Inst{19-16} = shift{16-13}; // Rn 1953 let Inst{15-12} = Rt; 1954 let Inst{11-0} = shift{11-0}; 1955 } 1956} 1957 1958multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii, 1959 InstrItinClass iir, PatFrag opnode> { 1960 // Note: We use the complex addrmode_imm12 rather than just an input 1961 // GPR and a constrained immediate so that we can use this to match 1962 // frame index references and avoid matching constant pool references. 1963 def i12 : AI2ldst<0b010, 0, isByte, (outs), 1964 (ins GPRnopc:$Rt, addrmode_imm12:$addr), 1965 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr", 1966 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> { 1967 bits<4> Rt; 1968 bits<17> addr; 1969 let Inst{23} = addr{12}; // U (add = ('U' == 1)) 1970 let Inst{19-16} = addr{16-13}; // Rn 1971 let Inst{15-12} = Rt; 1972 let Inst{11-0} = addr{11-0}; // imm12 1973 } 1974 def rs : AI2ldst<0b011, 0, isByte, (outs), 1975 (ins GPRnopc:$Rt, ldst_so_reg:$shift), 1976 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift", 1977 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> { 1978 bits<4> Rt; 1979 bits<17> shift; 1980 let shift{4} = 0; // Inst{4} = 0 1981 let Inst{23} = shift{12}; // U (add = ('U' == 1)) 1982 let Inst{19-16} = shift{16-13}; // Rn 1983 let Inst{15-12} = Rt; 1984 let Inst{11-0} = shift{11-0}; 1985 } 1986} 1987 1988 1989//===----------------------------------------------------------------------===// 1990// Instructions 1991//===----------------------------------------------------------------------===// 1992 1993//===----------------------------------------------------------------------===// 1994// Miscellaneous Instructions. 1995// 1996 1997/// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in 1998/// the function. The first operand is the ID# for this instruction, the second 1999/// is the index into the MachineConstantPool that this is, the third is the 2000/// size in bytes of this constant pool entry. 2001let hasSideEffects = 0, isNotDuplicable = 1, hasNoSchedulingInfo = 1 in 2002def CONSTPOOL_ENTRY : 2003PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx, 2004 i32imm:$size), NoItinerary, []>; 2005 2006/// A jumptable consisting of direct 32-bit addresses of the destination basic 2007/// blocks (either absolute, or relative to the start of the jump-table in PIC 2008/// mode). Used mostly in ARM and Thumb-1 modes. 2009def JUMPTABLE_ADDRS : 2010PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx, 2011 i32imm:$size), NoItinerary, []>; 2012 2013/// A jumptable consisting of 32-bit jump instructions. Used for Thumb-2 tables 2014/// that cannot be optimised to use TBB or TBH. 2015def JUMPTABLE_INSTS : 2016PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx, 2017 i32imm:$size), NoItinerary, []>; 2018 2019/// A jumptable consisting of 8-bit unsigned integers representing offsets from 2020/// a TBB instruction. 2021def JUMPTABLE_TBB : 2022PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx, 2023 i32imm:$size), NoItinerary, []>; 2024 2025/// A jumptable consisting of 16-bit unsigned integers representing offsets from 2026/// a TBH instruction. 2027def JUMPTABLE_TBH : 2028PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx, 2029 i32imm:$size), NoItinerary, []>; 2030 2031 2032// FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE 2033// from removing one half of the matched pairs. That breaks PEI, which assumes 2034// these will always be in pairs, and asserts if it finds otherwise. Better way? 2035let Defs = [SP], Uses = [SP], hasSideEffects = 1 in { 2036def ADJCALLSTACKUP : 2037PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary, 2038 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>; 2039 2040def ADJCALLSTACKDOWN : 2041PseudoInst<(outs), (ins i32imm:$amt, i32imm:$amt2, pred:$p), NoItinerary, 2042 [(ARMcallseq_start timm:$amt, timm:$amt2)]>; 2043} 2044 2045def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary, 2046 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>, 2047 Requires<[IsARM, HasV6]> { 2048 bits<8> imm; 2049 let Inst{27-8} = 0b00110010000011110000; 2050 let Inst{7-0} = imm; 2051 let DecoderMethod = "DecodeHINTInstruction"; 2052} 2053 2054def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6K]>; 2055def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6K]>; 2056def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6K]>; 2057def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6K]>; 2058def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6K]>; 2059def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>; 2060def : InstAlias<"esb$p", (HINT 16, pred:$p)>, Requires<[IsARM, HasRAS]>; 2061def : InstAlias<"csdb$p", (HINT 20, pred:$p)>, Requires<[IsARM, HasV6K]>; 2062 2063def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel", 2064 "\t$Rd, $Rn, $Rm", 2065 [(set GPR:$Rd, (int_arm_sel GPR:$Rn, GPR:$Rm))]>, 2066 Requires<[IsARM, HasV6]> { 2067 bits<4> Rd; 2068 bits<4> Rn; 2069 bits<4> Rm; 2070 let Inst{3-0} = Rm; 2071 let Inst{15-12} = Rd; 2072 let Inst{19-16} = Rn; 2073 let Inst{27-20} = 0b01101000; 2074 let Inst{7-4} = 0b1011; 2075 let Inst{11-8} = 0b1111; 2076 let Unpredictable{11-8} = 0b1111; 2077} 2078 2079// The 16-bit operand $val can be used by a debugger to store more information 2080// about the breakpoint. 2081def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary, 2082 "bkpt", "\t$val", []>, Requires<[IsARM]> { 2083 bits<16> val; 2084 let Inst{3-0} = val{3-0}; 2085 let Inst{19-8} = val{15-4}; 2086 let Inst{27-20} = 0b00010010; 2087 let Inst{31-28} = 0xe; // AL 2088 let Inst{7-4} = 0b0111; 2089} 2090// default immediate for breakpoint mnemonic 2091def : InstAlias<"bkpt", (BKPT 0), 0>, Requires<[IsARM]>; 2092 2093def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary, 2094 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> { 2095 bits<16> val; 2096 let Inst{3-0} = val{3-0}; 2097 let Inst{19-8} = val{15-4}; 2098 let Inst{27-20} = 0b00010000; 2099 let Inst{31-28} = 0xe; // AL 2100 let Inst{7-4} = 0b0111; 2101} 2102 2103// Change Processor State 2104// FIXME: We should use InstAlias to handle the optional operands. 2105class CPS<dag iops, string asm_ops> 2106 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops), 2107 []>, Requires<[IsARM]> { 2108 bits<2> imod; 2109 bits<3> iflags; 2110 bits<5> mode; 2111 bit M; 2112 2113 let Inst{31-28} = 0b1111; 2114 let Inst{27-20} = 0b00010000; 2115 let Inst{19-18} = imod; 2116 let Inst{17} = M; // Enabled if mode is set; 2117 let Inst{16-9} = 0b00000000; 2118 let Inst{8-6} = iflags; 2119 let Inst{5} = 0; 2120 let Inst{4-0} = mode; 2121} 2122 2123let DecoderMethod = "DecodeCPSInstruction" in { 2124let M = 1 in 2125 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode), 2126 "$imod\t$iflags, $mode">; 2127let mode = 0, M = 0 in 2128 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">; 2129 2130let imod = 0, iflags = 0, M = 1 in 2131 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">; 2132} 2133 2134// Preload signals the memory system of possible future data/instruction access. 2135multiclass APreLoad<bits<1> read, bits<1> data, string opc> { 2136 2137 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm, 2138 IIC_Preload, !strconcat(opc, "\t$addr"), 2139 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>, 2140 Sched<[WritePreLd]> { 2141 bits<4> Rt; 2142 bits<17> addr; 2143 let Inst{31-26} = 0b111101; 2144 let Inst{25} = 0; // 0 for immediate form 2145 let Inst{24} = data; 2146 let Inst{23} = addr{12}; // U (add = ('U' == 1)) 2147 let Inst{22} = read; 2148 let Inst{21-20} = 0b01; 2149 let Inst{19-16} = addr{16-13}; // Rn 2150 let Inst{15-12} = 0b1111; 2151 let Inst{11-0} = addr{11-0}; // imm12 2152 } 2153 2154 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload, 2155 !strconcat(opc, "\t$shift"), 2156 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>, 2157 Sched<[WritePreLd]> { 2158 bits<17> shift; 2159 let Inst{31-26} = 0b111101; 2160 let Inst{25} = 1; // 1 for register form 2161 let Inst{24} = data; 2162 let Inst{23} = shift{12}; // U (add = ('U' == 1)) 2163 let Inst{22} = read; 2164 let Inst{21-20} = 0b01; 2165 let Inst{19-16} = shift{16-13}; // Rn 2166 let Inst{15-12} = 0b1111; 2167 let Inst{11-0} = shift{11-0}; 2168 let Inst{4} = 0; 2169 } 2170} 2171 2172defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>; 2173defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>; 2174defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>; 2175 2176def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary, 2177 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> { 2178 bits<1> end; 2179 let Inst{31-10} = 0b1111000100000001000000; 2180 let Inst{9} = end; 2181 let Inst{8-0} = 0; 2182} 2183 2184def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt", 2185 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> { 2186 bits<4> opt; 2187 let Inst{27-4} = 0b001100100000111100001111; 2188 let Inst{3-0} = opt; 2189} 2190 2191// A8.8.247 UDF - Undefined (Encoding A1) 2192def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary, 2193 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> { 2194 bits<16> imm16; 2195 let Inst{31-28} = 0b1110; // AL 2196 let Inst{27-25} = 0b011; 2197 let Inst{24-20} = 0b11111; 2198 let Inst{19-8} = imm16{15-4}; 2199 let Inst{7-4} = 0b1111; 2200 let Inst{3-0} = imm16{3-0}; 2201} 2202 2203/* 2204 * A5.4 Permanently UNDEFINED instructions. 2205 * 2206 * For most targets use UDF #65006, for which the OS will generate SIGTRAP. 2207 * Other UDF encodings generate SIGILL. 2208 * 2209 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb. 2210 * Encoding A1: 2211 * 1110 0111 1111 iiii iiii iiii 1111 iiii 2212 * Encoding T1: 2213 * 1101 1110 iiii iiii 2214 * It uses the following encoding: 2215 * 1110 0111 1111 1110 1101 1110 1111 0000 2216 * - In ARM: UDF #60896; 2217 * - In Thumb: UDF #254 followed by a branch-to-self. 2218 */ 2219let isBarrier = 1, isTerminator = 1 in 2220def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary, 2221 "trap", [(trap)]>, 2222 Requires<[IsARM,UseNaClTrap]> { 2223 let Inst = 0xe7fedef0; 2224} 2225let isBarrier = 1, isTerminator = 1 in 2226def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary, 2227 "trap", [(trap)]>, 2228 Requires<[IsARM,DontUseNaClTrap]> { 2229 let Inst = 0xe7ffdefe; 2230} 2231 2232def : Pat<(debugtrap), (BKPT 0)>, Requires<[IsARM, HasV5T]>; 2233def : Pat<(debugtrap), (UDF 254)>, Requires<[IsARM, NoV5T]>; 2234 2235// Address computation and loads and stores in PIC mode. 2236let isNotDuplicable = 1 in { 2237def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p), 2238 4, IIC_iALUr, 2239 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>, 2240 Sched<[WriteALU, ReadALU]>; 2241 2242let AddedComplexity = 10 in { 2243def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), 2244 4, IIC_iLoad_r, 2245 [(set GPR:$dst, (load addrmodepc:$addr))]>; 2246 2247def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p), 2248 4, IIC_iLoad_bh_r, 2249 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>; 2250 2251def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p), 2252 4, IIC_iLoad_bh_r, 2253 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>; 2254 2255def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p), 2256 4, IIC_iLoad_bh_r, 2257 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>; 2258 2259def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p), 2260 4, IIC_iLoad_bh_r, 2261 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>; 2262} 2263let AddedComplexity = 10 in { 2264def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p), 2265 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>; 2266 2267def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p), 2268 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src, 2269 addrmodepc:$addr)]>; 2270 2271def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p), 2272 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>; 2273} 2274} // isNotDuplicable = 1 2275 2276 2277// LEApcrel - Load a pc-relative address into a register without offending the 2278// assembler. 2279let hasSideEffects = 0, isReMaterializable = 1 in 2280// The 'adr' mnemonic encodes differently if the label is before or after 2281// the instruction. The {24-21} opcode bits are set by the fixup, as we don't 2282// know until then which form of the instruction will be used. 2283def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label), 2284 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>, 2285 Sched<[WriteALU, ReadALU]> { 2286 bits<4> Rd; 2287 bits<14> label; 2288 let Inst{27-25} = 0b001; 2289 let Inst{24} = 0; 2290 let Inst{23-22} = label{13-12}; 2291 let Inst{21} = 0; 2292 let Inst{20} = 0; 2293 let Inst{19-16} = 0b1111; 2294 let Inst{15-12} = Rd; 2295 let Inst{11-0} = label{11-0}; 2296} 2297 2298let hasSideEffects = 1 in { 2299def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p), 2300 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>; 2301 2302def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd), 2303 (ins i32imm:$label, pred:$p), 2304 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>; 2305} 2306 2307//===----------------------------------------------------------------------===// 2308// Control Flow Instructions. 2309// 2310 2311let isReturn = 1, isTerminator = 1, isBarrier = 1 in { 2312 // ARMV4T and above 2313 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br, 2314 "bx", "\tlr", [(ARMretflag)]>, 2315 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> { 2316 let Inst{27-0} = 0b0001001011111111111100011110; 2317 } 2318 2319 // ARMV4 only 2320 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br, 2321 "mov", "\tpc, lr", [(ARMretflag)]>, 2322 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> { 2323 let Inst{27-0} = 0b0001101000001111000000001110; 2324 } 2325 2326 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets 2327 // the user-space one). 2328 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p), 2329 4, IIC_Br, 2330 [(ARMintretflag imm:$offset)]>; 2331} 2332 2333// Indirect branches 2334let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in { 2335 // ARMV4T and above 2336 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst", 2337 [(brind GPR:$dst)]>, 2338 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> { 2339 bits<4> dst; 2340 let Inst{31-4} = 0b1110000100101111111111110001; 2341 let Inst{3-0} = dst; 2342 } 2343 2344 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, 2345 "bx", "\t$dst", [/* pattern left blank */]>, 2346 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> { 2347 bits<4> dst; 2348 let Inst{27-4} = 0b000100101111111111110001; 2349 let Inst{3-0} = dst; 2350 } 2351} 2352 2353// SP is marked as a use to prevent stack-pointer assignments that appear 2354// immediately before calls from potentially appearing dead. 2355let isCall = 1, 2356 // FIXME: Do we really need a non-predicated version? If so, it should 2357 // at least be a pseudo instruction expanding to the predicated version 2358 // at MC lowering time. 2359 Defs = [LR], Uses = [SP] in { 2360 def BL : ABXI<0b1011, (outs), (ins arm_bl_target:$func), 2361 IIC_Br, "bl\t$func", 2362 [(ARMcall tglobaladdr:$func)]>, 2363 Requires<[IsARM]>, Sched<[WriteBrL]> { 2364 let Inst{31-28} = 0b1110; 2365 bits<24> func; 2366 let Inst{23-0} = func; 2367 let DecoderMethod = "DecodeBranchImmInstruction"; 2368 } 2369 2370 def BL_pred : ABI<0b1011, (outs), (ins arm_bl_target:$func), 2371 IIC_Br, "bl", "\t$func", 2372 [(ARMcall_pred tglobaladdr:$func)]>, 2373 Requires<[IsARM]>, Sched<[WriteBrL]> { 2374 bits<24> func; 2375 let Inst{23-0} = func; 2376 let DecoderMethod = "DecodeBranchImmInstruction"; 2377 } 2378 2379 // ARMv5T and above 2380 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm, 2381 IIC_Br, "blx\t$func", 2382 [(ARMcall GPR:$func)]>, 2383 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> { 2384 bits<4> func; 2385 let Inst{31-4} = 0b1110000100101111111111110011; 2386 let Inst{3-0} = func; 2387 } 2388 2389 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm, 2390 IIC_Br, "blx", "\t$func", 2391 [(ARMcall_pred GPR:$func)]>, 2392 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> { 2393 bits<4> func; 2394 let Inst{27-4} = 0b000100101111111111110011; 2395 let Inst{3-0} = func; 2396 } 2397 2398 // ARMv4T 2399 // Note: Restrict $func to the tGPR regclass to prevent it being in LR. 2400 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func), 2401 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>, 2402 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>; 2403 2404 // ARMv4 2405 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func), 2406 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>, 2407 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>; 2408 2409 // mov lr, pc; b if callee is marked noreturn to avoid confusing the 2410 // return stack predictor. 2411 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins arm_bl_target:$func), 2412 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>, 2413 Requires<[IsARM]>, Sched<[WriteBr]>; 2414 2415 // push lr before the call 2416 def BL_PUSHLR : ARMPseudoInst<(outs), (ins GPRlr:$ra, arm_bl_target:$func), 2417 4, IIC_Br, 2418 []>, 2419 Requires<[IsARM]>, Sched<[WriteBr]>; 2420} 2421 2422let isBranch = 1, isTerminator = 1 in { 2423 // FIXME: should be able to write a pattern for ARMBrcond, but can't use 2424 // a two-value operand where a dag node expects two operands. :( 2425 def Bcc : ABI<0b1010, (outs), (ins arm_br_target:$target), 2426 IIC_Br, "b", "\t$target", 2427 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>, 2428 Sched<[WriteBr]> { 2429 bits<24> target; 2430 let Inst{23-0} = target; 2431 let DecoderMethod = "DecodeBranchImmInstruction"; 2432 } 2433 2434 let isBarrier = 1 in { 2435 // B is "predicable" since it's just a Bcc with an 'always' condition. 2436 let isPredicable = 1 in 2437 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly 2438 // should be sufficient. 2439 // FIXME: Is B really a Barrier? That doesn't seem right. 2440 def B : ARMPseudoExpand<(outs), (ins arm_br_target:$target), 4, IIC_Br, 2441 [(br bb:$target)], (Bcc arm_br_target:$target, 2442 (ops 14, zero_reg))>, 2443 Sched<[WriteBr]>; 2444 2445 let Size = 4, isNotDuplicable = 1, isIndirectBranch = 1 in { 2446 def BR_JTr : ARMPseudoInst<(outs), 2447 (ins GPR:$target, i32imm:$jt), 2448 0, IIC_Br, 2449 [(ARMbrjt GPR:$target, tjumptable:$jt)]>, 2450 Sched<[WriteBr]>; 2451 def BR_JTm_i12 : ARMPseudoInst<(outs), 2452 (ins addrmode_imm12:$target, i32imm:$jt), 2453 0, IIC_Br, 2454 [(ARMbrjt (i32 (load addrmode_imm12:$target)), 2455 tjumptable:$jt)]>, Sched<[WriteBrTbl]>; 2456 def BR_JTm_rs : ARMPseudoInst<(outs), 2457 (ins ldst_so_reg:$target, i32imm:$jt), 2458 0, IIC_Br, 2459 [(ARMbrjt (i32 (load ldst_so_reg:$target)), 2460 tjumptable:$jt)]>, Sched<[WriteBrTbl]>; 2461 def BR_JTadd : ARMPseudoInst<(outs), 2462 (ins GPR:$target, GPR:$idx, i32imm:$jt), 2463 0, IIC_Br, 2464 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt)]>, 2465 Sched<[WriteBrTbl]>; 2466 } // isNotDuplicable = 1, isIndirectBranch = 1 2467 } // isBarrier = 1 2468 2469} 2470 2471// BLX (immediate) 2472def BLXi : AXI<(outs), (ins arm_blx_target:$target), BrMiscFrm, NoItinerary, 2473 "blx\t$target", []>, 2474 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> { 2475 let Inst{31-25} = 0b1111101; 2476 bits<25> target; 2477 let Inst{23-0} = target{24-1}; 2478 let Inst{24} = target{0}; 2479 let isCall = 1; 2480} 2481 2482// Branch and Exchange Jazelle 2483def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func", 2484 [/* pattern left blank */]>, Sched<[WriteBr]> { 2485 bits<4> func; 2486 let Inst{23-20} = 0b0010; 2487 let Inst{19-8} = 0xfff; 2488 let Inst{7-4} = 0b0010; 2489 let Inst{3-0} = func; 2490 let isBranch = 1; 2491} 2492 2493// Tail calls. 2494 2495let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in { 2496 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>, 2497 Sched<[WriteBr]>; 2498 2499 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>, 2500 Sched<[WriteBr]>; 2501 2502 def TAILJMPd : ARMPseudoExpand<(outs), (ins arm_br_target:$dst), 2503 4, IIC_Br, [], 2504 (Bcc arm_br_target:$dst, (ops 14, zero_reg))>, 2505 Requires<[IsARM]>, Sched<[WriteBr]>; 2506 2507 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst), 2508 4, IIC_Br, [], 2509 (BX GPR:$dst)>, Sched<[WriteBr]>, 2510 Requires<[IsARM, HasV4T]>; 2511} 2512 2513// Secure Monitor Call is a system instruction. 2514def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt", 2515 []>, Requires<[IsARM, HasTrustZone]> { 2516 bits<4> opt; 2517 let Inst{23-4} = 0b01100000000000000111; 2518 let Inst{3-0} = opt; 2519} 2520def : MnemonicAlias<"smi", "smc">; 2521 2522// Supervisor Call (Software Interrupt) 2523let isCall = 1, Uses = [SP] in { 2524def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>, 2525 Sched<[WriteBr]> { 2526 bits<24> svc; 2527 let Inst{23-0} = svc; 2528} 2529} 2530 2531// Store Return State 2532class SRSI<bit wb, string asm> 2533 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm, 2534 NoItinerary, asm, "", []> { 2535 bits<5> mode; 2536 let Inst{31-28} = 0b1111; 2537 let Inst{27-25} = 0b100; 2538 let Inst{22} = 1; 2539 let Inst{21} = wb; 2540 let Inst{20} = 0; 2541 let Inst{19-16} = 0b1101; // SP 2542 let Inst{15-5} = 0b00000101000; 2543 let Inst{4-0} = mode; 2544} 2545 2546def SRSDA : SRSI<0, "srsda\tsp, $mode"> { 2547 let Inst{24-23} = 0; 2548} 2549def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> { 2550 let Inst{24-23} = 0; 2551} 2552def SRSDB : SRSI<0, "srsdb\tsp, $mode"> { 2553 let Inst{24-23} = 0b10; 2554} 2555def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> { 2556 let Inst{24-23} = 0b10; 2557} 2558def SRSIA : SRSI<0, "srsia\tsp, $mode"> { 2559 let Inst{24-23} = 0b01; 2560} 2561def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> { 2562 let Inst{24-23} = 0b01; 2563} 2564def SRSIB : SRSI<0, "srsib\tsp, $mode"> { 2565 let Inst{24-23} = 0b11; 2566} 2567def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> { 2568 let Inst{24-23} = 0b11; 2569} 2570 2571def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>; 2572def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>; 2573 2574def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>; 2575def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>; 2576 2577def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>; 2578def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>; 2579 2580def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>; 2581def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>; 2582 2583// Return From Exception 2584class RFEI<bit wb, string asm> 2585 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm, 2586 NoItinerary, asm, "", []> { 2587 bits<4> Rn; 2588 let Inst{31-28} = 0b1111; 2589 let Inst{27-25} = 0b100; 2590 let Inst{22} = 0; 2591 let Inst{21} = wb; 2592 let Inst{20} = 1; 2593 let Inst{19-16} = Rn; 2594 let Inst{15-0} = 0xa00; 2595} 2596 2597def RFEDA : RFEI<0, "rfeda\t$Rn"> { 2598 let Inst{24-23} = 0; 2599} 2600def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> { 2601 let Inst{24-23} = 0; 2602} 2603def RFEDB : RFEI<0, "rfedb\t$Rn"> { 2604 let Inst{24-23} = 0b10; 2605} 2606def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> { 2607 let Inst{24-23} = 0b10; 2608} 2609def RFEIA : RFEI<0, "rfeia\t$Rn"> { 2610 let Inst{24-23} = 0b01; 2611} 2612def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> { 2613 let Inst{24-23} = 0b01; 2614} 2615def RFEIB : RFEI<0, "rfeib\t$Rn"> { 2616 let Inst{24-23} = 0b11; 2617} 2618def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> { 2619 let Inst{24-23} = 0b11; 2620} 2621 2622// Hypervisor Call is a system instruction 2623let isCall = 1 in { 2624def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary, 2625 "hvc", "\t$imm", []>, 2626 Requires<[IsARM, HasVirtualization]> { 2627 bits<16> imm; 2628 2629 // Even though HVC isn't predicable, it's encoding includes a condition field. 2630 // The instruction is undefined if the condition field is 0xf otherwise it is 2631 // unpredictable if it isn't condition AL (0xe). 2632 let Inst{31-28} = 0b1110; 2633 let Unpredictable{31-28} = 0b1111; 2634 let Inst{27-24} = 0b0001; 2635 let Inst{23-20} = 0b0100; 2636 let Inst{19-8} = imm{15-4}; 2637 let Inst{7-4} = 0b0111; 2638 let Inst{3-0} = imm{3-0}; 2639} 2640} 2641 2642// Return from exception in Hypervisor mode. 2643let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in 2644def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>, 2645 Requires<[IsARM, HasVirtualization]> { 2646 let Inst{23-0} = 0b011000000000000001101110; 2647} 2648 2649//===----------------------------------------------------------------------===// 2650// Load / Store Instructions. 2651// 2652 2653// Load 2654 2655 2656defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si, load>; 2657defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si, 2658 zextloadi8>; 2659defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si, store>; 2660defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si, 2661 truncstorei8>; 2662 2663// Special LDR for loads from non-pc-relative constpools. 2664let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0, 2665 isReMaterializable = 1, isCodeGenOnly = 1 in 2666def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr), 2667 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr", 2668 []> { 2669 bits<4> Rt; 2670 bits<17> addr; 2671 let Inst{23} = addr{12}; // U (add = ('U' == 1)) 2672 let Inst{19-16} = 0b1111; 2673 let Inst{15-12} = Rt; 2674 let Inst{11-0} = addr{11-0}; // imm12 2675} 2676 2677// Loads with zero extension 2678def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm, 2679 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr", 2680 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>; 2681 2682// Loads with sign extension 2683def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm, 2684 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr", 2685 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>; 2686 2687def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm, 2688 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr", 2689 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>; 2690 2691let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in { 2692 // Load doubleword 2693 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr), 2694 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>, 2695 Requires<[IsARM, HasV5TE]>; 2696} 2697 2698def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr), 2699 NoItinerary, "lda", "\t$Rt, $addr", []>; 2700def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr), 2701 NoItinerary, "ldab", "\t$Rt, $addr", []>; 2702def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr), 2703 NoItinerary, "ldah", "\t$Rt, $addr", []>; 2704 2705// Indexed loads 2706multiclass AI2_ldridx<bit isByte, string opc, 2707 InstrItinClass iii, InstrItinClass iir> { 2708 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb), 2709 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii, 2710 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> { 2711 bits<17> addr; 2712 let Inst{25} = 0; 2713 let Inst{23} = addr{12}; 2714 let Inst{19-16} = addr{16-13}; 2715 let Inst{11-0} = addr{11-0}; 2716 let DecoderMethod = "DecodeLDRPreImm"; 2717 } 2718 2719 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb), 2720 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir, 2721 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> { 2722 bits<17> addr; 2723 let Inst{25} = 1; 2724 let Inst{23} = addr{12}; 2725 let Inst{19-16} = addr{16-13}; 2726 let Inst{11-0} = addr{11-0}; 2727 let Inst{4} = 0; 2728 let DecoderMethod = "DecodeLDRPreReg"; 2729 } 2730 2731 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb), 2732 (ins addr_offset_none:$addr, am2offset_reg:$offset), 2733 IndexModePost, LdFrm, iir, 2734 opc, "\t$Rt, $addr, $offset", 2735 "$addr.base = $Rn_wb", []> { 2736 // {12} isAdd 2737 // {11-0} imm12/Rm 2738 bits<14> offset; 2739 bits<4> addr; 2740 let Inst{25} = 1; 2741 let Inst{23} = offset{12}; 2742 let Inst{19-16} = addr; 2743 let Inst{11-0} = offset{11-0}; 2744 let Inst{4} = 0; 2745 2746 let DecoderMethod = "DecodeAddrMode2IdxInstruction"; 2747 } 2748 2749 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb), 2750 (ins addr_offset_none:$addr, am2offset_imm:$offset), 2751 IndexModePost, LdFrm, iii, 2752 opc, "\t$Rt, $addr, $offset", 2753 "$addr.base = $Rn_wb", []> { 2754 // {12} isAdd 2755 // {11-0} imm12/Rm 2756 bits<14> offset; 2757 bits<4> addr; 2758 let Inst{25} = 0; 2759 let Inst{23} = offset{12}; 2760 let Inst{19-16} = addr; 2761 let Inst{11-0} = offset{11-0}; 2762 2763 let DecoderMethod = "DecodeAddrMode2IdxInstruction"; 2764 } 2765 2766} 2767 2768let mayLoad = 1, hasSideEffects = 0 in { 2769// FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or 2770// IIC_iLoad_siu depending on whether it the offset register is shifted. 2771defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>; 2772defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>; 2773} 2774 2775multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> { 2776 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb), 2777 (ins addrmode3_pre:$addr), IndexModePre, 2778 LdMiscFrm, itin, 2779 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> { 2780 bits<14> addr; 2781 let Inst{23} = addr{8}; // U bit 2782 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm 2783 let Inst{19-16} = addr{12-9}; // Rn 2784 let Inst{11-8} = addr{7-4}; // imm7_4/zero 2785 let Inst{3-0} = addr{3-0}; // imm3_0/Rm 2786 let DecoderMethod = "DecodeAddrMode3Instruction"; 2787 } 2788 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb), 2789 (ins addr_offset_none:$addr, am3offset:$offset), 2790 IndexModePost, LdMiscFrm, itin, 2791 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", 2792 []> { 2793 bits<10> offset; 2794 bits<4> addr; 2795 let Inst{23} = offset{8}; // U bit 2796 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm 2797 let Inst{19-16} = addr; 2798 let Inst{11-8} = offset{7-4}; // imm7_4/zero 2799 let Inst{3-0} = offset{3-0}; // imm3_0/Rm 2800 let DecoderMethod = "DecodeAddrMode3Instruction"; 2801 } 2802} 2803 2804let mayLoad = 1, hasSideEffects = 0 in { 2805defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>; 2806defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>; 2807defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>; 2808let hasExtraDefRegAllocReq = 1 in { 2809def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb), 2810 (ins addrmode3_pre:$addr), IndexModePre, 2811 LdMiscFrm, IIC_iLoad_d_ru, 2812 "ldrd", "\t$Rt, $Rt2, $addr!", 2813 "$addr.base = $Rn_wb", []> { 2814 bits<14> addr; 2815 let Inst{23} = addr{8}; // U bit 2816 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm 2817 let Inst{19-16} = addr{12-9}; // Rn 2818 let Inst{11-8} = addr{7-4}; // imm7_4/zero 2819 let Inst{3-0} = addr{3-0}; // imm3_0/Rm 2820 let DecoderMethod = "DecodeAddrMode3Instruction"; 2821} 2822def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb), 2823 (ins addr_offset_none:$addr, am3offset:$offset), 2824 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru, 2825 "ldrd", "\t$Rt, $Rt2, $addr, $offset", 2826 "$addr.base = $Rn_wb", []> { 2827 bits<10> offset; 2828 bits<4> addr; 2829 let Inst{23} = offset{8}; // U bit 2830 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm 2831 let Inst{19-16} = addr; 2832 let Inst{11-8} = offset{7-4}; // imm7_4/zero 2833 let Inst{3-0} = offset{3-0}; // imm3_0/Rm 2834 let DecoderMethod = "DecodeAddrMode3Instruction"; 2835} 2836} // hasExtraDefRegAllocReq = 1 2837} // mayLoad = 1, hasSideEffects = 0 2838 2839// LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT. 2840let mayLoad = 1, hasSideEffects = 0 in { 2841def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb), 2842 (ins addr_offset_none:$addr, am2offset_reg:$offset), 2843 IndexModePost, LdFrm, IIC_iLoad_ru, 2844 "ldrt", "\t$Rt, $addr, $offset", 2845 "$addr.base = $Rn_wb", []> { 2846 // {12} isAdd 2847 // {11-0} imm12/Rm 2848 bits<14> offset; 2849 bits<4> addr; 2850 let Inst{25} = 1; 2851 let Inst{23} = offset{12}; 2852 let Inst{21} = 1; // overwrite 2853 let Inst{19-16} = addr; 2854 let Inst{11-5} = offset{11-5}; 2855 let Inst{4} = 0; 2856 let Inst{3-0} = offset{3-0}; 2857 let DecoderMethod = "DecodeAddrMode2IdxInstruction"; 2858} 2859 2860def LDRT_POST_IMM 2861 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb), 2862 (ins addr_offset_none:$addr, am2offset_imm:$offset), 2863 IndexModePost, LdFrm, IIC_iLoad_ru, 2864 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> { 2865 // {12} isAdd 2866 // {11-0} imm12/Rm 2867 bits<14> offset; 2868 bits<4> addr; 2869 let Inst{25} = 0; 2870 let Inst{23} = offset{12}; 2871 let Inst{21} = 1; // overwrite 2872 let Inst{19-16} = addr; 2873 let Inst{11-0} = offset{11-0}; 2874 let DecoderMethod = "DecodeAddrMode2IdxInstruction"; 2875} 2876 2877def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb), 2878 (ins addr_offset_none:$addr, am2offset_reg:$offset), 2879 IndexModePost, LdFrm, IIC_iLoad_bh_ru, 2880 "ldrbt", "\t$Rt, $addr, $offset", 2881 "$addr.base = $Rn_wb", []> { 2882 // {12} isAdd 2883 // {11-0} imm12/Rm 2884 bits<14> offset; 2885 bits<4> addr; 2886 let Inst{25} = 1; 2887 let Inst{23} = offset{12}; 2888 let Inst{21} = 1; // overwrite 2889 let Inst{19-16} = addr; 2890 let Inst{11-5} = offset{11-5}; 2891 let Inst{4} = 0; 2892 let Inst{3-0} = offset{3-0}; 2893 let DecoderMethod = "DecodeAddrMode2IdxInstruction"; 2894} 2895 2896def LDRBT_POST_IMM 2897 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb), 2898 (ins addr_offset_none:$addr, am2offset_imm:$offset), 2899 IndexModePost, LdFrm, IIC_iLoad_bh_ru, 2900 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> { 2901 // {12} isAdd 2902 // {11-0} imm12/Rm 2903 bits<14> offset; 2904 bits<4> addr; 2905 let Inst{25} = 0; 2906 let Inst{23} = offset{12}; 2907 let Inst{21} = 1; // overwrite 2908 let Inst{19-16} = addr; 2909 let Inst{11-0} = offset{11-0}; 2910 let DecoderMethod = "DecodeAddrMode2IdxInstruction"; 2911} 2912 2913multiclass AI3ldrT<bits<4> op, string opc> { 2914 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb), 2915 (ins addr_offset_none:$addr, postidx_imm8:$offset), 2916 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc, 2917 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> { 2918 bits<9> offset; 2919 let Inst{23} = offset{8}; 2920 let Inst{22} = 1; 2921 let Inst{11-8} = offset{7-4}; 2922 let Inst{3-0} = offset{3-0}; 2923 } 2924 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb), 2925 (ins addr_offset_none:$addr, postidx_reg:$Rm), 2926 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc, 2927 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> { 2928 bits<5> Rm; 2929 let Inst{23} = Rm{4}; 2930 let Inst{22} = 0; 2931 let Inst{11-8} = 0; 2932 let Unpredictable{11-8} = 0b1111; 2933 let Inst{3-0} = Rm{3-0}; 2934 let DecoderMethod = "DecodeLDR"; 2935 } 2936} 2937 2938defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">; 2939defm LDRHT : AI3ldrT<0b1011, "ldrht">; 2940defm LDRSHT : AI3ldrT<0b1111, "ldrsht">; 2941} 2942 2943def LDRT_POST 2944 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q), 2945 (outs GPR:$Rt)>; 2946 2947def LDRBT_POST 2948 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q), 2949 (outs GPR:$Rt)>; 2950 2951// Pseudo instruction ldr Rt, =immediate 2952def LDRConstPool 2953 : ARMAsmPseudo<"ldr${q} $Rt, $immediate", 2954 (ins const_pool_asm_imm:$immediate, pred:$q), 2955 (outs GPR:$Rt)>; 2956 2957// Store 2958 2959// Stores with truncate 2960def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm, 2961 IIC_iStore_bh_r, "strh", "\t$Rt, $addr", 2962 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>; 2963 2964// Store doubleword 2965let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in { 2966 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr), 2967 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>, 2968 Requires<[IsARM, HasV5TE]> { 2969 let Inst{21} = 0; 2970 } 2971} 2972 2973// Indexed stores 2974multiclass AI2_stridx<bit isByte, string opc, 2975 InstrItinClass iii, InstrItinClass iir> { 2976 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb), 2977 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre, 2978 StFrm, iii, 2979 opc, "\t$Rt, $addr!", 2980 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> { 2981 bits<17> addr; 2982 let Inst{25} = 0; 2983 let Inst{23} = addr{12}; // U (add = ('U' == 1)) 2984 let Inst{19-16} = addr{16-13}; // Rn 2985 let Inst{11-0} = addr{11-0}; // imm12 2986 let DecoderMethod = "DecodeSTRPreImm"; 2987 } 2988 2989 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb), 2990 (ins GPR:$Rt, ldst_so_reg:$addr), 2991 IndexModePre, StFrm, iir, 2992 opc, "\t$Rt, $addr!", 2993 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> { 2994 bits<17> addr; 2995 let Inst{25} = 1; 2996 let Inst{23} = addr{12}; // U (add = ('U' == 1)) 2997 let Inst{19-16} = addr{16-13}; // Rn 2998 let Inst{11-0} = addr{11-0}; 2999 let Inst{4} = 0; // Inst{4} = 0 3000 let DecoderMethod = "DecodeSTRPreReg"; 3001 } 3002 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb), 3003 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset), 3004 IndexModePost, StFrm, iir, 3005 opc, "\t$Rt, $addr, $offset", 3006 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> { 3007 // {12} isAdd 3008 // {11-0} imm12/Rm 3009 bits<14> offset; 3010 bits<4> addr; 3011 let Inst{25} = 1; 3012 let Inst{23} = offset{12}; 3013 let Inst{19-16} = addr; 3014 let Inst{11-0} = offset{11-0}; 3015 let Inst{4} = 0; 3016 3017 let DecoderMethod = "DecodeAddrMode2IdxInstruction"; 3018 } 3019 3020 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb), 3021 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset), 3022 IndexModePost, StFrm, iii, 3023 opc, "\t$Rt, $addr, $offset", 3024 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> { 3025 // {12} isAdd 3026 // {11-0} imm12/Rm 3027 bits<14> offset; 3028 bits<4> addr; 3029 let Inst{25} = 0; 3030 let Inst{23} = offset{12}; 3031 let Inst{19-16} = addr; 3032 let Inst{11-0} = offset{11-0}; 3033 3034 let DecoderMethod = "DecodeAddrMode2IdxInstruction"; 3035 } 3036} 3037 3038let mayStore = 1, hasSideEffects = 0 in { 3039// FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or 3040// IIC_iStore_siu depending on whether it the offset register is shifted. 3041defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>; 3042defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>; 3043} 3044 3045def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr, 3046 am2offset_reg:$offset), 3047 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr, 3048 am2offset_reg:$offset)>; 3049def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr, 3050 am2offset_imm:$offset), 3051 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr, 3052 am2offset_imm:$offset)>; 3053def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr, 3054 am2offset_reg:$offset), 3055 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr, 3056 am2offset_reg:$offset)>; 3057def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr, 3058 am2offset_imm:$offset), 3059 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr, 3060 am2offset_imm:$offset)>; 3061 3062// Pseudo-instructions for pattern matching the pre-indexed stores. We can't 3063// put the patterns on the instruction definitions directly as ISel wants 3064// the address base and offset to be separate operands, not a single 3065// complex operand like we represent the instructions themselves. The 3066// pseudos map between the two. 3067let usesCustomInserter = 1, 3068 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in { 3069def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb), 3070 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p), 3071 4, IIC_iStore_ru, 3072 [(set GPR:$Rn_wb, 3073 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>; 3074def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb), 3075 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p), 3076 4, IIC_iStore_ru, 3077 [(set GPR:$Rn_wb, 3078 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>; 3079def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb), 3080 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p), 3081 4, IIC_iStore_ru, 3082 [(set GPR:$Rn_wb, 3083 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>; 3084def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb), 3085 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p), 3086 4, IIC_iStore_ru, 3087 [(set GPR:$Rn_wb, 3088 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>; 3089def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb), 3090 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p), 3091 4, IIC_iStore_ru, 3092 [(set GPR:$Rn_wb, 3093 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>; 3094} 3095 3096 3097 3098def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb), 3099 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre, 3100 StMiscFrm, IIC_iStore_bh_ru, 3101 "strh", "\t$Rt, $addr!", 3102 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> { 3103 bits<14> addr; 3104 let Inst{23} = addr{8}; // U bit 3105 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm 3106 let Inst{19-16} = addr{12-9}; // Rn 3107 let Inst{11-8} = addr{7-4}; // imm7_4/zero 3108 let Inst{3-0} = addr{3-0}; // imm3_0/Rm 3109 let DecoderMethod = "DecodeAddrMode3Instruction"; 3110} 3111 3112def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb), 3113 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset), 3114 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, 3115 "strh", "\t$Rt, $addr, $offset", 3116 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", 3117 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt, 3118 addr_offset_none:$addr, 3119 am3offset:$offset))]> { 3120 bits<10> offset; 3121 bits<4> addr; 3122 let Inst{23} = offset{8}; // U bit 3123 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm 3124 let Inst{19-16} = addr; 3125 let Inst{11-8} = offset{7-4}; // imm7_4/zero 3126 let Inst{3-0} = offset{3-0}; // imm3_0/Rm 3127 let DecoderMethod = "DecodeAddrMode3Instruction"; 3128} 3129 3130let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in { 3131def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb), 3132 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr), 3133 IndexModePre, StMiscFrm, IIC_iStore_d_ru, 3134 "strd", "\t$Rt, $Rt2, $addr!", 3135 "$addr.base = $Rn_wb", []> { 3136 bits<14> addr; 3137 let Inst{23} = addr{8}; // U bit 3138 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm 3139 let Inst{19-16} = addr{12-9}; // Rn 3140 let Inst{11-8} = addr{7-4}; // imm7_4/zero 3141 let Inst{3-0} = addr{3-0}; // imm3_0/Rm 3142 let DecoderMethod = "DecodeAddrMode3Instruction"; 3143} 3144 3145def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb), 3146 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr, 3147 am3offset:$offset), 3148 IndexModePost, StMiscFrm, IIC_iStore_d_ru, 3149 "strd", "\t$Rt, $Rt2, $addr, $offset", 3150 "$addr.base = $Rn_wb", []> { 3151 bits<10> offset; 3152 bits<4> addr; 3153 let Inst{23} = offset{8}; // U bit 3154 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm 3155 let Inst{19-16} = addr; 3156 let Inst{11-8} = offset{7-4}; // imm7_4/zero 3157 let Inst{3-0} = offset{3-0}; // imm3_0/Rm 3158 let DecoderMethod = "DecodeAddrMode3Instruction"; 3159} 3160} // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 3161 3162// STRT, STRBT, and STRHT 3163 3164def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb), 3165 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset), 3166 IndexModePost, StFrm, IIC_iStore_bh_ru, 3167 "strbt", "\t$Rt, $addr, $offset", 3168 "$addr.base = $Rn_wb", []> { 3169 // {12} isAdd 3170 // {11-0} imm12/Rm 3171 bits<14> offset; 3172 bits<4> addr; 3173 let Inst{25} = 1; 3174 let Inst{23} = offset{12}; 3175 let Inst{21} = 1; // overwrite 3176 let Inst{19-16} = addr; 3177 let Inst{11-5} = offset{11-5}; 3178 let Inst{4} = 0; 3179 let Inst{3-0} = offset{3-0}; 3180 let DecoderMethod = "DecodeAddrMode2IdxInstruction"; 3181} 3182 3183def STRBT_POST_IMM 3184 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb), 3185 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset), 3186 IndexModePost, StFrm, IIC_iStore_bh_ru, 3187 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> { 3188 // {12} isAdd 3189 // {11-0} imm12/Rm 3190 bits<14> offset; 3191 bits<4> addr; 3192 let Inst{25} = 0; 3193 let Inst{23} = offset{12}; 3194 let Inst{21} = 1; // overwrite 3195 let Inst{19-16} = addr; 3196 let Inst{11-0} = offset{11-0}; 3197 let DecoderMethod = "DecodeAddrMode2IdxInstruction"; 3198} 3199 3200def STRBT_POST 3201 : ARMAsmPseudo<"strbt${q} $Rt, $addr", 3202 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>; 3203 3204let mayStore = 1, hasSideEffects = 0 in { 3205def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb), 3206 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset), 3207 IndexModePost, StFrm, IIC_iStore_ru, 3208 "strt", "\t$Rt, $addr, $offset", 3209 "$addr.base = $Rn_wb", []> { 3210 // {12} isAdd 3211 // {11-0} imm12/Rm 3212 bits<14> offset; 3213 bits<4> addr; 3214 let Inst{25} = 1; 3215 let Inst{23} = offset{12}; 3216 let Inst{21} = 1; // overwrite 3217 let Inst{19-16} = addr; 3218 let Inst{11-5} = offset{11-5}; 3219 let Inst{4} = 0; 3220 let Inst{3-0} = offset{3-0}; 3221 let DecoderMethod = "DecodeAddrMode2IdxInstruction"; 3222} 3223 3224def STRT_POST_IMM 3225 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb), 3226 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset), 3227 IndexModePost, StFrm, IIC_iStore_ru, 3228 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> { 3229 // {12} isAdd 3230 // {11-0} imm12/Rm 3231 bits<14> offset; 3232 bits<4> addr; 3233 let Inst{25} = 0; 3234 let Inst{23} = offset{12}; 3235 let Inst{21} = 1; // overwrite 3236 let Inst{19-16} = addr; 3237 let Inst{11-0} = offset{11-0}; 3238 let DecoderMethod = "DecodeAddrMode2IdxInstruction"; 3239} 3240} 3241 3242def STRT_POST 3243 : ARMAsmPseudo<"strt${q} $Rt, $addr", 3244 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>; 3245 3246multiclass AI3strT<bits<4> op, string opc> { 3247 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb), 3248 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset), 3249 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc, 3250 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> { 3251 bits<9> offset; 3252 let Inst{23} = offset{8}; 3253 let Inst{22} = 1; 3254 let Inst{11-8} = offset{7-4}; 3255 let Inst{3-0} = offset{3-0}; 3256 } 3257 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb), 3258 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm), 3259 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc, 3260 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> { 3261 bits<5> Rm; 3262 let Inst{23} = Rm{4}; 3263 let Inst{22} = 0; 3264 let Inst{11-8} = 0; 3265 let Inst{3-0} = Rm{3-0}; 3266 } 3267} 3268 3269 3270defm STRHT : AI3strT<0b1011, "strht">; 3271 3272def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr), 3273 NoItinerary, "stl", "\t$Rt, $addr", []>; 3274def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr), 3275 NoItinerary, "stlb", "\t$Rt, $addr", []>; 3276def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr), 3277 NoItinerary, "stlh", "\t$Rt, $addr", []>; 3278 3279//===----------------------------------------------------------------------===// 3280// Load / store multiple Instructions. 3281// 3282 3283multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f, 3284 InstrItinClass itin, InstrItinClass itin_upd> { 3285 // IA is the default, so no need for an explicit suffix on the 3286 // mnemonic here. Without it is the canonical spelling. 3287 def IA : 3288 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 3289 IndexModeNone, f, itin, 3290 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> { 3291 let Inst{24-23} = 0b01; // Increment After 3292 let Inst{22} = P_bit; 3293 let Inst{21} = 0; // No writeback 3294 let Inst{20} = L_bit; 3295 } 3296 def IA_UPD : 3297 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 3298 IndexModeUpd, f, itin_upd, 3299 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> { 3300 let Inst{24-23} = 0b01; // Increment After 3301 let Inst{22} = P_bit; 3302 let Inst{21} = 1; // Writeback 3303 let Inst{20} = L_bit; 3304 3305 let DecoderMethod = "DecodeMemMultipleWritebackInstruction"; 3306 } 3307 def DA : 3308 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 3309 IndexModeNone, f, itin, 3310 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> { 3311 let Inst{24-23} = 0b00; // Decrement After 3312 let Inst{22} = P_bit; 3313 let Inst{21} = 0; // No writeback 3314 let Inst{20} = L_bit; 3315 } 3316 def DA_UPD : 3317 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 3318 IndexModeUpd, f, itin_upd, 3319 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> { 3320 let Inst{24-23} = 0b00; // Decrement After 3321 let Inst{22} = P_bit; 3322 let Inst{21} = 1; // Writeback 3323 let Inst{20} = L_bit; 3324 3325 let DecoderMethod = "DecodeMemMultipleWritebackInstruction"; 3326 } 3327 def DB : 3328 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 3329 IndexModeNone, f, itin, 3330 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> { 3331 let Inst{24-23} = 0b10; // Decrement Before 3332 let Inst{22} = P_bit; 3333 let Inst{21} = 0; // No writeback 3334 let Inst{20} = L_bit; 3335 } 3336 def DB_UPD : 3337 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 3338 IndexModeUpd, f, itin_upd, 3339 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> { 3340 let Inst{24-23} = 0b10; // Decrement Before 3341 let Inst{22} = P_bit; 3342 let Inst{21} = 1; // Writeback 3343 let Inst{20} = L_bit; 3344 3345 let DecoderMethod = "DecodeMemMultipleWritebackInstruction"; 3346 } 3347 def IB : 3348 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 3349 IndexModeNone, f, itin, 3350 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> { 3351 let Inst{24-23} = 0b11; // Increment Before 3352 let Inst{22} = P_bit; 3353 let Inst{21} = 0; // No writeback 3354 let Inst{20} = L_bit; 3355 } 3356 def IB_UPD : 3357 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 3358 IndexModeUpd, f, itin_upd, 3359 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> { 3360 let Inst{24-23} = 0b11; // Increment Before 3361 let Inst{22} = P_bit; 3362 let Inst{21} = 1; // Writeback 3363 let Inst{20} = L_bit; 3364 3365 let DecoderMethod = "DecodeMemMultipleWritebackInstruction"; 3366 } 3367} 3368 3369let hasSideEffects = 0 in { 3370 3371let mayLoad = 1, hasExtraDefRegAllocReq = 1, variadicOpsAreDefs = 1 in 3372defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m, 3373 IIC_iLoad_mu>, ComplexDeprecationPredicate<"ARMLoad">; 3374 3375let mayStore = 1, hasExtraSrcRegAllocReq = 1 in 3376defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m, 3377 IIC_iStore_mu>, 3378 ComplexDeprecationPredicate<"ARMStore">; 3379 3380} // hasSideEffects 3381 3382// FIXME: remove when we have a way to marking a MI with these properties. 3383// FIXME: Should pc be an implicit operand like PICADD, etc? 3384let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1, 3385 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in 3386def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, 3387 reglist:$regs, variable_ops), 3388 4, IIC_iLoad_mBr, [], 3389 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>, 3390 RegConstraint<"$Rn = $wb">; 3391 3392let mayLoad = 1, hasExtraDefRegAllocReq = 1 in 3393defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m, 3394 IIC_iLoad_mu>; 3395 3396let mayStore = 1, hasExtraSrcRegAllocReq = 1 in 3397defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m, 3398 IIC_iStore_mu>; 3399 3400 3401 3402//===----------------------------------------------------------------------===// 3403// Move Instructions. 3404// 3405 3406let hasSideEffects = 0, isMoveReg = 1 in 3407def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr, 3408 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> { 3409 bits<4> Rd; 3410 bits<4> Rm; 3411 3412 let Inst{19-16} = 0b0000; 3413 let Inst{11-4} = 0b00000000; 3414 let Inst{25} = 0; 3415 let Inst{3-0} = Rm; 3416 let Inst{15-12} = Rd; 3417} 3418 3419// A version for the smaller set of tail call registers. 3420let hasSideEffects = 0 in 3421def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm, 3422 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> { 3423 bits<4> Rd; 3424 bits<4> Rm; 3425 3426 let Inst{11-4} = 0b00000000; 3427 let Inst{25} = 0; 3428 let Inst{3-0} = Rm; 3429 let Inst{15-12} = Rd; 3430} 3431 3432def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src), 3433 DPSoRegRegFrm, IIC_iMOVsr, 3434 "mov", "\t$Rd, $src", 3435 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP, 3436 Sched<[WriteALU]> { 3437 bits<4> Rd; 3438 bits<12> src; 3439 let Inst{15-12} = Rd; 3440 let Inst{19-16} = 0b0000; 3441 let Inst{11-8} = src{11-8}; 3442 let Inst{7} = 0; 3443 let Inst{6-5} = src{6-5}; 3444 let Inst{4} = 1; 3445 let Inst{3-0} = src{3-0}; 3446 let Inst{25} = 0; 3447} 3448 3449def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src), 3450 DPSoRegImmFrm, IIC_iMOVsr, 3451 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>, 3452 UnaryDP, Sched<[WriteALU]> { 3453 bits<4> Rd; 3454 bits<12> src; 3455 let Inst{15-12} = Rd; 3456 let Inst{19-16} = 0b0000; 3457 let Inst{11-5} = src{11-5}; 3458 let Inst{4} = 0; 3459 let Inst{3-0} = src{3-0}; 3460 let Inst{25} = 0; 3461} 3462 3463let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in 3464def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi, 3465 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP, 3466 Sched<[WriteALU]> { 3467 bits<4> Rd; 3468 bits<12> imm; 3469 let Inst{25} = 1; 3470 let Inst{15-12} = Rd; 3471 let Inst{19-16} = 0b0000; 3472 let Inst{11-0} = imm; 3473} 3474 3475let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in 3476def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm), 3477 DPFrm, IIC_iMOVi, 3478 "movw", "\t$Rd, $imm", 3479 [(set GPR:$Rd, imm0_65535:$imm)]>, 3480 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> { 3481 bits<4> Rd; 3482 bits<16> imm; 3483 let Inst{15-12} = Rd; 3484 let Inst{11-0} = imm{11-0}; 3485 let Inst{19-16} = imm{15-12}; 3486 let Inst{20} = 0; 3487 let Inst{25} = 1; 3488 let DecoderMethod = "DecodeArmMOVTWInstruction"; 3489} 3490 3491def : InstAlias<"mov${p} $Rd, $imm", 3492 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p), 0>, 3493 Requires<[IsARM, HasV6T2]>; 3494 3495def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd), 3496 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>, 3497 Sched<[WriteALU]>; 3498 3499let Constraints = "$src = $Rd" in { 3500def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd), 3501 (ins GPR:$src, imm0_65535_expr:$imm), 3502 DPFrm, IIC_iMOVi, 3503 "movt", "\t$Rd, $imm", 3504 [(set GPRnopc:$Rd, 3505 (or (and GPR:$src, 0xffff), 3506 lo16AllZero:$imm))]>, UnaryDP, 3507 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> { 3508 bits<4> Rd; 3509 bits<16> imm; 3510 let Inst{15-12} = Rd; 3511 let Inst{11-0} = imm{11-0}; 3512 let Inst{19-16} = imm{15-12}; 3513 let Inst{20} = 0; 3514 let Inst{25} = 1; 3515 let DecoderMethod = "DecodeArmMOVTWInstruction"; 3516} 3517 3518def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd), 3519 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>, 3520 Sched<[WriteALU]>; 3521 3522} // Constraints 3523 3524def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>, 3525 Requires<[IsARM, HasV6T2]>; 3526 3527let Uses = [CPSR] in 3528def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi, 3529 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP, 3530 Requires<[IsARM]>, Sched<[WriteALU]>; 3531 3532// These aren't really mov instructions, but we have to define them this way 3533// due to flag operands. 3534 3535let Defs = [CPSR] in { 3536def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi, 3537 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP, 3538 Sched<[WriteALU]>, Requires<[IsARM]>; 3539def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi, 3540 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP, 3541 Sched<[WriteALU]>, Requires<[IsARM]>; 3542} 3543 3544//===----------------------------------------------------------------------===// 3545// Extend Instructions. 3546// 3547 3548// Sign extenders 3549 3550def SXTB : AI_ext_rrot<0b01101010, 3551 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>; 3552def SXTH : AI_ext_rrot<0b01101011, 3553 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>; 3554 3555def SXTAB : AI_exta_rrot<0b01101010, 3556 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>; 3557def SXTAH : AI_exta_rrot<0b01101011, 3558 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>; 3559 3560def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, rot_imm:$rot), i8)), 3561 (SXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 3562def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, imm8_or_16:$rot), 3563 i16)), 3564 (SXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 3565 3566def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">; 3567def : ARMV6Pat<(int_arm_sxtb16 GPR:$Src), 3568 (SXTB16 GPR:$Src, 0)>; 3569def : ARMV6Pat<(int_arm_sxtb16 (rotr GPR:$Src, rot_imm:$rot)), 3570 (SXTB16 GPR:$Src, rot_imm:$rot)>; 3571 3572def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">; 3573def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, GPR:$RHS), 3574 (SXTAB16 GPR:$LHS, GPR:$RHS, 0)>; 3575def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)), 3576 (SXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>; 3577 3578// Zero extenders 3579 3580let AddedComplexity = 16 in { 3581def UXTB : AI_ext_rrot<0b01101110, 3582 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>; 3583def UXTH : AI_ext_rrot<0b01101111, 3584 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>; 3585def UXTB16 : AI_ext_rrot<0b01101100, 3586 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>; 3587 3588// FIXME: This pattern incorrectly assumes the shl operator is a rotate. 3589// The transformation should probably be done as a combiner action 3590// instead so we can include a check for masking back in the upper 3591// eight bits of the source into the lower eight bits of the result. 3592//def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF), 3593// (UXTB16r_rot GPR:$Src, 3)>; 3594def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF), 3595 (UXTB16 GPR:$Src, 1)>; 3596def : ARMV6Pat<(int_arm_uxtb16 GPR:$Src), 3597 (UXTB16 GPR:$Src, 0)>; 3598def : ARMV6Pat<(int_arm_uxtb16 (rotr GPR:$Src, rot_imm:$rot)), 3599 (UXTB16 GPR:$Src, rot_imm:$rot)>; 3600 3601def UXTAB : AI_exta_rrot<0b01101110, "uxtab", 3602 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>; 3603def UXTAH : AI_exta_rrot<0b01101111, "uxtah", 3604 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>; 3605 3606def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, rot_imm:$rot), 0xFF)), 3607 (UXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 3608def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, imm8_or_16:$rot), 0xFFFF)), 3609 (UXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 3610} 3611 3612// This isn't safe in general, the add is two 16-bit units, not a 32-bit add. 3613def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">; 3614def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, GPR:$RHS), 3615 (UXTAB16 GPR:$LHS, GPR:$RHS, 0)>; 3616def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)), 3617 (UXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>; 3618 3619 3620def SBFX : I<(outs GPRnopc:$Rd), 3621 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width), 3622 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi, 3623 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>, 3624 Requires<[IsARM, HasV6T2]> { 3625 bits<4> Rd; 3626 bits<4> Rn; 3627 bits<5> lsb; 3628 bits<5> width; 3629 let Inst{27-21} = 0b0111101; 3630 let Inst{6-4} = 0b101; 3631 let Inst{20-16} = width; 3632 let Inst{15-12} = Rd; 3633 let Inst{11-7} = lsb; 3634 let Inst{3-0} = Rn; 3635} 3636 3637def UBFX : I<(outs GPRnopc:$Rd), 3638 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width), 3639 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi, 3640 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>, 3641 Requires<[IsARM, HasV6T2]> { 3642 bits<4> Rd; 3643 bits<4> Rn; 3644 bits<5> lsb; 3645 bits<5> width; 3646 let Inst{27-21} = 0b0111111; 3647 let Inst{6-4} = 0b101; 3648 let Inst{20-16} = width; 3649 let Inst{15-12} = Rd; 3650 let Inst{11-7} = lsb; 3651 let Inst{3-0} = Rn; 3652} 3653 3654//===----------------------------------------------------------------------===// 3655// Arithmetic Instructions. 3656// 3657 3658let isAdd = 1 in 3659defm ADD : AsI1_bin_irs<0b0100, "add", 3660 IIC_iALUi, IIC_iALUr, IIC_iALUsr, add, 1>; 3661defm SUB : AsI1_bin_irs<0b0010, "sub", 3662 IIC_iALUi, IIC_iALUr, IIC_iALUsr, sub>; 3663 3664// ADD and SUB with 's' bit set. 3665// 3666// Currently, ADDS/SUBS are pseudo opcodes that exist only in the 3667// selection DAG. They are "lowered" to real ADD/SUB opcodes by 3668// AdjustInstrPostInstrSelection where we determine whether or not to 3669// set the "s" bit based on CPSR liveness. 3670// 3671// FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen 3672// support for an optional CPSR definition that corresponds to the DAG 3673// node's second value. We can then eliminate the implicit def of CPSR. 3674let isAdd = 1 in 3675defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMaddc, 1>; 3676defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>; 3677 3678def : ARMPat<(ARMsubs GPR:$Rn, mod_imm:$imm), (SUBSri $Rn, mod_imm:$imm)>; 3679def : ARMPat<(ARMsubs GPR:$Rn, GPR:$Rm), (SUBSrr $Rn, $Rm)>; 3680def : ARMPat<(ARMsubs GPR:$Rn, so_reg_imm:$shift), 3681 (SUBSrsi $Rn, so_reg_imm:$shift)>; 3682def : ARMPat<(ARMsubs GPR:$Rn, so_reg_reg:$shift), 3683 (SUBSrsr $Rn, so_reg_reg:$shift)>; 3684 3685 3686let isAdd = 1 in 3687defm ADC : AI1_adde_sube_irs<0b0101, "adc", ARMadde, 1>; 3688defm SBC : AI1_adde_sube_irs<0b0110, "sbc", ARMsube>; 3689 3690defm RSB : AsI1_rbin_irs<0b0011, "rsb", 3691 IIC_iALUi, IIC_iALUr, IIC_iALUsr, 3692 sub>; 3693 3694// FIXME: Eliminate them if we can write def : Pat patterns which defines 3695// CPSR and the implicit def of CPSR is not needed. 3696defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>; 3697 3698defm RSC : AI1_rsc_irs<0b0111, "rsc", ARMsube>; 3699 3700// (sub X, imm) gets canonicalized to (add X, -imm). Match this form. 3701// The assume-no-carry-in form uses the negation of the input since add/sub 3702// assume opposite meanings of the carry flag (i.e., carry == !borrow). 3703// See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory 3704// details. 3705def : ARMPat<(add GPR:$src, mod_imm_neg:$imm), 3706 (SUBri GPR:$src, mod_imm_neg:$imm)>; 3707def : ARMPat<(ARMaddc GPR:$src, mod_imm_neg:$imm), 3708 (SUBSri GPR:$src, mod_imm_neg:$imm)>; 3709 3710def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm), 3711 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>, 3712 Requires<[IsARM, HasV6T2]>; 3713def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm), 3714 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>, 3715 Requires<[IsARM, HasV6T2]>; 3716 3717// The with-carry-in form matches bitwise not instead of the negation. 3718// Effectively, the inverse interpretation of the carry flag already accounts 3719// for part of the negation. 3720def : ARMPat<(ARMadde GPR:$src, mod_imm_not:$imm, CPSR), 3721 (SBCri GPR:$src, mod_imm_not:$imm)>; 3722def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR), 3723 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>, 3724 Requires<[IsARM, HasV6T2]>; 3725 3726// Note: These are implemented in C++ code, because they have to generate 3727// ADD/SUBrs instructions, which use a complex pattern that a xform function 3728// cannot produce. 3729// (mul X, 2^n+1) -> (add (X << n), X) 3730// (mul X, 2^n-1) -> (rsb X, (X << n)) 3731 3732// ARM Arithmetic Instruction 3733// GPR:$dst = GPR:$a op GPR:$b 3734class AAI<bits<8> op27_20, bits<8> op11_4, string opc, 3735 list<dag> pattern = [], 3736 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm), 3737 string asm = "\t$Rd, $Rn, $Rm"> 3738 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>, 3739 Sched<[WriteALU, ReadALU, ReadALU]> { 3740 bits<4> Rn; 3741 bits<4> Rd; 3742 bits<4> Rm; 3743 let Inst{27-20} = op27_20; 3744 let Inst{11-4} = op11_4; 3745 let Inst{19-16} = Rn; 3746 let Inst{15-12} = Rd; 3747 let Inst{3-0} = Rm; 3748 3749 let Unpredictable{11-8} = 0b1111; 3750} 3751 3752// Wrappers around the AAI class 3753class AAIRevOpr<bits<8> op27_20, bits<8> op11_4, string opc, 3754 list<dag> pattern = []> 3755 : AAI<op27_20, op11_4, opc, 3756 pattern, 3757 (ins GPRnopc:$Rm, GPRnopc:$Rn), 3758 "\t$Rd, $Rm, $Rn">; 3759 3760class AAIIntrinsic<bits<8> op27_20, bits<8> op11_4, string opc, 3761 Intrinsic intrinsic> 3762 : AAI<op27_20, op11_4, opc, 3763 [(set GPRnopc:$Rd, (intrinsic GPRnopc:$Rn, GPRnopc:$Rm))]>; 3764 3765// Saturating add/subtract 3766let hasSideEffects = 1 in { 3767def QADD8 : AAIIntrinsic<0b01100010, 0b11111001, "qadd8", int_arm_qadd8>; 3768def QADD16 : AAIIntrinsic<0b01100010, 0b11110001, "qadd16", int_arm_qadd16>; 3769def QSUB16 : AAIIntrinsic<0b01100010, 0b11110111, "qsub16", int_arm_qsub16>; 3770def QSUB8 : AAIIntrinsic<0b01100010, 0b11111111, "qsub8", int_arm_qsub8>; 3771 3772def QDADD : AAIRevOpr<0b00010100, 0b00000101, "qdadd", 3773 [(set GPRnopc:$Rd, (int_arm_qadd (int_arm_qadd GPRnopc:$Rm, 3774 GPRnopc:$Rm), 3775 GPRnopc:$Rn))]>; 3776def QDSUB : AAIRevOpr<0b00010110, 0b00000101, "qdsub", 3777 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, 3778 (int_arm_qadd GPRnopc:$Rn, GPRnopc:$Rn)))]>; 3779def QSUB : AAIRevOpr<0b00010010, 0b00000101, "qsub", 3780 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))]>; 3781let DecoderMethod = "DecodeQADDInstruction" in 3782 def QADD : AAIRevOpr<0b00010000, 0b00000101, "qadd", 3783 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))]>; 3784} 3785 3786def : ARMV5TEPat<(saddsat GPR:$a, GPR:$b), 3787 (QADD GPR:$a, GPR:$b)>; 3788def : ARMV5TEPat<(ssubsat GPR:$a, GPR:$b), 3789 (QSUB GPR:$a, GPR:$b)>; 3790def : ARMV5TEPat<(saddsat(saddsat rGPR:$Rm, rGPR:$Rm), rGPR:$Rn), 3791 (QDADD rGPR:$Rm, rGPR:$Rn)>; 3792def : ARMV5TEPat<(ssubsat rGPR:$Rm, (saddsat rGPR:$Rn, rGPR:$Rn)), 3793 (QDSUB rGPR:$Rm, rGPR:$Rn)>; 3794def : ARMV6Pat<(ARMqadd8b rGPR:$Rm, rGPR:$Rn), 3795 (QADD8 rGPR:$Rm, rGPR:$Rn)>; 3796def : ARMV6Pat<(ARMqsub8b rGPR:$Rm, rGPR:$Rn), 3797 (QSUB8 rGPR:$Rm, rGPR:$Rn)>; 3798def : ARMV6Pat<(ARMqadd16b rGPR:$Rm, rGPR:$Rn), 3799 (QADD16 rGPR:$Rm, rGPR:$Rn)>; 3800def : ARMV6Pat<(ARMqsub16b rGPR:$Rm, rGPR:$Rn), 3801 (QSUB16 rGPR:$Rm, rGPR:$Rn)>; 3802 3803def UQADD16 : AAIIntrinsic<0b01100110, 0b11110001, "uqadd16", int_arm_uqadd16>; 3804def UQADD8 : AAIIntrinsic<0b01100110, 0b11111001, "uqadd8", int_arm_uqadd8>; 3805def UQSUB16 : AAIIntrinsic<0b01100110, 0b11110111, "uqsub16", int_arm_uqsub16>; 3806def UQSUB8 : AAIIntrinsic<0b01100110, 0b11111111, "uqsub8", int_arm_uqsub8>; 3807def QASX : AAIIntrinsic<0b01100010, 0b11110011, "qasx", int_arm_qasx>; 3808def QSAX : AAIIntrinsic<0b01100010, 0b11110101, "qsax", int_arm_qsax>; 3809def UQASX : AAIIntrinsic<0b01100110, 0b11110011, "uqasx", int_arm_uqasx>; 3810def UQSAX : AAIIntrinsic<0b01100110, 0b11110101, "uqsax", int_arm_uqsax>; 3811 3812// Signed/Unsigned add/subtract 3813 3814def SASX : AAIIntrinsic<0b01100001, 0b11110011, "sasx", int_arm_sasx>; 3815def SADD16 : AAIIntrinsic<0b01100001, 0b11110001, "sadd16", int_arm_sadd16>; 3816def SADD8 : AAIIntrinsic<0b01100001, 0b11111001, "sadd8", int_arm_sadd8>; 3817def SSAX : AAIIntrinsic<0b01100001, 0b11110101, "ssax", int_arm_ssax>; 3818def SSUB16 : AAIIntrinsic<0b01100001, 0b11110111, "ssub16", int_arm_ssub16>; 3819def SSUB8 : AAIIntrinsic<0b01100001, 0b11111111, "ssub8", int_arm_ssub8>; 3820def UASX : AAIIntrinsic<0b01100101, 0b11110011, "uasx", int_arm_uasx>; 3821def UADD16 : AAIIntrinsic<0b01100101, 0b11110001, "uadd16", int_arm_uadd16>; 3822def UADD8 : AAIIntrinsic<0b01100101, 0b11111001, "uadd8", int_arm_uadd8>; 3823def USAX : AAIIntrinsic<0b01100101, 0b11110101, "usax", int_arm_usax>; 3824def USUB16 : AAIIntrinsic<0b01100101, 0b11110111, "usub16", int_arm_usub16>; 3825def USUB8 : AAIIntrinsic<0b01100101, 0b11111111, "usub8", int_arm_usub8>; 3826 3827// Signed/Unsigned halving add/subtract 3828 3829def SHASX : AAIIntrinsic<0b01100011, 0b11110011, "shasx", int_arm_shasx>; 3830def SHADD16 : AAIIntrinsic<0b01100011, 0b11110001, "shadd16", int_arm_shadd16>; 3831def SHADD8 : AAIIntrinsic<0b01100011, 0b11111001, "shadd8", int_arm_shadd8>; 3832def SHSAX : AAIIntrinsic<0b01100011, 0b11110101, "shsax", int_arm_shsax>; 3833def SHSUB16 : AAIIntrinsic<0b01100011, 0b11110111, "shsub16", int_arm_shsub16>; 3834def SHSUB8 : AAIIntrinsic<0b01100011, 0b11111111, "shsub8", int_arm_shsub8>; 3835def UHASX : AAIIntrinsic<0b01100111, 0b11110011, "uhasx", int_arm_uhasx>; 3836def UHADD16 : AAIIntrinsic<0b01100111, 0b11110001, "uhadd16", int_arm_uhadd16>; 3837def UHADD8 : AAIIntrinsic<0b01100111, 0b11111001, "uhadd8", int_arm_uhadd8>; 3838def UHSAX : AAIIntrinsic<0b01100111, 0b11110101, "uhsax", int_arm_uhsax>; 3839def UHSUB16 : AAIIntrinsic<0b01100111, 0b11110111, "uhsub16", int_arm_uhsub16>; 3840def UHSUB8 : AAIIntrinsic<0b01100111, 0b11111111, "uhsub8", int_arm_uhsub8>; 3841 3842// Unsigned Sum of Absolute Differences [and Accumulate]. 3843 3844def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), 3845 MulFrm /* for convenience */, NoItinerary, "usad8", 3846 "\t$Rd, $Rn, $Rm", 3847 [(set GPR:$Rd, (int_arm_usad8 GPR:$Rn, GPR:$Rm))]>, 3848 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> { 3849 bits<4> Rd; 3850 bits<4> Rn; 3851 bits<4> Rm; 3852 let Inst{27-20} = 0b01111000; 3853 let Inst{15-12} = 0b1111; 3854 let Inst{7-4} = 0b0001; 3855 let Inst{19-16} = Rd; 3856 let Inst{11-8} = Rm; 3857 let Inst{3-0} = Rn; 3858} 3859def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), 3860 MulFrm /* for convenience */, NoItinerary, "usada8", 3861 "\t$Rd, $Rn, $Rm, $Ra", 3862 [(set GPR:$Rd, (int_arm_usada8 GPR:$Rn, GPR:$Rm, GPR:$Ra))]>, 3863 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{ 3864 bits<4> Rd; 3865 bits<4> Rn; 3866 bits<4> Rm; 3867 bits<4> Ra; 3868 let Inst{27-20} = 0b01111000; 3869 let Inst{7-4} = 0b0001; 3870 let Inst{19-16} = Rd; 3871 let Inst{15-12} = Ra; 3872 let Inst{11-8} = Rm; 3873 let Inst{3-0} = Rn; 3874} 3875 3876// Signed/Unsigned saturate 3877def SSAT : AI<(outs GPRnopc:$Rd), 3878 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh), 3879 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []>, 3880 Requires<[IsARM,HasV6]>{ 3881 bits<4> Rd; 3882 bits<5> sat_imm; 3883 bits<4> Rn; 3884 bits<8> sh; 3885 let Inst{27-21} = 0b0110101; 3886 let Inst{5-4} = 0b01; 3887 let Inst{20-16} = sat_imm; 3888 let Inst{15-12} = Rd; 3889 let Inst{11-7} = sh{4-0}; 3890 let Inst{6} = sh{5}; 3891 let Inst{3-0} = Rn; 3892} 3893 3894def SSAT16 : AI<(outs GPRnopc:$Rd), 3895 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm, 3896 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []>, 3897 Requires<[IsARM,HasV6]>{ 3898 bits<4> Rd; 3899 bits<4> sat_imm; 3900 bits<4> Rn; 3901 let Inst{27-20} = 0b01101010; 3902 let Inst{11-4} = 0b11110011; 3903 let Inst{15-12} = Rd; 3904 let Inst{19-16} = sat_imm; 3905 let Inst{3-0} = Rn; 3906} 3907 3908def USAT : AI<(outs GPRnopc:$Rd), 3909 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh), 3910 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []>, 3911 Requires<[IsARM,HasV6]> { 3912 bits<4> Rd; 3913 bits<5> sat_imm; 3914 bits<4> Rn; 3915 bits<8> sh; 3916 let Inst{27-21} = 0b0110111; 3917 let Inst{5-4} = 0b01; 3918 let Inst{15-12} = Rd; 3919 let Inst{11-7} = sh{4-0}; 3920 let Inst{6} = sh{5}; 3921 let Inst{20-16} = sat_imm; 3922 let Inst{3-0} = Rn; 3923} 3924 3925def USAT16 : AI<(outs GPRnopc:$Rd), 3926 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm, 3927 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []>, 3928 Requires<[IsARM,HasV6]>{ 3929 bits<4> Rd; 3930 bits<4> sat_imm; 3931 bits<4> Rn; 3932 let Inst{27-20} = 0b01101110; 3933 let Inst{11-4} = 0b11110011; 3934 let Inst{15-12} = Rd; 3935 let Inst{19-16} = sat_imm; 3936 let Inst{3-0} = Rn; 3937} 3938 3939def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm1_32:$pos), 3940 (SSAT imm1_32:$pos, GPRnopc:$a, 0)>; 3941def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm0_31:$pos), 3942 (USAT imm0_31:$pos, GPRnopc:$a, 0)>; 3943def : ARMPat<(ARMssatnoshift GPRnopc:$Rn, imm0_31:$imm), 3944 (SSAT imm0_31:$imm, GPRnopc:$Rn, 0)>; 3945def : ARMPat<(ARMusatnoshift GPRnopc:$Rn, imm0_31:$imm), 3946 (USAT imm0_31:$imm, GPRnopc:$Rn, 0)>; 3947def : ARMV6Pat<(int_arm_ssat16 GPRnopc:$a, imm1_16:$pos), 3948 (SSAT16 imm1_16:$pos, GPRnopc:$a)>; 3949def : ARMV6Pat<(int_arm_usat16 GPRnopc:$a, imm0_15:$pos), 3950 (USAT16 imm0_15:$pos, GPRnopc:$a)>; 3951 3952//===----------------------------------------------------------------------===// 3953// Bitwise Instructions. 3954// 3955 3956defm AND : AsI1_bin_irs<0b0000, "and", 3957 IIC_iBITi, IIC_iBITr, IIC_iBITsr, and, 1>; 3958defm ORR : AsI1_bin_irs<0b1100, "orr", 3959 IIC_iBITi, IIC_iBITr, IIC_iBITsr, or, 1>; 3960defm EOR : AsI1_bin_irs<0b0001, "eor", 3961 IIC_iBITi, IIC_iBITr, IIC_iBITsr, xor, 1>; 3962defm BIC : AsI1_bin_irs<0b1110, "bic", 3963 IIC_iBITi, IIC_iBITr, IIC_iBITsr, 3964 BinOpFrag<(and node:$LHS, (not node:$RHS))>>; 3965 3966// FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just 3967// like in the actual instruction encoding. The complexity of mapping the mask 3968// to the lsb/msb pair should be handled by ISel, not encapsulated in the 3969// instruction description. 3970def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm), 3971 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi, 3972 "bfc", "\t$Rd, $imm", "$src = $Rd", 3973 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>, 3974 Requires<[IsARM, HasV6T2]> { 3975 bits<4> Rd; 3976 bits<10> imm; 3977 let Inst{27-21} = 0b0111110; 3978 let Inst{6-0} = 0b0011111; 3979 let Inst{15-12} = Rd; 3980 let Inst{11-7} = imm{4-0}; // lsb 3981 let Inst{20-16} = imm{9-5}; // msb 3982} 3983 3984// A8.6.18 BFI - Bitfield insert (Encoding A1) 3985def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm), 3986 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi, 3987 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd", 3988 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn, 3989 bf_inv_mask_imm:$imm))]>, 3990 Requires<[IsARM, HasV6T2]> { 3991 bits<4> Rd; 3992 bits<4> Rn; 3993 bits<10> imm; 3994 let Inst{27-21} = 0b0111110; 3995 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15 3996 let Inst{15-12} = Rd; 3997 let Inst{11-7} = imm{4-0}; // lsb 3998 let Inst{20-16} = imm{9-5}; // width 3999 let Inst{3-0} = Rn; 4000} 4001 4002def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr, 4003 "mvn", "\t$Rd, $Rm", 4004 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> { 4005 bits<4> Rd; 4006 bits<4> Rm; 4007 let Inst{25} = 0; 4008 let Inst{19-16} = 0b0000; 4009 let Inst{11-4} = 0b00000000; 4010 let Inst{15-12} = Rd; 4011 let Inst{3-0} = Rm; 4012 4013 let Unpredictable{19-16} = 0b1111; 4014} 4015def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift), 4016 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift", 4017 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP, 4018 Sched<[WriteALU]> { 4019 bits<4> Rd; 4020 bits<12> shift; 4021 let Inst{25} = 0; 4022 let Inst{19-16} = 0b0000; 4023 let Inst{15-12} = Rd; 4024 let Inst{11-5} = shift{11-5}; 4025 let Inst{4} = 0; 4026 let Inst{3-0} = shift{3-0}; 4027 4028 let Unpredictable{19-16} = 0b1111; 4029} 4030def MVNsr : AsI1<0b1111, (outs GPRnopc:$Rd), (ins so_reg_reg:$shift), 4031 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift", 4032 [(set GPRnopc:$Rd, (not so_reg_reg:$shift))]>, UnaryDP, 4033 Sched<[WriteALU]> { 4034 bits<4> Rd; 4035 bits<12> shift; 4036 let Inst{25} = 0; 4037 let Inst{19-16} = 0b0000; 4038 let Inst{15-12} = Rd; 4039 let Inst{11-8} = shift{11-8}; 4040 let Inst{7} = 0; 4041 let Inst{6-5} = shift{6-5}; 4042 let Inst{4} = 1; 4043 let Inst{3-0} = shift{3-0}; 4044 4045 let Unpredictable{19-16} = 0b1111; 4046} 4047let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in 4048def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, 4049 IIC_iMVNi, "mvn", "\t$Rd, $imm", 4050 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> { 4051 bits<4> Rd; 4052 bits<12> imm; 4053 let Inst{25} = 1; 4054 let Inst{19-16} = 0b0000; 4055 let Inst{15-12} = Rd; 4056 let Inst{11-0} = imm; 4057} 4058 4059let AddedComplexity = 1 in 4060def : ARMPat<(and GPR:$src, mod_imm_not:$imm), 4061 (BICri GPR:$src, mod_imm_not:$imm)>; 4062 4063//===----------------------------------------------------------------------===// 4064// Multiply Instructions. 4065// 4066class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin, 4067 string opc, string asm, list<dag> pattern> 4068 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> { 4069 bits<4> Rd; 4070 bits<4> Rm; 4071 bits<4> Rn; 4072 let Inst{19-16} = Rd; 4073 let Inst{11-8} = Rm; 4074 let Inst{3-0} = Rn; 4075} 4076class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin, 4077 string opc, string asm, list<dag> pattern> 4078 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> { 4079 bits<4> RdLo; 4080 bits<4> RdHi; 4081 bits<4> Rm; 4082 bits<4> Rn; 4083 let Inst{19-16} = RdHi; 4084 let Inst{15-12} = RdLo; 4085 let Inst{11-8} = Rm; 4086 let Inst{3-0} = Rn; 4087} 4088class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin, 4089 string opc, string asm, list<dag> pattern> 4090 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> { 4091 bits<4> RdLo; 4092 bits<4> RdHi; 4093 bits<4> Rm; 4094 bits<4> Rn; 4095 let Inst{19-16} = RdHi; 4096 let Inst{15-12} = RdLo; 4097 let Inst{11-8} = Rm; 4098 let Inst{3-0} = Rn; 4099} 4100 4101// FIXME: The v5 pseudos are only necessary for the additional Constraint 4102// property. Remove them when it's possible to add those properties 4103// on an individual MachineInstr, not just an instruction description. 4104let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in { 4105def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd), 4106 (ins GPRnopc:$Rn, GPRnopc:$Rm), 4107 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm", 4108 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>, 4109 Requires<[IsARM, HasV6]>, 4110 Sched<[WriteMUL32, ReadMUL, ReadMUL]> { 4111 let Inst{15-12} = 0b0000; 4112 let Unpredictable{15-12} = 0b1111; 4113} 4114 4115let Constraints = "@earlyclobber $Rd" in 4116def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm, 4117 pred:$p, cc_out:$s), 4118 4, IIC_iMUL32, 4119 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))], 4120 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>, 4121 Requires<[IsARM, NoV6, UseMulOps]>, 4122 Sched<[WriteMUL32, ReadMUL, ReadMUL]>; 4123} 4124 4125def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd), 4126 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra), 4127 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra", 4128 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>, 4129 Requires<[IsARM, HasV6, UseMulOps]>, 4130 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> { 4131 bits<4> Ra; 4132 let Inst{15-12} = Ra; 4133} 4134 4135let Constraints = "@earlyclobber $Rd" in 4136def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd), 4137 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, 4138 pred:$p, cc_out:$s), 4, IIC_iMAC32, 4139 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))], 4140 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>, 4141 Requires<[IsARM, NoV6]>, 4142 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>; 4143 4144def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), 4145 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra", 4146 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>, 4147 Requires<[IsARM, HasV6T2, UseMulOps]>, 4148 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> { 4149 bits<4> Rd; 4150 bits<4> Rm; 4151 bits<4> Rn; 4152 bits<4> Ra; 4153 let Inst{19-16} = Rd; 4154 let Inst{15-12} = Ra; 4155 let Inst{11-8} = Rm; 4156 let Inst{3-0} = Rn; 4157} 4158 4159// Extra precision multiplies with low / high results 4160let hasSideEffects = 0 in { 4161let isCommutable = 1 in { 4162def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi), 4163 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64, 4164 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", 4165 [(set GPR:$RdLo, GPR:$RdHi, 4166 (smullohi GPR:$Rn, GPR:$Rm))]>, 4167 Requires<[IsARM, HasV6]>, 4168 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>; 4169 4170def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi), 4171 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64, 4172 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", 4173 [(set GPR:$RdLo, GPR:$RdHi, 4174 (umullohi GPR:$Rn, GPR:$Rm))]>, 4175 Requires<[IsARM, HasV6]>, 4176 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL]>; 4177 4178let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in { 4179def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi), 4180 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 4181 4, IIC_iMUL64, 4182 [(set GPR:$RdLo, GPR:$RdHi, 4183 (smullohi GPR:$Rn, GPR:$Rm))], 4184 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>, 4185 Requires<[IsARM, NoV6]>, 4186 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>; 4187 4188def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi), 4189 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 4190 4, IIC_iMUL64, 4191 [(set GPR:$RdLo, GPR:$RdHi, 4192 (umullohi GPR:$Rn, GPR:$Rm))], 4193 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>, 4194 Requires<[IsARM, NoV6]>, 4195 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>; 4196} 4197} 4198 4199// Multiply + accumulate 4200def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi), 4201 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64, 4202 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>, 4203 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>, 4204 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>; 4205def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi), 4206 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64, 4207 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>, 4208 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>, 4209 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>; 4210 4211def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi), 4212 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), 4213 IIC_iMAC64, 4214 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>, 4215 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>, 4216 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]> { 4217 bits<4> RdLo; 4218 bits<4> RdHi; 4219 bits<4> Rm; 4220 bits<4> Rn; 4221 let Inst{19-16} = RdHi; 4222 let Inst{15-12} = RdLo; 4223 let Inst{11-8} = Rm; 4224 let Inst{3-0} = Rn; 4225} 4226 4227let Constraints = 4228 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in { 4229def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi), 4230 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s), 4231 4, IIC_iMAC64, [], 4232 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, 4233 pred:$p, cc_out:$s)>, 4234 Requires<[IsARM, NoV6]>, 4235 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>; 4236def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi), 4237 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s), 4238 4, IIC_iMAC64, [], 4239 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, 4240 pred:$p, cc_out:$s)>, 4241 Requires<[IsARM, NoV6]>, 4242 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>; 4243} 4244 4245} // hasSideEffects 4246 4247// Most significant word multiply 4248def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), 4249 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm", 4250 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>, 4251 Requires<[IsARM, HasV6]>, 4252 Sched<[WriteMUL32, ReadMUL, ReadMUL]> { 4253 let Inst{15-12} = 0b1111; 4254} 4255 4256def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), 4257 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", 4258 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, (i32 0)))]>, 4259 Requires<[IsARM, HasV6]>, 4260 Sched<[WriteMUL32, ReadMUL, ReadMUL]> { 4261 let Inst{15-12} = 0b1111; 4262} 4263 4264def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd), 4265 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), 4266 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra", 4267 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>, 4268 Requires<[IsARM, HasV6, UseMulOps]>, 4269 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>; 4270 4271def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd), 4272 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), 4273 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", 4274 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, GPR:$Ra))]>, 4275 Requires<[IsARM, HasV6]>, 4276 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>; 4277 4278def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd), 4279 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), 4280 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>, 4281 Requires<[IsARM, HasV6, UseMulOps]>, 4282 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>; 4283 4284def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd), 4285 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), 4286 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", 4287 [(set GPR:$Rd, (ARMsmmlsr GPR:$Rn, GPR:$Rm, GPR:$Ra))]>, 4288 Requires<[IsARM, HasV6]>, 4289 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>; 4290 4291multiclass AI_smul<string opc> { 4292 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), 4293 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm", 4294 [(set GPR:$Rd, (bb_mul GPR:$Rn, GPR:$Rm))]>, 4295 Requires<[IsARM, HasV5TE]>, 4296 Sched<[WriteMUL16, ReadMUL, ReadMUL]>; 4297 4298 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), 4299 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm", 4300 [(set GPR:$Rd, (bt_mul GPR:$Rn, GPR:$Rm))]>, 4301 Requires<[IsARM, HasV5TE]>, 4302 Sched<[WriteMUL16, ReadMUL, ReadMUL]>; 4303 4304 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), 4305 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm", 4306 [(set GPR:$Rd, (tb_mul GPR:$Rn, GPR:$Rm))]>, 4307 Requires<[IsARM, HasV5TE]>, 4308 Sched<[WriteMUL16, ReadMUL, ReadMUL]>; 4309 4310 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), 4311 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm", 4312 [(set GPR:$Rd, (tt_mul GPR:$Rn, GPR:$Rm))]>, 4313 Requires<[IsARM, HasV5TE]>, 4314 Sched<[WriteMUL16, ReadMUL, ReadMUL]>; 4315 4316 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), 4317 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm", 4318 [(set GPR:$Rd, (ARMsmulwb GPR:$Rn, GPR:$Rm))]>, 4319 Requires<[IsARM, HasV5TE]>, 4320 Sched<[WriteMUL16, ReadMUL, ReadMUL]>; 4321 4322 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), 4323 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm", 4324 [(set GPR:$Rd, (ARMsmulwt GPR:$Rn, GPR:$Rm))]>, 4325 Requires<[IsARM, HasV5TE]>, 4326 Sched<[WriteMUL16, ReadMUL, ReadMUL]>; 4327} 4328 4329 4330multiclass AI_smla<string opc> { 4331 let DecoderMethod = "DecodeSMLAInstruction" in { 4332 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd), 4333 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra), 4334 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra", 4335 [(set GPRnopc:$Rd, (add GPR:$Ra, 4336 (bb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>, 4337 Requires<[IsARM, HasV5TE, UseMulOps]>, 4338 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>; 4339 4340 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd), 4341 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra), 4342 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra", 4343 [(set GPRnopc:$Rd, (add GPR:$Ra, 4344 (bt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>, 4345 Requires<[IsARM, HasV5TE, UseMulOps]>, 4346 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>; 4347 4348 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd), 4349 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra), 4350 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra", 4351 [(set GPRnopc:$Rd, (add GPR:$Ra, 4352 (tb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>, 4353 Requires<[IsARM, HasV5TE, UseMulOps]>, 4354 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>; 4355 4356 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd), 4357 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra), 4358 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra", 4359 [(set GPRnopc:$Rd, (add GPR:$Ra, 4360 (tt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>, 4361 Requires<[IsARM, HasV5TE, UseMulOps]>, 4362 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>; 4363 4364 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd), 4365 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra), 4366 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra", 4367 [(set GPRnopc:$Rd, 4368 (add GPR:$Ra, (ARMsmulwb GPRnopc:$Rn, GPRnopc:$Rm)))]>, 4369 Requires<[IsARM, HasV5TE, UseMulOps]>, 4370 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>; 4371 4372 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd), 4373 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra), 4374 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra", 4375 [(set GPRnopc:$Rd, 4376 (add GPR:$Ra, (ARMsmulwt GPRnopc:$Rn, GPRnopc:$Rm)))]>, 4377 Requires<[IsARM, HasV5TE, UseMulOps]>, 4378 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>; 4379 } 4380} 4381 4382defm SMUL : AI_smul<"smul">; 4383defm SMLA : AI_smla<"smla">; 4384 4385// Halfword multiply accumulate long: SMLAL<x><y>. 4386class SMLAL<bits<2> opc1, string asm> 4387 : AMulxyI64<0b0001010, opc1, 4388 (outs GPRnopc:$RdLo, GPRnopc:$RdHi), 4389 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi), 4390 IIC_iMAC64, asm, "\t$RdLo, $RdHi, $Rn, $Rm", []>, 4391 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, 4392 Requires<[IsARM, HasV5TE]>, 4393 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>; 4394 4395def SMLALBB : SMLAL<0b00, "smlalbb">; 4396def SMLALBT : SMLAL<0b10, "smlalbt">; 4397def SMLALTB : SMLAL<0b01, "smlaltb">; 4398def SMLALTT : SMLAL<0b11, "smlaltt">; 4399 4400def : ARMV5TEPat<(ARMsmlalbb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), 4401 (SMLALBB $Rn, $Rm, $RLo, $RHi)>; 4402def : ARMV5TEPat<(ARMsmlalbt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), 4403 (SMLALBT $Rn, $Rm, $RLo, $RHi)>; 4404def : ARMV5TEPat<(ARMsmlaltb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), 4405 (SMLALTB $Rn, $Rm, $RLo, $RHi)>; 4406def : ARMV5TEPat<(ARMsmlaltt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), 4407 (SMLALTT $Rn, $Rm, $RLo, $RHi)>; 4408 4409// Helper class for AI_smld. 4410class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops, 4411 InstrItinClass itin, string opc, string asm> 4412 : AI<oops, iops, MulFrm, itin, opc, asm, []>, 4413 Requires<[IsARM, HasV6]> { 4414 bits<4> Rn; 4415 bits<4> Rm; 4416 let Inst{27-23} = 0b01110; 4417 let Inst{22} = long; 4418 let Inst{21-20} = 0b00; 4419 let Inst{11-8} = Rm; 4420 let Inst{7} = 0; 4421 let Inst{6} = sub; 4422 let Inst{5} = swap; 4423 let Inst{4} = 1; 4424 let Inst{3-0} = Rn; 4425} 4426class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops, 4427 InstrItinClass itin, string opc, string asm> 4428 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> { 4429 bits<4> Rd; 4430 let Inst{15-12} = 0b1111; 4431 let Inst{19-16} = Rd; 4432} 4433class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops, 4434 InstrItinClass itin, string opc, string asm> 4435 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> { 4436 bits<4> Ra; 4437 bits<4> Rd; 4438 let Inst{19-16} = Rd; 4439 let Inst{15-12} = Ra; 4440} 4441class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops, 4442 InstrItinClass itin, string opc, string asm> 4443 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> { 4444 bits<4> RdLo; 4445 bits<4> RdHi; 4446 let Inst{19-16} = RdHi; 4447 let Inst{15-12} = RdLo; 4448} 4449 4450multiclass AI_smld<bit sub, string opc> { 4451 4452 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd), 4453 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra), 4454 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">, 4455 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>; 4456 4457 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd), 4458 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra), 4459 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">, 4460 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>; 4461 4462 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi), 4463 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi), 4464 NoItinerary, 4465 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">, 4466 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, 4467 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>; 4468 4469 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi), 4470 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi), 4471 NoItinerary, 4472 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">, 4473 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, 4474 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>; 4475} 4476 4477defm SMLA : AI_smld<0, "smla">; 4478defm SMLS : AI_smld<1, "smls">; 4479 4480def : ARMV6Pat<(int_arm_smlad GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra), 4481 (SMLAD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>; 4482def : ARMV6Pat<(int_arm_smladx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra), 4483 (SMLADX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>; 4484def : ARMV6Pat<(int_arm_smlsd GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra), 4485 (SMLSD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>; 4486def : ARMV6Pat<(int_arm_smlsdx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra), 4487 (SMLSDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>; 4488def : ARMV6Pat<(ARMSmlald GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi), 4489 (SMLALD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>; 4490def : ARMV6Pat<(ARMSmlaldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi), 4491 (SMLALDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>; 4492def : ARMV6Pat<(ARMSmlsld GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi), 4493 (SMLSLD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>; 4494def : ARMV6Pat<(ARMSmlsldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi), 4495 (SMLSLDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>; 4496 4497multiclass AI_sdml<bit sub, string opc> { 4498 4499 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), 4500 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">, 4501 Sched<[WriteMUL32, ReadMUL, ReadMUL]>; 4502 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm), 4503 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">, 4504 Sched<[WriteMUL32, ReadMUL, ReadMUL]>; 4505} 4506 4507defm SMUA : AI_sdml<0, "smua">; 4508defm SMUS : AI_sdml<1, "smus">; 4509 4510def : ARMV6Pat<(int_arm_smuad GPRnopc:$Rn, GPRnopc:$Rm), 4511 (SMUAD GPRnopc:$Rn, GPRnopc:$Rm)>; 4512def : ARMV6Pat<(int_arm_smuadx GPRnopc:$Rn, GPRnopc:$Rm), 4513 (SMUADX GPRnopc:$Rn, GPRnopc:$Rm)>; 4514def : ARMV6Pat<(int_arm_smusd GPRnopc:$Rn, GPRnopc:$Rm), 4515 (SMUSD GPRnopc:$Rn, GPRnopc:$Rm)>; 4516def : ARMV6Pat<(int_arm_smusdx GPRnopc:$Rn, GPRnopc:$Rm), 4517 (SMUSDX GPRnopc:$Rn, GPRnopc:$Rm)>; 4518 4519//===----------------------------------------------------------------------===// 4520// Division Instructions (ARMv7-A with virtualization extension) 4521// 4522def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV, 4523 "sdiv", "\t$Rd, $Rn, $Rm", 4524 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>, 4525 Requires<[IsARM, HasDivideInARM]>, 4526 Sched<[WriteDIV]>; 4527 4528def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV, 4529 "udiv", "\t$Rd, $Rn, $Rm", 4530 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>, 4531 Requires<[IsARM, HasDivideInARM]>, 4532 Sched<[WriteDIV]>; 4533 4534//===----------------------------------------------------------------------===// 4535// Misc. Arithmetic Instructions. 4536// 4537 4538def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm), 4539 IIC_iUNAr, "clz", "\t$Rd, $Rm", 4540 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>, 4541 Sched<[WriteALU]>; 4542 4543def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm), 4544 IIC_iUNAr, "rbit", "\t$Rd, $Rm", 4545 [(set GPR:$Rd, (bitreverse GPR:$Rm))]>, 4546 Requires<[IsARM, HasV6T2]>, 4547 Sched<[WriteALU]>; 4548 4549def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm), 4550 IIC_iUNAr, "rev", "\t$Rd, $Rm", 4551 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>, 4552 Sched<[WriteALU]>; 4553 4554let AddedComplexity = 5 in 4555def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm), 4556 IIC_iUNAr, "rev16", "\t$Rd, $Rm", 4557 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>, 4558 Requires<[IsARM, HasV6]>, 4559 Sched<[WriteALU]>; 4560 4561def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)), 4562 (REV16 (LDRH addrmode3:$addr))>; 4563def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr), 4564 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>; 4565 4566let AddedComplexity = 5 in 4567def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm), 4568 IIC_iUNAr, "revsh", "\t$Rd, $Rm", 4569 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>, 4570 Requires<[IsARM, HasV6]>, 4571 Sched<[WriteALU]>; 4572 4573def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)), 4574 (and (srl GPR:$Rm, (i32 8)), 0xFF)), 4575 (REVSH GPR:$Rm)>; 4576 4577def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd), 4578 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh), 4579 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh", 4580 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF), 4581 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh), 4582 0xFFFF0000)))]>, 4583 Requires<[IsARM, HasV6]>, 4584 Sched<[WriteALUsi, ReadALU]>; 4585 4586// Alternate cases for PKHBT where identities eliminate some nodes. 4587def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)), 4588 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>; 4589def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)), 4590 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>; 4591 4592// Note: Shifts of 1-15 bits will be transformed to srl instead of sra and 4593// will match the pattern below. 4594def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd), 4595 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh), 4596 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh", 4597 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000), 4598 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh), 4599 0xFFFF)))]>, 4600 Requires<[IsARM, HasV6]>, 4601 Sched<[WriteALUsi, ReadALU]>; 4602 4603// Alternate cases for PKHTB where identities eliminate some nodes. Note that 4604// a shift amount of 0 is *not legal* here, it is PKHBT instead. 4605// We also can not replace a srl (17..31) by an arithmetic shift we would use in 4606// pkhtb src1, src2, asr (17..31). 4607def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000), 4608 (srl GPRnopc:$src2, imm16:$sh)), 4609 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>; 4610def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000), 4611 (sra GPRnopc:$src2, imm16_31:$sh)), 4612 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>; 4613def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000), 4614 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)), 4615 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>; 4616 4617//===----------------------------------------------------------------------===// 4618// CRC Instructions 4619// 4620// Polynomials: 4621// + CRC32{B,H,W} 0x04C11DB7 4622// + CRC32C{B,H,W} 0x1EDC6F41 4623// 4624 4625class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin> 4626 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary, 4627 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm", 4628 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>, 4629 Requires<[IsARM, HasV8, HasCRC]> { 4630 bits<4> Rd; 4631 bits<4> Rn; 4632 bits<4> Rm; 4633 4634 let Inst{31-28} = 0b1110; 4635 let Inst{27-23} = 0b00010; 4636 let Inst{22-21} = sz; 4637 let Inst{20} = 0; 4638 let Inst{19-16} = Rn; 4639 let Inst{15-12} = Rd; 4640 let Inst{11-10} = 0b00; 4641 let Inst{9} = C; 4642 let Inst{8} = 0; 4643 let Inst{7-4} = 0b0100; 4644 let Inst{3-0} = Rm; 4645 4646 let Unpredictable{11-8} = 0b1101; 4647} 4648 4649def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>; 4650def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>; 4651def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>; 4652def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>; 4653def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>; 4654def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>; 4655 4656//===----------------------------------------------------------------------===// 4657// ARMv8.1a Privilege Access Never extension 4658// 4659// SETPAN #imm1 4660 4661def SETPAN : AInoP<(outs), (ins imm0_1:$imm), MiscFrm, NoItinerary, "setpan", 4662 "\t$imm", []>, Requires<[IsARM, HasV8, HasV8_1a]> { 4663 bits<1> imm; 4664 4665 let Inst{31-28} = 0b1111; 4666 let Inst{27-20} = 0b00010001; 4667 let Inst{19-16} = 0b0000; 4668 let Inst{15-10} = 0b000000; 4669 let Inst{9} = imm; 4670 let Inst{8} = 0b0; 4671 let Inst{7-4} = 0b0000; 4672 let Inst{3-0} = 0b0000; 4673 4674 let Unpredictable{19-16} = 0b1111; 4675 let Unpredictable{15-10} = 0b111111; 4676 let Unpredictable{8} = 0b1; 4677 let Unpredictable{3-0} = 0b1111; 4678} 4679 4680//===----------------------------------------------------------------------===// 4681// Comparison Instructions... 4682// 4683 4684defm CMP : AI1_cmp_irs<0b1010, "cmp", 4685 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, ARMcmp>; 4686 4687// ARMcmpZ can re-use the above instruction definitions. 4688def : ARMPat<(ARMcmpZ GPR:$src, mod_imm:$imm), 4689 (CMPri GPR:$src, mod_imm:$imm)>; 4690def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs), 4691 (CMPrr GPR:$src, GPR:$rhs)>; 4692def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs), 4693 (CMPrsi GPR:$src, so_reg_imm:$rhs)>; 4694def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs), 4695 (CMPrsr GPR:$src, so_reg_reg:$rhs)>; 4696 4697// CMN register-integer 4698let isCompare = 1, Defs = [CPSR] in { 4699def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi, 4700 "cmn", "\t$Rn, $imm", 4701 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>, 4702 Sched<[WriteCMP, ReadALU]> { 4703 bits<4> Rn; 4704 bits<12> imm; 4705 let Inst{25} = 1; 4706 let Inst{20} = 1; 4707 let Inst{19-16} = Rn; 4708 let Inst{15-12} = 0b0000; 4709 let Inst{11-0} = imm; 4710 4711 let Unpredictable{15-12} = 0b1111; 4712} 4713 4714// CMN register-register/shift 4715def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr, 4716 "cmn", "\t$Rn, $Rm", 4717 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))> 4718 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> { 4719 bits<4> Rn; 4720 bits<4> Rm; 4721 let isCommutable = 1; 4722 let Inst{25} = 0; 4723 let Inst{20} = 1; 4724 let Inst{19-16} = Rn; 4725 let Inst{15-12} = 0b0000; 4726 let Inst{11-4} = 0b00000000; 4727 let Inst{3-0} = Rm; 4728 4729 let Unpredictable{15-12} = 0b1111; 4730} 4731 4732def CMNzrsi : AI1<0b1011, (outs), 4733 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr, 4734 "cmn", "\t$Rn, $shift", 4735 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))> 4736 GPR:$Rn, so_reg_imm:$shift)]>, 4737 Sched<[WriteCMPsi, ReadALU]> { 4738 bits<4> Rn; 4739 bits<12> shift; 4740 let Inst{25} = 0; 4741 let Inst{20} = 1; 4742 let Inst{19-16} = Rn; 4743 let Inst{15-12} = 0b0000; 4744 let Inst{11-5} = shift{11-5}; 4745 let Inst{4} = 0; 4746 let Inst{3-0} = shift{3-0}; 4747 4748 let Unpredictable{15-12} = 0b1111; 4749} 4750 4751def CMNzrsr : AI1<0b1011, (outs), 4752 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr, 4753 "cmn", "\t$Rn, $shift", 4754 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))> 4755 GPRnopc:$Rn, so_reg_reg:$shift)]>, 4756 Sched<[WriteCMPsr, ReadALU]> { 4757 bits<4> Rn; 4758 bits<12> shift; 4759 let Inst{25} = 0; 4760 let Inst{20} = 1; 4761 let Inst{19-16} = Rn; 4762 let Inst{15-12} = 0b0000; 4763 let Inst{11-8} = shift{11-8}; 4764 let Inst{7} = 0; 4765 let Inst{6-5} = shift{6-5}; 4766 let Inst{4} = 1; 4767 let Inst{3-0} = shift{3-0}; 4768 4769 let Unpredictable{15-12} = 0b1111; 4770} 4771 4772} 4773 4774def : ARMPat<(ARMcmp GPR:$src, mod_imm_neg:$imm), 4775 (CMNri GPR:$src, mod_imm_neg:$imm)>; 4776 4777def : ARMPat<(ARMcmpZ GPR:$src, mod_imm_neg:$imm), 4778 (CMNri GPR:$src, mod_imm_neg:$imm)>; 4779 4780// Note that TST/TEQ don't set all the same flags that CMP does! 4781defm TST : AI1_cmp_irs<0b1000, "tst", 4782 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr, 4783 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1, 4784 "DecodeTSTInstruction">; 4785defm TEQ : AI1_cmp_irs<0b1001, "teq", 4786 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr, 4787 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>; 4788 4789// Pseudo i64 compares for some floating point compares. 4790let usesCustomInserter = 1, isBranch = 1, isTerminator = 1, 4791 Defs = [CPSR] in { 4792def BCCi64 : PseudoInst<(outs), 4793 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst), 4794 IIC_Br, 4795 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>, 4796 Sched<[WriteBr]>; 4797 4798def BCCZi64 : PseudoInst<(outs), 4799 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br, 4800 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>, 4801 Sched<[WriteBr]>; 4802} // usesCustomInserter 4803 4804 4805// Conditional moves 4806let hasSideEffects = 0 in { 4807 4808let isCommutable = 1, isSelect = 1 in 4809def MOVCCr : ARMPseudoInst<(outs GPR:$Rd), 4810 (ins GPR:$false, GPR:$Rm, cmovpred:$p), 4811 4, IIC_iCMOVr, 4812 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, 4813 cmovpred:$p))]>, 4814 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>; 4815 4816def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd), 4817 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p), 4818 4, IIC_iCMOVsr, 4819 [(set GPR:$Rd, 4820 (ARMcmov GPR:$false, so_reg_imm:$shift, 4821 cmovpred:$p))]>, 4822 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>; 4823def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd), 4824 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p), 4825 4, IIC_iCMOVsr, 4826 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift, 4827 cmovpred:$p))]>, 4828 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>; 4829 4830 4831let isMoveImm = 1 in 4832def MOVCCi16 4833 : ARMPseudoInst<(outs GPR:$Rd), 4834 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p), 4835 4, IIC_iMOVi, 4836 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm, 4837 cmovpred:$p))]>, 4838 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>, 4839 Sched<[WriteALU]>; 4840 4841let isMoveImm = 1 in 4842def MOVCCi : ARMPseudoInst<(outs GPR:$Rd), 4843 (ins GPR:$false, mod_imm:$imm, cmovpred:$p), 4844 4, IIC_iCMOVi, 4845 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm:$imm, 4846 cmovpred:$p))]>, 4847 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>; 4848 4849// Two instruction predicate mov immediate. 4850let isMoveImm = 1 in 4851def MOVCCi32imm 4852 : ARMPseudoInst<(outs GPR:$Rd), 4853 (ins GPR:$false, i32imm:$src, cmovpred:$p), 4854 8, IIC_iCMOVix2, 4855 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src, 4856 cmovpred:$p))]>, 4857 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>; 4858 4859let isMoveImm = 1 in 4860def MVNCCi : ARMPseudoInst<(outs GPR:$Rd), 4861 (ins GPR:$false, mod_imm:$imm, cmovpred:$p), 4862 4, IIC_iCMOVi, 4863 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm_not:$imm, 4864 cmovpred:$p))]>, 4865 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>; 4866 4867} // hasSideEffects 4868 4869 4870//===----------------------------------------------------------------------===// 4871// Atomic operations intrinsics 4872// 4873 4874def MemBarrierOptOperand : AsmOperandClass { 4875 let Name = "MemBarrierOpt"; 4876 let ParserMethod = "parseMemBarrierOptOperand"; 4877} 4878def memb_opt : Operand<i32> { 4879 let PrintMethod = "printMemBOption"; 4880 let ParserMatchClass = MemBarrierOptOperand; 4881 let DecoderMethod = "DecodeMemBarrierOption"; 4882} 4883 4884def InstSyncBarrierOptOperand : AsmOperandClass { 4885 let Name = "InstSyncBarrierOpt"; 4886 let ParserMethod = "parseInstSyncBarrierOptOperand"; 4887} 4888def instsyncb_opt : Operand<i32> { 4889 let PrintMethod = "printInstSyncBOption"; 4890 let ParserMatchClass = InstSyncBarrierOptOperand; 4891 let DecoderMethod = "DecodeInstSyncBarrierOption"; 4892} 4893 4894def TraceSyncBarrierOptOperand : AsmOperandClass { 4895 let Name = "TraceSyncBarrierOpt"; 4896 let ParserMethod = "parseTraceSyncBarrierOptOperand"; 4897} 4898def tsb_opt : Operand<i32> { 4899 let PrintMethod = "printTraceSyncBOption"; 4900 let ParserMatchClass = TraceSyncBarrierOptOperand; 4901} 4902 4903// Memory barriers protect the atomic sequences 4904let hasSideEffects = 1 in { 4905def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary, 4906 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>, 4907 Requires<[IsARM, HasDB]> { 4908 bits<4> opt; 4909 let Inst{31-4} = 0xf57ff05; 4910 let Inst{3-0} = opt; 4911} 4912 4913def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary, 4914 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>, 4915 Requires<[IsARM, HasDB]> { 4916 bits<4> opt; 4917 let Inst{31-4} = 0xf57ff04; 4918 let Inst{3-0} = opt; 4919} 4920 4921// ISB has only full system option 4922def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary, 4923 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>, 4924 Requires<[IsARM, HasDB]> { 4925 bits<4> opt; 4926 let Inst{31-4} = 0xf57ff06; 4927 let Inst{3-0} = opt; 4928} 4929 4930let hasNoSchedulingInfo = 1 in 4931def TSB : AInoP<(outs), (ins tsb_opt:$opt), MiscFrm, NoItinerary, 4932 "tsb", "\t$opt", []>, Requires<[IsARM, HasV8_4a]> { 4933 let Inst{31-0} = 0xe320f012; 4934} 4935 4936} 4937 4938// Armv8.5-A speculation barrier 4939def SB : AInoP<(outs), (ins), MiscFrm, NoItinerary, "sb", "", []>, 4940 Requires<[IsARM, HasSB]>, Sched<[]> { 4941 let Inst{31-0} = 0xf57ff070; 4942 let Unpredictable = 0x000fff0f; 4943 let hasSideEffects = 1; 4944} 4945 4946let usesCustomInserter = 1, Defs = [CPSR], hasNoSchedulingInfo = 1 in { 4947 // Pseudo instruction that combines movs + predicated rsbmi 4948 // to implement integer ABS 4949 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>; 4950} 4951 4952let usesCustomInserter = 1, Defs = [CPSR], hasNoSchedulingInfo = 1 in { 4953 def COPY_STRUCT_BYVAL_I32 : PseudoInst< 4954 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment), 4955 NoItinerary, 4956 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>; 4957} 4958 4959let hasPostISelHook = 1, Constraints = "$newdst = $dst, $newsrc = $src" in { 4960 // %newsrc, %newdst = MEMCPY %dst, %src, N, ...N scratch regs... 4961 // Copies N registers worth of memory from address %src to address %dst 4962 // and returns the incremented addresses. N scratch register will 4963 // be attached for the copy to use. 4964 def MEMCPY : PseudoInst< 4965 (outs GPR:$newdst, GPR:$newsrc), 4966 (ins GPR:$dst, GPR:$src, i32imm:$nreg, variable_ops), 4967 NoItinerary, 4968 [(set GPR:$newdst, GPR:$newsrc, 4969 (ARMmemcopy GPR:$dst, GPR:$src, imm:$nreg))]>; 4970} 4971 4972def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{ 4973 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8; 4974}]>; 4975 4976def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{ 4977 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16; 4978}]>; 4979 4980def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{ 4981 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32; 4982}]>; 4983 4984def strex_1 : PatFrag<(ops node:$val, node:$ptr), 4985 (int_arm_strex node:$val, node:$ptr), [{ 4986 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8; 4987}]>; 4988 4989def strex_2 : PatFrag<(ops node:$val, node:$ptr), 4990 (int_arm_strex node:$val, node:$ptr), [{ 4991 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16; 4992}]>; 4993 4994def strex_4 : PatFrag<(ops node:$val, node:$ptr), 4995 (int_arm_strex node:$val, node:$ptr), [{ 4996 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32; 4997}]>; 4998 4999def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{ 5000 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8; 5001}]>; 5002 5003def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{ 5004 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16; 5005}]>; 5006 5007def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{ 5008 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32; 5009}]>; 5010 5011def stlex_1 : PatFrag<(ops node:$val, node:$ptr), 5012 (int_arm_stlex node:$val, node:$ptr), [{ 5013 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8; 5014}]>; 5015 5016def stlex_2 : PatFrag<(ops node:$val, node:$ptr), 5017 (int_arm_stlex node:$val, node:$ptr), [{ 5018 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16; 5019}]>; 5020 5021def stlex_4 : PatFrag<(ops node:$val, node:$ptr), 5022 (int_arm_stlex node:$val, node:$ptr), [{ 5023 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32; 5024}]>; 5025 5026let mayLoad = 1 in { 5027def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr), 5028 NoItinerary, "ldrexb", "\t$Rt, $addr", 5029 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>; 5030def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr), 5031 NoItinerary, "ldrexh", "\t$Rt, $addr", 5032 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>; 5033def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr), 5034 NoItinerary, "ldrex", "\t$Rt, $addr", 5035 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>; 5036let hasExtraDefRegAllocReq = 1 in 5037def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr), 5038 NoItinerary, "ldrexd", "\t$Rt, $addr", []> { 5039 let DecoderMethod = "DecodeDoubleRegLoad"; 5040} 5041 5042def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr), 5043 NoItinerary, "ldaexb", "\t$Rt, $addr", 5044 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>; 5045def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr), 5046 NoItinerary, "ldaexh", "\t$Rt, $addr", 5047 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>; 5048def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr), 5049 NoItinerary, "ldaex", "\t$Rt, $addr", 5050 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>; 5051let hasExtraDefRegAllocReq = 1 in 5052def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr), 5053 NoItinerary, "ldaexd", "\t$Rt, $addr", []> { 5054 let DecoderMethod = "DecodeDoubleRegLoad"; 5055} 5056} 5057 5058let mayStore = 1, Constraints = "@earlyclobber $Rd" in { 5059def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr), 5060 NoItinerary, "strexb", "\t$Rd, $Rt, $addr", 5061 [(set GPR:$Rd, (strex_1 GPR:$Rt, 5062 addr_offset_none:$addr))]>; 5063def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr), 5064 NoItinerary, "strexh", "\t$Rd, $Rt, $addr", 5065 [(set GPR:$Rd, (strex_2 GPR:$Rt, 5066 addr_offset_none:$addr))]>; 5067def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr), 5068 NoItinerary, "strex", "\t$Rd, $Rt, $addr", 5069 [(set GPR:$Rd, (strex_4 GPR:$Rt, 5070 addr_offset_none:$addr))]>; 5071let hasExtraSrcRegAllocReq = 1 in 5072def STREXD : AIstrex<0b01, (outs GPR:$Rd), 5073 (ins GPRPairOp:$Rt, addr_offset_none:$addr), 5074 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> { 5075 let DecoderMethod = "DecodeDoubleRegStore"; 5076} 5077def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr), 5078 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr", 5079 [(set GPR:$Rd, 5080 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>; 5081def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr), 5082 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr", 5083 [(set GPR:$Rd, 5084 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>; 5085def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr), 5086 NoItinerary, "stlex", "\t$Rd, $Rt, $addr", 5087 [(set GPR:$Rd, 5088 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>; 5089let hasExtraSrcRegAllocReq = 1 in 5090def STLEXD : AIstlex<0b01, (outs GPR:$Rd), 5091 (ins GPRPairOp:$Rt, addr_offset_none:$addr), 5092 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> { 5093 let DecoderMethod = "DecodeDoubleRegStore"; 5094} 5095} 5096 5097def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex", 5098 [(int_arm_clrex)]>, 5099 Requires<[IsARM, HasV6K]> { 5100 let Inst{31-0} = 0b11110101011111111111000000011111; 5101} 5102 5103def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr), 5104 (STREXB GPR:$Rt, addr_offset_none:$addr)>; 5105def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr), 5106 (STREXH GPR:$Rt, addr_offset_none:$addr)>; 5107 5108def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr), 5109 (STLEXB GPR:$Rt, addr_offset_none:$addr)>; 5110def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr), 5111 (STLEXH GPR:$Rt, addr_offset_none:$addr)>; 5112 5113class acquiring_load<PatFrag base> 5114 : PatFrag<(ops node:$ptr), (base node:$ptr), [{ 5115 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering(); 5116 return isAcquireOrStronger(Ordering); 5117}]>; 5118 5119def atomic_load_acquire_8 : acquiring_load<atomic_load_8>; 5120def atomic_load_acquire_16 : acquiring_load<atomic_load_16>; 5121def atomic_load_acquire_32 : acquiring_load<atomic_load_32>; 5122 5123class releasing_store<PatFrag base> 5124 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{ 5125 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering(); 5126 return isReleaseOrStronger(Ordering); 5127}]>; 5128 5129def atomic_store_release_8 : releasing_store<atomic_store_8>; 5130def atomic_store_release_16 : releasing_store<atomic_store_16>; 5131def atomic_store_release_32 : releasing_store<atomic_store_32>; 5132 5133let AddedComplexity = 8 in { 5134 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>; 5135 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>; 5136 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>; 5137 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>; 5138 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>; 5139 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>; 5140} 5141 5142// SWP/SWPB are deprecated in V6/V7 and optional in v7VE. 5143// FIXME Use InstAlias to generate LDREX/STREX pairs instead. 5144let mayLoad = 1, mayStore = 1 in { 5145def SWP : AIswp<0, (outs GPRnopc:$Rt), 5146 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>, 5147 Requires<[IsARM,PreV8]>; 5148def SWPB: AIswp<1, (outs GPRnopc:$Rt), 5149 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>, 5150 Requires<[IsARM,PreV8]>; 5151} 5152 5153//===----------------------------------------------------------------------===// 5154// Coprocessor Instructions. 5155// 5156 5157def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1, 5158 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2), 5159 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2", 5160 [(int_arm_cdp timm:$cop, timm:$opc1, timm:$CRd, timm:$CRn, 5161 timm:$CRm, timm:$opc2)]>, 5162 Requires<[IsARM,PreV8]> { 5163 bits<4> opc1; 5164 bits<4> CRn; 5165 bits<4> CRd; 5166 bits<4> cop; 5167 bits<3> opc2; 5168 bits<4> CRm; 5169 5170 let Inst{3-0} = CRm; 5171 let Inst{4} = 0; 5172 let Inst{7-5} = opc2; 5173 let Inst{11-8} = cop; 5174 let Inst{15-12} = CRd; 5175 let Inst{19-16} = CRn; 5176 let Inst{23-20} = opc1; 5177 5178 let DecoderNamespace = "CoProc"; 5179} 5180 5181def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1, 5182 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2), 5183 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2", 5184 [(int_arm_cdp2 timm:$cop, timm:$opc1, timm:$CRd, timm:$CRn, 5185 timm:$CRm, timm:$opc2)]>, 5186 Requires<[IsARM,PreV8]> { 5187 let Inst{31-28} = 0b1111; 5188 bits<4> opc1; 5189 bits<4> CRn; 5190 bits<4> CRd; 5191 bits<4> cop; 5192 bits<3> opc2; 5193 bits<4> CRm; 5194 5195 let Inst{3-0} = CRm; 5196 let Inst{4} = 0; 5197 let Inst{7-5} = opc2; 5198 let Inst{11-8} = cop; 5199 let Inst{15-12} = CRd; 5200 let Inst{19-16} = CRn; 5201 let Inst{23-20} = opc1; 5202 5203 let DecoderNamespace = "CoProc"; 5204} 5205 5206class ACI<dag oops, dag iops, string opc, string asm, 5207 list<dag> pattern, IndexMode im = IndexModeNone> 5208 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary, 5209 opc, asm, "", pattern> { 5210 let Inst{27-25} = 0b110; 5211} 5212class ACInoP<dag oops, dag iops, string opc, string asm, 5213 list<dag> pattern, IndexMode im = IndexModeNone> 5214 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary, 5215 opc, asm, "", pattern> { 5216 let Inst{31-28} = 0b1111; 5217 let Inst{27-25} = 0b110; 5218} 5219 5220let DecoderNamespace = "CoProc" in { 5221multiclass LdStCop<bit load, bit Dbit, string asm, list<dag> pattern> { 5222 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr), 5223 asm, "\t$cop, $CRd, $addr", pattern> { 5224 bits<13> addr; 5225 bits<4> cop; 5226 bits<4> CRd; 5227 let Inst{24} = 1; // P = 1 5228 let Inst{23} = addr{8}; 5229 let Inst{22} = Dbit; 5230 let Inst{21} = 0; // W = 0 5231 let Inst{20} = load; 5232 let Inst{19-16} = addr{12-9}; 5233 let Inst{15-12} = CRd; 5234 let Inst{11-8} = cop; 5235 let Inst{7-0} = addr{7-0}; 5236 let DecoderMethod = "DecodeCopMemInstruction"; 5237 } 5238 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr), 5239 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> { 5240 bits<13> addr; 5241 bits<4> cop; 5242 bits<4> CRd; 5243 let Inst{24} = 1; // P = 1 5244 let Inst{23} = addr{8}; 5245 let Inst{22} = Dbit; 5246 let Inst{21} = 1; // W = 1 5247 let Inst{20} = load; 5248 let Inst{19-16} = addr{12-9}; 5249 let Inst{15-12} = CRd; 5250 let Inst{11-8} = cop; 5251 let Inst{7-0} = addr{7-0}; 5252 let DecoderMethod = "DecodeCopMemInstruction"; 5253 } 5254 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr, 5255 postidx_imm8s4:$offset), 5256 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> { 5257 bits<9> offset; 5258 bits<4> addr; 5259 bits<4> cop; 5260 bits<4> CRd; 5261 let Inst{24} = 0; // P = 0 5262 let Inst{23} = offset{8}; 5263 let Inst{22} = Dbit; 5264 let Inst{21} = 1; // W = 1 5265 let Inst{20} = load; 5266 let Inst{19-16} = addr; 5267 let Inst{15-12} = CRd; 5268 let Inst{11-8} = cop; 5269 let Inst{7-0} = offset{7-0}; 5270 let DecoderMethod = "DecodeCopMemInstruction"; 5271 } 5272 def _OPTION : ACI<(outs), 5273 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr, 5274 coproc_option_imm:$option), 5275 asm, "\t$cop, $CRd, $addr, $option", []> { 5276 bits<8> option; 5277 bits<4> addr; 5278 bits<4> cop; 5279 bits<4> CRd; 5280 let Inst{24} = 0; // P = 0 5281 let Inst{23} = 1; // U = 1 5282 let Inst{22} = Dbit; 5283 let Inst{21} = 0; // W = 0 5284 let Inst{20} = load; 5285 let Inst{19-16} = addr; 5286 let Inst{15-12} = CRd; 5287 let Inst{11-8} = cop; 5288 let Inst{7-0} = option; 5289 let DecoderMethod = "DecodeCopMemInstruction"; 5290 } 5291} 5292multiclass LdSt2Cop<bit load, bit Dbit, string asm, list<dag> pattern> { 5293 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr), 5294 asm, "\t$cop, $CRd, $addr", pattern> { 5295 bits<13> addr; 5296 bits<4> cop; 5297 bits<4> CRd; 5298 let Inst{24} = 1; // P = 1 5299 let Inst{23} = addr{8}; 5300 let Inst{22} = Dbit; 5301 let Inst{21} = 0; // W = 0 5302 let Inst{20} = load; 5303 let Inst{19-16} = addr{12-9}; 5304 let Inst{15-12} = CRd; 5305 let Inst{11-8} = cop; 5306 let Inst{7-0} = addr{7-0}; 5307 let DecoderMethod = "DecodeCopMemInstruction"; 5308 } 5309 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr), 5310 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> { 5311 bits<13> addr; 5312 bits<4> cop; 5313 bits<4> CRd; 5314 let Inst{24} = 1; // P = 1 5315 let Inst{23} = addr{8}; 5316 let Inst{22} = Dbit; 5317 let Inst{21} = 1; // W = 1 5318 let Inst{20} = load; 5319 let Inst{19-16} = addr{12-9}; 5320 let Inst{15-12} = CRd; 5321 let Inst{11-8} = cop; 5322 let Inst{7-0} = addr{7-0}; 5323 let DecoderMethod = "DecodeCopMemInstruction"; 5324 } 5325 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr, 5326 postidx_imm8s4:$offset), 5327 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> { 5328 bits<9> offset; 5329 bits<4> addr; 5330 bits<4> cop; 5331 bits<4> CRd; 5332 let Inst{24} = 0; // P = 0 5333 let Inst{23} = offset{8}; 5334 let Inst{22} = Dbit; 5335 let Inst{21} = 1; // W = 1 5336 let Inst{20} = load; 5337 let Inst{19-16} = addr; 5338 let Inst{15-12} = CRd; 5339 let Inst{11-8} = cop; 5340 let Inst{7-0} = offset{7-0}; 5341 let DecoderMethod = "DecodeCopMemInstruction"; 5342 } 5343 def _OPTION : ACInoP<(outs), 5344 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr, 5345 coproc_option_imm:$option), 5346 asm, "\t$cop, $CRd, $addr, $option", []> { 5347 bits<8> option; 5348 bits<4> addr; 5349 bits<4> cop; 5350 bits<4> CRd; 5351 let Inst{24} = 0; // P = 0 5352 let Inst{23} = 1; // U = 1 5353 let Inst{22} = Dbit; 5354 let Inst{21} = 0; // W = 0 5355 let Inst{20} = load; 5356 let Inst{19-16} = addr; 5357 let Inst{15-12} = CRd; 5358 let Inst{11-8} = cop; 5359 let Inst{7-0} = option; 5360 let DecoderMethod = "DecodeCopMemInstruction"; 5361 } 5362} 5363 5364defm LDC : LdStCop <1, 0, "ldc", [(int_arm_ldc timm:$cop, timm:$CRd, addrmode5:$addr)]>; 5365defm LDCL : LdStCop <1, 1, "ldcl", [(int_arm_ldcl timm:$cop, timm:$CRd, addrmode5:$addr)]>; 5366defm LDC2 : LdSt2Cop<1, 0, "ldc2", [(int_arm_ldc2 timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>; 5367defm LDC2L : LdSt2Cop<1, 1, "ldc2l", [(int_arm_ldc2l timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>; 5368 5369defm STC : LdStCop <0, 0, "stc", [(int_arm_stc timm:$cop, timm:$CRd, addrmode5:$addr)]>; 5370defm STCL : LdStCop <0, 1, "stcl", [(int_arm_stcl timm:$cop, timm:$CRd, addrmode5:$addr)]>; 5371defm STC2 : LdSt2Cop<0, 0, "stc2", [(int_arm_stc2 timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>; 5372defm STC2L : LdSt2Cop<0, 1, "stc2l", [(int_arm_stc2l timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>; 5373 5374} // DecoderNamespace = "CoProc" 5375 5376//===----------------------------------------------------------------------===// 5377// Move between coprocessor and ARM core register. 5378// 5379 5380class MovRCopro<string opc, bit direction, dag oops, dag iops, 5381 list<dag> pattern> 5382 : ABI<0b1110, oops, iops, NoItinerary, opc, 5383 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> { 5384 let Inst{20} = direction; 5385 let Inst{4} = 1; 5386 5387 bits<4> Rt; 5388 bits<4> cop; 5389 bits<3> opc1; 5390 bits<3> opc2; 5391 bits<4> CRm; 5392 bits<4> CRn; 5393 5394 let Inst{15-12} = Rt; 5395 let Inst{11-8} = cop; 5396 let Inst{23-21} = opc1; 5397 let Inst{7-5} = opc2; 5398 let Inst{3-0} = CRm; 5399 let Inst{19-16} = CRn; 5400 5401 let DecoderNamespace = "CoProc"; 5402} 5403 5404def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */, 5405 (outs), 5406 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn, 5407 c_imm:$CRm, imm0_7:$opc2), 5408 [(int_arm_mcr timm:$cop, timm:$opc1, GPR:$Rt, timm:$CRn, 5409 timm:$CRm, timm:$opc2)]>, 5410 ComplexDeprecationPredicate<"MCR">; 5411def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm", 5412 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn, 5413 c_imm:$CRm, 0, pred:$p)>; 5414def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */, 5415 (outs GPRwithAPSR:$Rt), 5416 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm, 5417 imm0_7:$opc2), []>; 5418def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm", 5419 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, 5420 c_imm:$CRm, 0, pred:$p)>; 5421 5422def : ARMPat<(int_arm_mrc timm:$cop, timm:$opc1, timm:$CRn, timm:$CRm, timm:$opc2), 5423 (MRC p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2)>; 5424 5425class MovRCopro2<string opc, bit direction, dag oops, dag iops, 5426 list<dag> pattern> 5427 : ABXI<0b1110, oops, iops, NoItinerary, 5428 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> { 5429 let Inst{31-24} = 0b11111110; 5430 let Inst{20} = direction; 5431 let Inst{4} = 1; 5432 5433 bits<4> Rt; 5434 bits<4> cop; 5435 bits<3> opc1; 5436 bits<3> opc2; 5437 bits<4> CRm; 5438 bits<4> CRn; 5439 5440 let Inst{15-12} = Rt; 5441 let Inst{11-8} = cop; 5442 let Inst{23-21} = opc1; 5443 let Inst{7-5} = opc2; 5444 let Inst{3-0} = CRm; 5445 let Inst{19-16} = CRn; 5446 5447 let DecoderNamespace = "CoProc"; 5448} 5449 5450def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */, 5451 (outs), 5452 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn, 5453 c_imm:$CRm, imm0_7:$opc2), 5454 [(int_arm_mcr2 timm:$cop, timm:$opc1, GPR:$Rt, timm:$CRn, 5455 timm:$CRm, timm:$opc2)]>, 5456 Requires<[IsARM,PreV8]>; 5457def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm", 5458 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn, 5459 c_imm:$CRm, 0)>; 5460def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */, 5461 (outs GPRwithAPSR:$Rt), 5462 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm, 5463 imm0_7:$opc2), []>, 5464 Requires<[IsARM,PreV8]>; 5465def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm", 5466 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, 5467 c_imm:$CRm, 0)>; 5468 5469def : ARMV5TPat<(int_arm_mrc2 timm:$cop, timm:$opc1, timm:$CRn, 5470 timm:$CRm, timm:$opc2), 5471 (MRC2 p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2)>; 5472 5473class MovRRCopro<string opc, bit direction, dag oops, dag iops, list<dag> 5474 pattern = []> 5475 : ABI<0b1100, oops, iops, NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", 5476 pattern> { 5477 5478 let Inst{23-21} = 0b010; 5479 let Inst{20} = direction; 5480 5481 bits<4> Rt; 5482 bits<4> Rt2; 5483 bits<4> cop; 5484 bits<4> opc1; 5485 bits<4> CRm; 5486 5487 let Inst{15-12} = Rt; 5488 let Inst{19-16} = Rt2; 5489 let Inst{11-8} = cop; 5490 let Inst{7-4} = opc1; 5491 let Inst{3-0} = CRm; 5492} 5493 5494def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */, 5495 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt, 5496 GPRnopc:$Rt2, c_imm:$CRm), 5497 [(int_arm_mcrr timm:$cop, timm:$opc1, GPRnopc:$Rt, 5498 GPRnopc:$Rt2, timm:$CRm)]>; 5499def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */, 5500 (outs GPRnopc:$Rt, GPRnopc:$Rt2), 5501 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>; 5502 5503class MovRRCopro2<string opc, bit direction, dag oops, dag iops, 5504 list<dag> pattern = []> 5505 : ABXI<0b1100, oops, iops, NoItinerary, 5506 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>, 5507 Requires<[IsARM,PreV8]> { 5508 let Inst{31-28} = 0b1111; 5509 let Inst{23-21} = 0b010; 5510 let Inst{20} = direction; 5511 5512 bits<4> Rt; 5513 bits<4> Rt2; 5514 bits<4> cop; 5515 bits<4> opc1; 5516 bits<4> CRm; 5517 5518 let Inst{15-12} = Rt; 5519 let Inst{19-16} = Rt2; 5520 let Inst{11-8} = cop; 5521 let Inst{7-4} = opc1; 5522 let Inst{3-0} = CRm; 5523 5524 let DecoderMethod = "DecoderForMRRC2AndMCRR2"; 5525} 5526 5527def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */, 5528 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt, 5529 GPRnopc:$Rt2, c_imm:$CRm), 5530 [(int_arm_mcrr2 timm:$cop, timm:$opc1, GPRnopc:$Rt, 5531 GPRnopc:$Rt2, timm:$CRm)]>; 5532 5533def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */, 5534 (outs GPRnopc:$Rt, GPRnopc:$Rt2), 5535 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>; 5536 5537//===----------------------------------------------------------------------===// 5538// Move between special register and ARM core register 5539// 5540 5541// Move to ARM core register from Special Register 5542def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary, 5543 "mrs", "\t$Rd, apsr", []> { 5544 bits<4> Rd; 5545 let Inst{23-16} = 0b00001111; 5546 let Unpredictable{19-17} = 0b111; 5547 5548 let Inst{15-12} = Rd; 5549 5550 let Inst{11-0} = 0b000000000000; 5551 let Unpredictable{11-0} = 0b110100001111; 5552} 5553 5554def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p), 0>, 5555 Requires<[IsARM]>; 5556 5557// The MRSsys instruction is the MRS instruction from the ARM ARM, 5558// section B9.3.9, with the R bit set to 1. 5559def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary, 5560 "mrs", "\t$Rd, spsr", []> { 5561 bits<4> Rd; 5562 let Inst{23-16} = 0b01001111; 5563 let Unpredictable{19-16} = 0b1111; 5564 5565 let Inst{15-12} = Rd; 5566 5567 let Inst{11-0} = 0b000000000000; 5568 let Unpredictable{11-0} = 0b110100001111; 5569} 5570 5571// However, the MRS (banked register) system instruction (ARMv7VE) *does* have a 5572// separate encoding (distinguished by bit 5. 5573def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked), 5574 NoItinerary, "mrs", "\t$Rd, $banked", []>, 5575 Requires<[IsARM, HasVirtualization]> { 5576 bits<6> banked; 5577 bits<4> Rd; 5578 5579 let Inst{23} = 0; 5580 let Inst{22} = banked{5}; // R bit 5581 let Inst{21-20} = 0b00; 5582 let Inst{19-16} = banked{3-0}; 5583 let Inst{15-12} = Rd; 5584 let Inst{11-9} = 0b001; 5585 let Inst{8} = banked{4}; 5586 let Inst{7-0} = 0b00000000; 5587} 5588 5589// Move from ARM core register to Special Register 5590// 5591// No need to have both system and application versions of MSR (immediate) or 5592// MSR (register), the encodings are the same and the assembly parser has no way 5593// to distinguish between them. The mask operand contains the special register 5594// (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be 5595// accessed in the special register. 5596let Defs = [CPSR] in 5597def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary, 5598 "msr", "\t$mask, $Rn", []> { 5599 bits<5> mask; 5600 bits<4> Rn; 5601 5602 let Inst{23} = 0; 5603 let Inst{22} = mask{4}; // R bit 5604 let Inst{21-20} = 0b10; 5605 let Inst{19-16} = mask{3-0}; 5606 let Inst{15-12} = 0b1111; 5607 let Inst{11-4} = 0b00000000; 5608 let Inst{3-0} = Rn; 5609} 5610 5611let Defs = [CPSR] in 5612def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary, 5613 "msr", "\t$mask, $imm", []> { 5614 bits<5> mask; 5615 bits<12> imm; 5616 5617 let Inst{23} = 0; 5618 let Inst{22} = mask{4}; // R bit 5619 let Inst{21-20} = 0b10; 5620 let Inst{19-16} = mask{3-0}; 5621 let Inst{15-12} = 0b1111; 5622 let Inst{11-0} = imm; 5623} 5624 5625// However, the MSR (banked register) system instruction (ARMv7VE) *does* have a 5626// separate encoding (distinguished by bit 5. 5627def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn), 5628 NoItinerary, "msr", "\t$banked, $Rn", []>, 5629 Requires<[IsARM, HasVirtualization]> { 5630 bits<6> banked; 5631 bits<4> Rn; 5632 5633 let Inst{23} = 0; 5634 let Inst{22} = banked{5}; // R bit 5635 let Inst{21-20} = 0b10; 5636 let Inst{19-16} = banked{3-0}; 5637 let Inst{15-12} = 0b1111; 5638 let Inst{11-9} = 0b001; 5639 let Inst{8} = banked{4}; 5640 let Inst{7-4} = 0b0000; 5641 let Inst{3-0} = Rn; 5642} 5643 5644// Dynamic stack allocation yields a _chkstk for Windows targets. These calls 5645// are needed to probe the stack when allocating more than 5646// 4k bytes in one go. Touching the stack at 4K increments is necessary to 5647// ensure that the guard pages used by the OS virtual memory manager are 5648// allocated in correct sequence. 5649// The main point of having separate instruction are extra unmodelled effects 5650// (compared to ordinary calls) like stack pointer change. 5651 5652def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone, 5653 [SDNPHasChain, SDNPSideEffect]>; 5654let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP], hasNoSchedulingInfo = 1 in 5655 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>; 5656 5657def win__dbzchk : SDNode<"ARMISD::WIN__DBZCHK", SDT_WIN__DBZCHK, 5658 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>; 5659let usesCustomInserter = 1, Defs = [CPSR], hasNoSchedulingInfo = 1 in 5660 def WIN__DBZCHK : PseudoInst<(outs), (ins tGPR:$divisor), NoItinerary, 5661 [(win__dbzchk tGPR:$divisor)]>; 5662 5663//===----------------------------------------------------------------------===// 5664// TLS Instructions 5665// 5666 5667// __aeabi_read_tp preserves the registers r1-r3. 5668// This is a pseudo inst so that we can get the encoding right, 5669// complete with fixup for the aeabi_read_tp function. 5670// TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern 5671// is defined in "ARMInstrThumb.td". 5672let isCall = 1, 5673 Defs = [R0, R12, LR, CPSR], Uses = [SP] in { 5674 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br, 5675 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>, 5676 Requires<[IsARM, IsReadTPSoft]>; 5677} 5678 5679// Reading thread pointer from coprocessor register 5680def : ARMPat<(ARMthread_pointer), (MRC 15, 0, 13, 0, 3)>, 5681 Requires<[IsARM, IsReadTPHard]>; 5682 5683//===----------------------------------------------------------------------===// 5684// SJLJ Exception handling intrinsics 5685// eh_sjlj_setjmp() is an instruction sequence to store the return 5686// address and save #0 in R0 for the non-longjmp case. 5687// Since by its nature we may be coming from some other function to get 5688// here, and we're using the stack frame for the containing function to 5689// save/restore registers, we can't keep anything live in regs across 5690// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon 5691// when we get here from a longjmp(). We force everything out of registers 5692// except for our own input by listing the relevant registers in Defs. By 5693// doing so, we also cause the prologue/epilogue code to actively preserve 5694// all of the callee-saved resgisters, which is exactly what we want. 5695// A constant value is passed in $val, and we use the location as a scratch. 5696// 5697// These are pseudo-instructions and are lowered to individual MC-insts, so 5698// no encoding information is necessary. 5699let Defs = 5700 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR, 5701 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ], 5702 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in { 5703 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val), 5704 NoItinerary, 5705 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>, 5706 Requires<[IsARM, HasVFP2]>; 5707} 5708 5709let Defs = 5710 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ], 5711 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in { 5712 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val), 5713 NoItinerary, 5714 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>, 5715 Requires<[IsARM, NoVFP]>; 5716} 5717 5718// FIXME: Non-IOS version(s) 5719let isBarrier = 1, hasSideEffects = 1, isTerminator = 1, 5720 Defs = [ R7, LR, SP ] in { 5721def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch), 5722 NoItinerary, 5723 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>, 5724 Requires<[IsARM]>; 5725} 5726 5727let isBarrier = 1, hasSideEffects = 1, usesCustomInserter = 1 in 5728def Int_eh_sjlj_setup_dispatch : PseudoInst<(outs), (ins), NoItinerary, 5729 [(ARMeh_sjlj_setup_dispatch)]>; 5730 5731// eh.sjlj.dispatchsetup pseudo-instruction. 5732// This pseudo is used for both ARM and Thumb. Any differences are handled when 5733// the pseudo is expanded (which happens before any passes that need the 5734// instruction size). 5735let isBarrier = 1 in 5736def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>; 5737 5738 5739//===----------------------------------------------------------------------===// 5740// Non-Instruction Patterns 5741// 5742 5743// ARMv4 indirect branch using (MOVr PC, dst) 5744let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in 5745 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst), 5746 4, IIC_Br, [(brind GPR:$dst)], 5747 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>, 5748 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>; 5749 5750let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in 5751 def TAILJMPr4 : ARMPseudoExpand<(outs), (ins GPR:$dst), 5752 4, IIC_Br, [], 5753 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>, 5754 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>; 5755 5756// Large immediate handling. 5757 5758// 32-bit immediate using two piece mod_imms or movw + movt. 5759// This is a single pseudo instruction, the benefit is that it can be remat'd 5760// as a single unit instead of having to handle reg inputs. 5761// FIXME: Remove this when we can do generalized remat. 5762let isReMaterializable = 1, isMoveImm = 1 in 5763def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2, 5764 [(set GPR:$dst, (arm_i32imm:$src))]>, 5765 Requires<[IsARM]>; 5766 5767def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i, 5768 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>, 5769 Requires<[IsARM, DontUseMovt]>; 5770 5771// Pseudo instruction that combines movw + movt + add pc (if PIC). 5772// It also makes it possible to rematerialize the instructions. 5773// FIXME: Remove this when we can do generalized remat and when machine licm 5774// can properly the instructions. 5775let isReMaterializable = 1 in { 5776def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr), 5777 IIC_iMOVix2addpc, 5778 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>, 5779 Requires<[IsARM, UseMovtInPic]>; 5780 5781def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr), 5782 IIC_iLoadiALU, 5783 [(set GPR:$dst, 5784 (ARMWrapperPIC tglobaladdr:$addr))]>, 5785 Requires<[IsARM, DontUseMovtInPic]>; 5786 5787let AddedComplexity = 10 in 5788def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr), 5789 NoItinerary, 5790 [(set GPR:$dst, 5791 (load (ARMWrapperPIC tglobaladdr:$addr)))]>, 5792 Requires<[IsARM, DontUseMovtInPic]>; 5793 5794let AddedComplexity = 10 in 5795def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr), 5796 IIC_iMOVix2ld, 5797 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>, 5798 Requires<[IsARM, UseMovtInPic]>; 5799} // isReMaterializable 5800 5801// The many different faces of TLS access. 5802def : ARMPat<(ARMWrapper tglobaltlsaddr :$dst), 5803 (MOVi32imm tglobaltlsaddr :$dst)>, 5804 Requires<[IsARM, UseMovt]>; 5805 5806def : Pat<(ARMWrapper tglobaltlsaddr:$src), 5807 (LDRLIT_ga_abs tglobaltlsaddr:$src)>, 5808 Requires<[IsARM, DontUseMovt]>; 5809 5810def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr), 5811 (MOV_ga_pcrel tglobaltlsaddr:$addr)>, Requires<[IsARM, UseMovtInPic]>; 5812 5813def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr), 5814 (LDRLIT_ga_pcrel tglobaltlsaddr:$addr)>, 5815 Requires<[IsARM, DontUseMovtInPic]>; 5816let AddedComplexity = 10 in 5817def : Pat<(load (ARMWrapperPIC tglobaltlsaddr:$addr)), 5818 (MOV_ga_pcrel_ldr tglobaltlsaddr:$addr)>, 5819 Requires<[IsARM, UseMovtInPic]>; 5820 5821 5822// ConstantPool, GlobalAddress, and JumpTable 5823def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>; 5824def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>, 5825 Requires<[IsARM, UseMovt]>; 5826def : ARMPat<(ARMWrapper texternalsym :$dst), (MOVi32imm texternalsym :$dst)>, 5827 Requires<[IsARM, UseMovt]>; 5828def : ARMPat<(ARMWrapperJT tjumptable:$dst), 5829 (LEApcrelJT tjumptable:$dst)>; 5830 5831// TODO: add,sub,and, 3-instr forms? 5832 5833// Tail calls. These patterns also apply to Thumb mode. 5834def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>; 5835def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>; 5836def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>; 5837 5838// Direct calls 5839def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>; 5840def : ARMPat<(ARMcall_nolink texternalsym:$func), 5841 (BMOVPCB_CALL texternalsym:$func)>; 5842 5843// zextload i1 -> zextload i8 5844def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>; 5845def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>; 5846 5847// extload -> zextload 5848def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>; 5849def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>; 5850def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>; 5851def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>; 5852 5853def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>; 5854 5855def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>; 5856def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>; 5857 5858// smul* and smla* 5859def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b), 5860 (SMULBB GPR:$a, GPR:$b)>; 5861def : ARMV5TEPat<(mul sext_16_node:$a, (sext_bottom_16 GPR:$b)), 5862 (SMULBB GPR:$a, GPR:$b)>; 5863def : ARMV5TEPat<(mul sext_16_node:$a, (sext_top_16 GPR:$b)), 5864 (SMULBT GPR:$a, GPR:$b)>; 5865def : ARMV5TEPat<(mul (sext_top_16 GPR:$a), sext_16_node:$b), 5866 (SMULTB GPR:$a, GPR:$b)>; 5867def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, sext_16_node:$b)), 5868 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>; 5869def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_bottom_16 GPR:$b))), 5870 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>; 5871def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_top_16 GPR:$b))), 5872 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>; 5873def : ARMV5MOPat<(add GPR:$acc, (mul (sext_top_16 GPR:$a), sext_16_node:$b)), 5874 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>; 5875 5876def : ARMV5TEPat<(int_arm_smulbb GPR:$a, GPR:$b), 5877 (SMULBB GPR:$a, GPR:$b)>; 5878def : ARMV5TEPat<(int_arm_smulbt GPR:$a, GPR:$b), 5879 (SMULBT GPR:$a, GPR:$b)>; 5880def : ARMV5TEPat<(int_arm_smultb GPR:$a, GPR:$b), 5881 (SMULTB GPR:$a, GPR:$b)>; 5882def : ARMV5TEPat<(int_arm_smultt GPR:$a, GPR:$b), 5883 (SMULTT GPR:$a, GPR:$b)>; 5884def : ARMV5TEPat<(int_arm_smulwb GPR:$a, GPR:$b), 5885 (SMULWB GPR:$a, GPR:$b)>; 5886def : ARMV5TEPat<(int_arm_smulwt GPR:$a, GPR:$b), 5887 (SMULWT GPR:$a, GPR:$b)>; 5888 5889def : ARMV5TEPat<(int_arm_smlabb GPR:$a, GPR:$b, GPR:$acc), 5890 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>; 5891def : ARMV5TEPat<(int_arm_smlabt GPR:$a, GPR:$b, GPR:$acc), 5892 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>; 5893def : ARMV5TEPat<(int_arm_smlatb GPR:$a, GPR:$b, GPR:$acc), 5894 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>; 5895def : ARMV5TEPat<(int_arm_smlatt GPR:$a, GPR:$b, GPR:$acc), 5896 (SMLATT GPR:$a, GPR:$b, GPR:$acc)>; 5897def : ARMV5TEPat<(int_arm_smlawb GPR:$a, GPR:$b, GPR:$acc), 5898 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>; 5899def : ARMV5TEPat<(int_arm_smlawt GPR:$a, GPR:$b, GPR:$acc), 5900 (SMLAWT GPR:$a, GPR:$b, GPR:$acc)>; 5901 5902// Pre-v7 uses MCR for synchronization barriers. 5903def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>, 5904 Requires<[IsARM, HasV6]>; 5905 5906// SXT/UXT with no rotate 5907let AddedComplexity = 16 in { 5908def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>; 5909def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>; 5910def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>; 5911def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)), 5912 (UXTAB GPR:$Rn, GPR:$Rm, 0)>; 5913def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)), 5914 (UXTAH GPR:$Rn, GPR:$Rm, 0)>; 5915} 5916 5917def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>; 5918def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>; 5919 5920def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)), 5921 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>; 5922def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)), 5923 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>; 5924 5925// Atomic load/store patterns 5926def : ARMPat<(atomic_load_8 ldst_so_reg:$src), 5927 (LDRBrs ldst_so_reg:$src)>; 5928def : ARMPat<(atomic_load_8 addrmode_imm12:$src), 5929 (LDRBi12 addrmode_imm12:$src)>; 5930def : ARMPat<(atomic_load_16 addrmode3:$src), 5931 (LDRH addrmode3:$src)>; 5932def : ARMPat<(atomic_load_32 ldst_so_reg:$src), 5933 (LDRrs ldst_so_reg:$src)>; 5934def : ARMPat<(atomic_load_32 addrmode_imm12:$src), 5935 (LDRi12 addrmode_imm12:$src)>; 5936def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val), 5937 (STRBrs GPR:$val, ldst_so_reg:$ptr)>; 5938def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val), 5939 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>; 5940def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val), 5941 (STRH GPR:$val, addrmode3:$ptr)>; 5942def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val), 5943 (STRrs GPR:$val, ldst_so_reg:$ptr)>; 5944def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val), 5945 (STRi12 GPR:$val, addrmode_imm12:$ptr)>; 5946 5947 5948//===----------------------------------------------------------------------===// 5949// Thumb Support 5950// 5951 5952include "ARMInstrThumb.td" 5953 5954//===----------------------------------------------------------------------===// 5955// Thumb2 Support 5956// 5957 5958include "ARMInstrThumb2.td" 5959 5960//===----------------------------------------------------------------------===// 5961// Floating Point Support 5962// 5963 5964include "ARMInstrVFP.td" 5965 5966//===----------------------------------------------------------------------===// 5967// Advanced SIMD (NEON) Support 5968// 5969 5970include "ARMInstrNEON.td" 5971 5972//===----------------------------------------------------------------------===// 5973// MVE Support 5974// 5975 5976include "ARMInstrMVE.td" 5977 5978//===----------------------------------------------------------------------===// 5979// Assembler aliases 5980// 5981 5982// Memory barriers 5983def : InstAlias<"dmb", (DMB 0xf), 0>, Requires<[IsARM, HasDB]>; 5984def : InstAlias<"dsb", (DSB 0xf), 0>, Requires<[IsARM, HasDB]>; 5985def : InstAlias<"ssbb", (DSB 0x0), 1>, Requires<[IsARM, HasDB]>; 5986def : InstAlias<"pssbb", (DSB 0x4), 1>, Requires<[IsARM, HasDB]>; 5987def : InstAlias<"isb", (ISB 0xf), 0>, Requires<[IsARM, HasDB]>; 5988// Armv8-R 'Data Full Barrier' 5989def : InstAlias<"dfb", (DSB 0xc), 1>, Requires<[IsARM, HasDFB]>; 5990 5991// System instructions 5992def : MnemonicAlias<"swi", "svc">; 5993 5994// Load / Store Multiple 5995def : MnemonicAlias<"ldmfd", "ldm">; 5996def : MnemonicAlias<"ldmia", "ldm">; 5997def : MnemonicAlias<"ldmea", "ldmdb">; 5998def : MnemonicAlias<"stmfd", "stmdb">; 5999def : MnemonicAlias<"stmia", "stm">; 6000def : MnemonicAlias<"stmea", "stm">; 6001 6002// PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT with the 6003// input operands swapped when the shift amount is zero (i.e., unspecified). 6004def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm", 6005 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p), 0>, 6006 Requires<[IsARM, HasV6]>; 6007def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm", 6008 (PKHBT GPRnopc:$Rd, GPRnopc:$Rm, GPRnopc:$Rn, 0, pred:$p), 0>, 6009 Requires<[IsARM, HasV6]>; 6010 6011// PUSH/POP aliases for STM/LDM 6012def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>; 6013def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>; 6014 6015// SSAT/USAT optional shift operand. 6016def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn", 6017 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>; 6018def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn", 6019 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>; 6020 6021 6022// Extend instruction optional rotate operand. 6023def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm", 6024 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>; 6025def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm", 6026 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>; 6027def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm", 6028 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>; 6029def : ARMInstAlias<"sxtb${p} $Rd, $Rm", 6030 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>; 6031def : ARMInstAlias<"sxtb16${p} $Rd, $Rm", 6032 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>; 6033def : ARMInstAlias<"sxth${p} $Rd, $Rm", 6034 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>; 6035 6036def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm", 6037 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>; 6038def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm", 6039 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>; 6040def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm", 6041 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>; 6042def : ARMInstAlias<"uxtb${p} $Rd, $Rm", 6043 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>; 6044def : ARMInstAlias<"uxtb16${p} $Rd, $Rm", 6045 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>; 6046def : ARMInstAlias<"uxth${p} $Rd, $Rm", 6047 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>; 6048 6049 6050// RFE aliases 6051def : MnemonicAlias<"rfefa", "rfeda">; 6052def : MnemonicAlias<"rfeea", "rfedb">; 6053def : MnemonicAlias<"rfefd", "rfeia">; 6054def : MnemonicAlias<"rfeed", "rfeib">; 6055def : MnemonicAlias<"rfe", "rfeia">; 6056 6057// SRS aliases 6058def : MnemonicAlias<"srsfa", "srsib">; 6059def : MnemonicAlias<"srsea", "srsia">; 6060def : MnemonicAlias<"srsfd", "srsdb">; 6061def : MnemonicAlias<"srsed", "srsda">; 6062def : MnemonicAlias<"srs", "srsia">; 6063 6064// QSAX == QSUBADDX 6065def : MnemonicAlias<"qsubaddx", "qsax">; 6066// SASX == SADDSUBX 6067def : MnemonicAlias<"saddsubx", "sasx">; 6068// SHASX == SHADDSUBX 6069def : MnemonicAlias<"shaddsubx", "shasx">; 6070// SHSAX == SHSUBADDX 6071def : MnemonicAlias<"shsubaddx", "shsax">; 6072// SSAX == SSUBADDX 6073def : MnemonicAlias<"ssubaddx", "ssax">; 6074// UASX == UADDSUBX 6075def : MnemonicAlias<"uaddsubx", "uasx">; 6076// UHASX == UHADDSUBX 6077def : MnemonicAlias<"uhaddsubx", "uhasx">; 6078// UHSAX == UHSUBADDX 6079def : MnemonicAlias<"uhsubaddx", "uhsax">; 6080// UQASX == UQADDSUBX 6081def : MnemonicAlias<"uqaddsubx", "uqasx">; 6082// UQSAX == UQSUBADDX 6083def : MnemonicAlias<"uqsubaddx", "uqsax">; 6084// USAX == USUBADDX 6085def : MnemonicAlias<"usubaddx", "usax">; 6086 6087// "mov Rd, mod_imm_not" can be handled via "mvn" in assembly, just like 6088// for isel. 6089def : ARMInstSubst<"mov${s}${p} $Rd, $imm", 6090 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>; 6091def : ARMInstSubst<"mvn${s}${p} $Rd, $imm", 6092 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>; 6093// Same for AND <--> BIC 6094def : ARMInstSubst<"bic${s}${p} $Rd, $Rn, $imm", 6095 (ANDri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, 6096 pred:$p, cc_out:$s)>; 6097def : ARMInstSubst<"bic${s}${p} $Rdn, $imm", 6098 (ANDri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, 6099 pred:$p, cc_out:$s)>; 6100def : ARMInstSubst<"and${s}${p} $Rd, $Rn, $imm", 6101 (BICri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, 6102 pred:$p, cc_out:$s)>; 6103def : ARMInstSubst<"and${s}${p} $Rdn, $imm", 6104 (BICri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, 6105 pred:$p, cc_out:$s)>; 6106 6107// Likewise, "add Rd, mod_imm_neg" -> sub 6108def : ARMInstSubst<"add${s}${p} $Rd, $Rn, $imm", 6109 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>; 6110def : ARMInstSubst<"add${s}${p} $Rd, $imm", 6111 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>; 6112// Likewise, "sub Rd, mod_imm_neg" -> add 6113def : ARMInstSubst<"sub${s}${p} $Rd, $Rn, $imm", 6114 (ADDri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>; 6115def : ARMInstSubst<"sub${s}${p} $Rd, $imm", 6116 (ADDri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>; 6117 6118 6119def : ARMInstSubst<"adc${s}${p} $Rd, $Rn, $imm", 6120 (SBCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>; 6121def : ARMInstSubst<"adc${s}${p} $Rdn, $imm", 6122 (SBCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>; 6123def : ARMInstSubst<"sbc${s}${p} $Rd, $Rn, $imm", 6124 (ADCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>; 6125def : ARMInstSubst<"sbc${s}${p} $Rdn, $imm", 6126 (ADCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>; 6127 6128// Same for CMP <--> CMN via mod_imm_neg 6129def : ARMInstSubst<"cmp${p} $Rd, $imm", 6130 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>; 6131def : ARMInstSubst<"cmn${p} $Rd, $imm", 6132 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>; 6133 6134// The shifter forms of the MOV instruction are aliased to the ASR, LSL, 6135// LSR, ROR, and RRX instructions. 6136// FIXME: We need C++ parser hooks to map the alias to the MOV 6137// encoding. It seems we should be able to do that sort of thing 6138// in tblgen, but it could get ugly. 6139let TwoOperandAliasConstraint = "$Rm = $Rd" in { 6140def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm", 6141 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p, 6142 cc_out:$s)>; 6143def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm", 6144 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p, 6145 cc_out:$s)>; 6146def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm", 6147 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p, 6148 cc_out:$s)>; 6149def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm", 6150 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p, 6151 cc_out:$s)>; 6152} 6153def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm", 6154 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>; 6155let TwoOperandAliasConstraint = "$Rn = $Rd" in { 6156def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm", 6157 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, 6158 cc_out:$s)>; 6159def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm", 6160 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, 6161 cc_out:$s)>; 6162def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm", 6163 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, 6164 cc_out:$s)>; 6165def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm", 6166 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, 6167 cc_out:$s)>; 6168} 6169 6170// "neg" is and alias for "rsb rd, rn, #0" 6171def : ARMInstAlias<"neg${s}${p} $Rd, $Rm", 6172 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>; 6173 6174// Pre-v6, 'mov r0, r0' was used as a NOP encoding. 6175def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>, 6176 Requires<[IsARM, NoV6]>; 6177 6178// MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but 6179// the instruction definitions need difference constraints pre-v6. 6180// Use these aliases for the assembly parsing on pre-v6. 6181def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm", 6182 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s), 0>, 6183 Requires<[IsARM, NoV6]>; 6184def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra", 6185 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, 6186 pred:$p, cc_out:$s), 0>, 6187 Requires<[IsARM, NoV6]>; 6188def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm", 6189 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>, 6190 Requires<[IsARM, NoV6]>; 6191def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm", 6192 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>, 6193 Requires<[IsARM, NoV6]>; 6194def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm", 6195 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>, 6196 Requires<[IsARM, NoV6]>; 6197def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm", 6198 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>, 6199 Requires<[IsARM, NoV6]>; 6200 6201// 'it' blocks in ARM mode just validate the predicates. The IT itself 6202// is discarded. 6203def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>, 6204 ComplexDeprecationPredicate<"IT">; 6205 6206let mayLoad = 1, mayStore =1, hasSideEffects = 1, hasNoSchedulingInfo = 1 in 6207def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn), 6208 NoItinerary, 6209 [(set GPR:$Rd, (int_arm_space timm:$size, GPR:$Rn))]>; 6210 6211//===---------------------------------- 6212// Atomic cmpxchg for -O0 6213//===---------------------------------- 6214 6215// The fast register allocator used during -O0 inserts spills to cover any VRegs 6216// live across basic block boundaries. When this happens between an LDXR and an 6217// STXR it can clear the exclusive monitor, causing all cmpxchg attempts to 6218// fail. 6219 6220// Unfortunately, this means we have to have an alternative (expanded 6221// post-regalloc) path for -O0 compilations. Fortunately this path can be 6222// significantly more naive than the standard expansion: we conservatively 6223// assume seq_cst, strong cmpxchg and omit clrex on failure. 6224 6225let Constraints = "@earlyclobber $Rd,@earlyclobber $temp", 6226 mayLoad = 1, mayStore = 1 in { 6227def CMP_SWAP_8 : PseudoInst<(outs GPR:$Rd, GPR:$temp), 6228 (ins GPR:$addr, GPR:$desired, GPR:$new), 6229 NoItinerary, []>, Sched<[]>; 6230 6231def CMP_SWAP_16 : PseudoInst<(outs GPR:$Rd, GPR:$temp), 6232 (ins GPR:$addr, GPR:$desired, GPR:$new), 6233 NoItinerary, []>, Sched<[]>; 6234 6235def CMP_SWAP_32 : PseudoInst<(outs GPR:$Rd, GPR:$temp), 6236 (ins GPR:$addr, GPR:$desired, GPR:$new), 6237 NoItinerary, []>, Sched<[]>; 6238 6239def CMP_SWAP_64 : PseudoInst<(outs GPRPair:$Rd, GPR:$temp), 6240 (ins GPR:$addr, GPRPair:$desired, GPRPair:$new), 6241 NoItinerary, []>, Sched<[]>; 6242} 6243 6244def CompilerBarrier : PseudoInst<(outs), (ins i32imm:$ordering), NoItinerary, 6245 [(atomic_fence timm:$ordering, 0)]> { 6246 let hasSideEffects = 1; 6247 let Size = 0; 6248 let AsmString = "@ COMPILER BARRIER"; 6249 let hasNoSchedulingInfo = 1; 6250} 6251