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