1//===-- ARMInstrThumb2.td - Thumb2 support for ARM ---------*- 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 Thumb2 instruction set. 10// 11//===----------------------------------------------------------------------===// 12 13// IT block predicate field 14def it_pred_asmoperand : AsmOperandClass { 15 let Name = "ITCondCode"; 16 let ParserMethod = "parseITCondCode"; 17} 18def it_pred : Operand<i32> { 19 let PrintMethod = "printMandatoryPredicateOperand"; 20 let ParserMatchClass = it_pred_asmoperand; 21} 22 23// IT block condition mask 24def it_mask_asmoperand : AsmOperandClass { let Name = "ITMask"; } 25def it_mask : Operand<i32> { 26 let PrintMethod = "printThumbITMask"; 27 let ParserMatchClass = it_mask_asmoperand; 28 let EncoderMethod = "getITMaskOpValue"; 29} 30 31// t2_shift_imm: An integer that encodes a shift amount and the type of shift 32// (asr or lsl). The 6-bit immediate encodes as: 33// {5} 0 ==> lsl 34// 1 asr 35// {4-0} imm5 shift amount. 36// asr #32 not allowed 37def t2_shift_imm : Operand<i32> { 38 let PrintMethod = "printShiftImmOperand"; 39 let ParserMatchClass = ShifterImmAsmOperand; 40 let DecoderMethod = "DecodeT2ShifterImmOperand"; 41} 42 43def mve_shift_imm : AsmOperandClass { 44 let Name = "MVELongShift"; 45 let RenderMethod = "addImmOperands"; 46 let DiagnosticString = "operand must be an immediate in the range [1,32]"; 47} 48def long_shift : Operand<i32>, 49 ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> { 50 let ParserMatchClass = mve_shift_imm; 51 let DecoderMethod = "DecodeLongShiftOperand"; 52} 53 54// Shifted operands. No register controlled shifts for Thumb2. 55// Note: We do not support rrx shifted operands yet. 56def t2_so_reg : Operand<i32>, // reg imm 57 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand", 58 [shl,srl,sra,rotr]> { 59 let EncoderMethod = "getT2SORegOpValue"; 60 let PrintMethod = "printT2SOOperand"; 61 let DecoderMethod = "DecodeSORegImmOperand"; 62 let ParserMatchClass = ShiftedImmAsmOperand; 63 let MIOperandInfo = (ops rGPR, i32imm); 64} 65 66// Same as above, but only matching on a single use node. 67def t2_so_reg_oneuse : Operand<i32>, 68 ComplexPattern<i32, 2, 69 "SelectShiftImmShifterOperandOneUse", 70 [shl,srl,sra,rotr]>; 71 72// t2_so_imm_not_XFORM - Return the complement of a t2_so_imm value 73def t2_so_imm_not_XFORM : SDNodeXForm<imm, [{ 74 return CurDAG->getTargetConstant(~((uint32_t)N->getZExtValue()), SDLoc(N), 75 MVT::i32); 76}]>; 77 78// t2_so_imm_neg_XFORM - Return the negation of a t2_so_imm value 79def t2_so_imm_neg_XFORM : SDNodeXForm<imm, [{ 80 return CurDAG->getTargetConstant(-((int)N->getZExtValue()), SDLoc(N), 81 MVT::i32); 82}]>; 83 84// so_imm_notSext_XFORM - Return a so_imm value packed into the format 85// described for so_imm_notSext def below, with sign extension from 16 86// bits. 87def t2_so_imm_notSext16_XFORM : SDNodeXForm<imm, [{ 88 APInt apIntN = N->getAPIntValue(); 89 unsigned N16bitSignExt = apIntN.trunc(16).sext(32).getZExtValue(); 90 return CurDAG->getTargetConstant(~N16bitSignExt, SDLoc(N), MVT::i32); 91}]>; 92 93// t2_so_imm - Match a 32-bit immediate operand, which is an 94// 8-bit immediate rotated by an arbitrary number of bits, or an 8-bit 95// immediate splatted into multiple bytes of the word. 96def t2_so_imm_asmoperand : AsmOperandClass { 97 let Name = "T2SOImm"; 98 let RenderMethod = "addImmOperands"; 99 100} 101def t2_so_imm : Operand<i32>, ImmLeaf<i32, [{ 102 return ARM_AM::getT2SOImmVal(Imm) != -1; 103 }]> { 104 let ParserMatchClass = t2_so_imm_asmoperand; 105 let EncoderMethod = "getT2SOImmOpValue"; 106 let DecoderMethod = "DecodeT2SOImm"; 107} 108 109// t2_so_imm_not - Match an immediate that is a complement 110// of a t2_so_imm. 111// Note: this pattern doesn't require an encoder method and such, as it's 112// only used on aliases (Pat<> and InstAlias<>). The actual encoding 113// is handled by the destination instructions, which use t2_so_imm. 114def t2_so_imm_not_asmoperand : AsmOperandClass { let Name = "T2SOImmNot"; } 115def t2_so_imm_not : Operand<i32>, PatLeaf<(imm), [{ 116 return ARM_AM::getT2SOImmVal(~((uint32_t)N->getZExtValue())) != -1; 117}], t2_so_imm_not_XFORM> { 118 let ParserMatchClass = t2_so_imm_not_asmoperand; 119} 120 121// t2_so_imm_notSext - match an immediate that is a complement of a t2_so_imm 122// if the upper 16 bits are zero. 123def t2_so_imm_notSext : Operand<i32>, PatLeaf<(imm), [{ 124 APInt apIntN = N->getAPIntValue(); 125 if (!apIntN.isIntN(16)) return false; 126 unsigned N16bitSignExt = apIntN.trunc(16).sext(32).getZExtValue(); 127 return ARM_AM::getT2SOImmVal(~N16bitSignExt) != -1; 128 }], t2_so_imm_notSext16_XFORM> { 129 let ParserMatchClass = t2_so_imm_not_asmoperand; 130} 131 132// t2_so_imm_neg - Match an immediate that is a negation of a t2_so_imm. 133def t2_so_imm_neg_asmoperand : AsmOperandClass { let Name = "T2SOImmNeg"; } 134def t2_so_imm_neg : Operand<i32>, ImmLeaf<i32, [{ 135 return Imm && ARM_AM::getT2SOImmVal(-(uint32_t)Imm) != -1; 136}], t2_so_imm_neg_XFORM> { 137 let ParserMatchClass = t2_so_imm_neg_asmoperand; 138} 139 140/// imm0_4095 predicate - True if the 32-bit immediate is in the range [0,4095]. 141def imm0_4095_asmoperand: ImmAsmOperand<0,4095> { let Name = "Imm0_4095"; } 142def imm0_4095 : Operand<i32>, ImmLeaf<i32, [{ 143 return Imm >= 0 && Imm < 4096; 144}]> { 145 let ParserMatchClass = imm0_4095_asmoperand; 146} 147 148def imm0_4095_neg_asmoperand: AsmOperandClass { let Name = "Imm0_4095Neg"; } 149def imm0_4095_neg : Operand<i32>, PatLeaf<(i32 imm), [{ 150 return (uint32_t)(-N->getZExtValue()) < 4096; 151}], imm_neg_XFORM> { 152 let ParserMatchClass = imm0_4095_neg_asmoperand; 153} 154 155def imm1_255_neg : PatLeaf<(i32 imm), [{ 156 uint32_t Val = -N->getZExtValue(); 157 return (Val > 0 && Val < 255); 158}], imm_neg_XFORM>; 159 160def imm0_255_not : PatLeaf<(i32 imm), [{ 161 return (uint32_t)(~N->getZExtValue()) < 255; 162}], imm_not_XFORM>; 163 164def lo5AllOne : PatLeaf<(i32 imm), [{ 165 // Returns true if all low 5-bits are 1. 166 return (((uint32_t)N->getZExtValue()) & 0x1FUL) == 0x1FUL; 167}]>; 168 169// Define Thumb2 specific addressing modes. 170 171// t2_addr_offset_none := reg 172def MemNoOffsetT2AsmOperand 173 : AsmOperandClass { let Name = "MemNoOffsetT2"; } 174def t2_addr_offset_none : MemOperand { 175 let PrintMethod = "printAddrMode7Operand"; 176 let DecoderMethod = "DecodeGPRnopcRegisterClass"; 177 let ParserMatchClass = MemNoOffsetT2AsmOperand; 178 let MIOperandInfo = (ops GPRnopc:$base); 179} 180 181// t2_nosp_addr_offset_none := reg 182def MemNoOffsetT2NoSpAsmOperand 183 : AsmOperandClass { let Name = "MemNoOffsetT2NoSp"; } 184def t2_nosp_addr_offset_none : MemOperand { 185 let PrintMethod = "printAddrMode7Operand"; 186 let DecoderMethod = "DecoderGPRRegisterClass"; 187 let ParserMatchClass = MemNoOffsetT2NoSpAsmOperand; 188 let MIOperandInfo = (ops rGPR:$base); 189} 190 191// t2addrmode_imm12 := reg + imm12 192def t2addrmode_imm12_asmoperand : AsmOperandClass {let Name="MemUImm12Offset";} 193def t2addrmode_imm12 : MemOperand, 194 ComplexPattern<i32, 2, "SelectT2AddrModeImm12", []> { 195 let PrintMethod = "printAddrModeImm12Operand<false>"; 196 let EncoderMethod = "getAddrModeImm12OpValue"; 197 let DecoderMethod = "DecodeT2AddrModeImm12"; 198 let ParserMatchClass = t2addrmode_imm12_asmoperand; 199 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm); 200} 201 202// t2ldrlabel := imm12 203def t2ldrlabel : MemOperand { 204 let EncoderMethod = "getAddrModeImm12OpValue"; 205 let PrintMethod = "printThumbLdrLabelOperand"; 206} 207 208def t2ldr_pcrel_imm12_asmoperand : AsmOperandClass {let Name = "MemPCRelImm12";} 209def t2ldr_pcrel_imm12 : Operand<i32> { 210 let ParserMatchClass = t2ldr_pcrel_imm12_asmoperand; 211 // used for assembler pseudo instruction and maps to t2ldrlabel, so 212 // doesn't need encoder or print methods of its own. 213} 214 215// ADR instruction labels. 216def t2adrlabel : Operand<i32> { 217 let EncoderMethod = "getT2AdrLabelOpValue"; 218 let PrintMethod = "printAdrLabelOperand<0>"; 219} 220 221// t2addrmode_posimm8 := reg + imm8 222def MemPosImm8OffsetAsmOperand : AsmOperandClass { 223 let Name="MemPosImm8Offset"; 224 let RenderMethod = "addMemImmOffsetOperands"; 225} 226def t2addrmode_posimm8 : MemOperand { 227 let PrintMethod = "printT2AddrModeImm8Operand<false>"; 228 let EncoderMethod = "getT2AddrModeImmOpValue<8,0>"; 229 let DecoderMethod = "DecodeT2AddrModeImm8"; 230 let ParserMatchClass = MemPosImm8OffsetAsmOperand; 231 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm); 232} 233 234// t2addrmode_negimm8 := reg - imm8 235def MemNegImm8OffsetAsmOperand : AsmOperandClass { 236 let Name="MemNegImm8Offset"; 237 let RenderMethod = "addMemImmOffsetOperands"; 238} 239def t2addrmode_negimm8 : MemOperand, 240 ComplexPattern<i32, 2, "SelectT2AddrModeImm8", []> { 241 let PrintMethod = "printT2AddrModeImm8Operand<false>"; 242 let EncoderMethod = "getT2AddrModeImmOpValue<8,0>"; 243 let DecoderMethod = "DecodeT2AddrModeImm8"; 244 let ParserMatchClass = MemNegImm8OffsetAsmOperand; 245 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm); 246} 247 248// t2addrmode_imm8 := reg +/- imm8 249def MemImm8OffsetAsmOperand : AsmOperandClass { 250 let Name = "MemImm8Offset"; 251 let RenderMethod = "addMemImmOffsetOperands"; 252} 253class T2AddrMode_Imm8 : MemOperand, 254 ComplexPattern<i32, 2, "SelectT2AddrModeImm8", []> { 255 let EncoderMethod = "getT2AddrModeImmOpValue<8,0>"; 256 let DecoderMethod = "DecodeT2AddrModeImm8"; 257 let ParserMatchClass = MemImm8OffsetAsmOperand; 258 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm); 259} 260 261def t2addrmode_imm8 : T2AddrMode_Imm8 { 262 let PrintMethod = "printT2AddrModeImm8Operand<false>"; 263} 264 265def t2addrmode_imm8_pre : T2AddrMode_Imm8 { 266 let PrintMethod = "printT2AddrModeImm8Operand<true>"; 267} 268 269def t2am_imm8_offset : MemOperand, 270 ComplexPattern<i32, 1, "SelectT2AddrModeImm8Offset", 271 [], [SDNPWantRoot]> { 272 let PrintMethod = "printT2AddrModeImm8OffsetOperand"; 273 let EncoderMethod = "getT2AddrModeImm8OffsetOpValue"; 274 let DecoderMethod = "DecodeT2Imm8"; 275} 276 277// t2addrmode_imm8s4 := reg +/- (imm8 << 2) 278def MemImm8s4OffsetAsmOperand : AsmOperandClass {let Name = "MemImm8s4Offset";} 279class T2AddrMode_Imm8s4 : MemOperand, 280 ComplexPattern<i32, 2, "SelectT2AddrModeImm8<2>", []> { 281 let EncoderMethod = "getT2AddrModeImm8s4OpValue"; 282 let DecoderMethod = "DecodeT2AddrModeImm8s4"; 283 let ParserMatchClass = MemImm8s4OffsetAsmOperand; 284 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm); 285} 286 287def t2addrmode_imm8s4 : T2AddrMode_Imm8s4 { 288 let PrintMethod = "printT2AddrModeImm8s4Operand<false>"; 289} 290 291def t2addrmode_imm8s4_pre : T2AddrMode_Imm8s4 { 292 let PrintMethod = "printT2AddrModeImm8s4Operand<true>"; 293} 294 295def t2am_imm8s4_offset_asmoperand : AsmOperandClass { let Name = "Imm8s4"; } 296def t2am_imm8s4_offset : MemOperand { 297 let PrintMethod = "printT2AddrModeImm8s4OffsetOperand"; 298 let EncoderMethod = "getT2ScaledImmOpValue<8,2>"; 299 let DecoderMethod = "DecodeT2Imm8S4"; 300} 301 302// t2addrmode_imm7s4 := reg +/- (imm7 << 2) 303def MemImm7s4OffsetAsmOperand : AsmOperandClass {let Name = "MemImm7s4Offset";} 304class T2AddrMode_Imm7s4 : MemOperand { 305 let EncoderMethod = "getT2AddrModeImm7s4OpValue"; 306 let DecoderMethod = "DecodeT2AddrModeImm7<2,0>"; 307 let ParserMatchClass = MemImm7s4OffsetAsmOperand; 308 let MIOperandInfo = (ops GPRnopc:$base, i32imm:$offsimm); 309} 310 311def t2addrmode_imm7s4 : T2AddrMode_Imm7s4 { 312 // They are printed the same way as the imm8 version 313 let PrintMethod = "printT2AddrModeImm8s4Operand<false>"; 314} 315 316def t2addrmode_imm7s4_pre : T2AddrMode_Imm7s4 { 317 // They are printed the same way as the imm8 version 318 let PrintMethod = "printT2AddrModeImm8s4Operand<true>"; 319} 320 321def t2am_imm7s4_offset_asmoperand : AsmOperandClass { let Name = "Imm7s4"; } 322def t2am_imm7s4_offset : MemOperand { 323 // They are printed the same way as the imm8 version 324 let PrintMethod = "printT2AddrModeImm8s4OffsetOperand"; 325 let ParserMatchClass = t2am_imm7s4_offset_asmoperand; 326 let EncoderMethod = "getT2ScaledImmOpValue<7,2>"; 327 let DecoderMethod = "DecodeT2Imm7S4"; 328} 329 330// t2addrmode_imm0_1020s4 := reg + (imm8 << 2) 331def MemImm0_1020s4OffsetAsmOperand : AsmOperandClass { 332 let Name = "MemImm0_1020s4Offset"; 333} 334def t2addrmode_imm0_1020s4 : MemOperand, 335 ComplexPattern<i32, 2, "SelectT2AddrModeExclusive"> { 336 let PrintMethod = "printT2AddrModeImm0_1020s4Operand"; 337 let EncoderMethod = "getT2AddrModeImm0_1020s4OpValue"; 338 let DecoderMethod = "DecodeT2AddrModeImm0_1020s4"; 339 let ParserMatchClass = MemImm0_1020s4OffsetAsmOperand; 340 let MIOperandInfo = (ops GPRnopc:$base, i32imm:$offsimm); 341} 342 343// t2addrmode_so_reg := reg + (reg << imm2) 344def t2addrmode_so_reg_asmoperand : AsmOperandClass {let Name="T2MemRegOffset";} 345def t2addrmode_so_reg : MemOperand, 346 ComplexPattern<i32, 3, "SelectT2AddrModeSoReg", []> { 347 let PrintMethod = "printT2AddrModeSoRegOperand"; 348 let EncoderMethod = "getT2AddrModeSORegOpValue"; 349 let DecoderMethod = "DecodeT2AddrModeSOReg"; 350 let ParserMatchClass = t2addrmode_so_reg_asmoperand; 351 let MIOperandInfo = (ops GPRnopc:$base, rGPR:$offsreg, i32imm:$offsimm); 352} 353 354// Addresses for the TBB/TBH instructions. 355def addrmode_tbb_asmoperand : AsmOperandClass { let Name = "MemTBB"; } 356def addrmode_tbb : MemOperand { 357 let PrintMethod = "printAddrModeTBB"; 358 let ParserMatchClass = addrmode_tbb_asmoperand; 359 let MIOperandInfo = (ops GPR:$Rn, rGPR:$Rm); 360} 361def addrmode_tbh_asmoperand : AsmOperandClass { let Name = "MemTBH"; } 362def addrmode_tbh : MemOperand { 363 let PrintMethod = "printAddrModeTBH"; 364 let ParserMatchClass = addrmode_tbh_asmoperand; 365 let MIOperandInfo = (ops GPR:$Rn, rGPR:$Rm); 366} 367 368// Define ARMv8.1-M specific addressing modes. 369 370// Label operands for BF/BFL/WLS/DLS/LE 371class BFLabelOp<string signed, string isNeg, string zeroPermitted, string size, 372 string fixup> 373 : Operand<OtherVT> { 374 let EncoderMethod = !strconcat("getBFTargetOpValue<", isNeg, ", ", 375 fixup, ">"); 376 let OperandType = "OPERAND_PCREL"; 377 let DecoderMethod = !strconcat("DecodeBFLabelOperand<", signed, ", ", 378 isNeg, ", ", zeroPermitted, ", ", size, ">"); 379} 380def bflabel_u4 : BFLabelOp<"false", "false", "false", "4", "ARM::fixup_bf_branch">; 381def bflabel_s12 : BFLabelOp<"true", "false", "true", "12", "ARM::fixup_bfc_target">; 382def bflabel_s16 : BFLabelOp<"true", "false", "true", "16", "ARM::fixup_bf_target">; 383def bflabel_s18 : BFLabelOp<"true", "false", "true", "18", "ARM::fixup_bfl_target">; 384 385def wlslabel_u11_asmoperand : AsmOperandClass { 386 let Name = "WLSLabel"; 387 let RenderMethod = "addImmOperands"; 388 let PredicateMethod = "isUnsignedOffset<11, 1>"; 389 let DiagnosticString = 390 "loop end is out of range or not a positive multiple of 2"; 391} 392def wlslabel_u11 : BFLabelOp<"false", "false", "true", "11", "ARM::fixup_wls"> { 393 let ParserMatchClass = wlslabel_u11_asmoperand; 394} 395def lelabel_u11_asmoperand : AsmOperandClass { 396 let Name = "LELabel"; 397 let RenderMethod = "addImmOperands"; 398 let PredicateMethod = "isLEOffset"; 399 let DiagnosticString = 400 "loop start is out of range or not a negative multiple of 2"; 401} 402def lelabel_u11 : BFLabelOp<"false", "true", "true", "11", "ARM::fixup_le"> { 403 let ParserMatchClass = lelabel_u11_asmoperand; 404} 405 406def bfafter_target : Operand<OtherVT> { 407 let EncoderMethod = "getBFAfterTargetOpValue"; 408 let OperandType = "OPERAND_PCREL"; 409 let DecoderMethod = "DecodeBFAfterTargetOperand"; 410} 411 412// pred operand excluding AL 413def pred_noal_asmoperand : AsmOperandClass { 414 let Name = "CondCodeNoAL"; 415 let RenderMethod = "addITCondCodeOperands"; 416 let PredicateMethod = "isITCondCodeNoAL"; 417 let ParserMethod = "parseITCondCode"; 418} 419def pred_noal : Operand<i32> { 420 let PrintMethod = "printMandatoryPredicateOperand"; 421 let ParserMatchClass = pred_noal_asmoperand; 422 let DecoderMethod = "DecodePredNoALOperand"; 423} 424 425 426// CSEL aliases inverted predicate 427def pred_noal_inv_asmoperand : AsmOperandClass { 428 let Name = "CondCodeNoALInv"; 429 let RenderMethod = "addITCondCodeInvOperands"; 430 let PredicateMethod = "isITCondCodeNoAL"; 431 let ParserMethod = "parseITCondCode"; 432} 433def pred_noal_inv : Operand<i32> { 434 let PrintMethod = "printMandatoryInvertedPredicateOperand"; 435 let ParserMatchClass = pred_noal_inv_asmoperand; 436} 437//===----------------------------------------------------------------------===// 438// Multiclass helpers... 439// 440 441 442class T2OneRegImm<dag oops, dag iops, InstrItinClass itin, 443 string opc, string asm, list<dag> pattern> 444 : T2I<oops, iops, itin, opc, asm, pattern> { 445 bits<4> Rd; 446 bits<12> imm; 447 448 let Inst{11-8} = Rd; 449 let Inst{26} = imm{11}; 450 let Inst{14-12} = imm{10-8}; 451 let Inst{7-0} = imm{7-0}; 452} 453 454 455class T2sOneRegImm<dag oops, dag iops, InstrItinClass itin, 456 string opc, string asm, list<dag> pattern> 457 : T2sI<oops, iops, itin, opc, asm, pattern> { 458 bits<4> Rd; 459 bits<4> Rn; 460 bits<12> imm; 461 462 let Inst{11-8} = Rd; 463 let Inst{26} = imm{11}; 464 let Inst{14-12} = imm{10-8}; 465 let Inst{7-0} = imm{7-0}; 466} 467 468class T2OneRegCmpImm<dag oops, dag iops, InstrItinClass itin, 469 string opc, string asm, list<dag> pattern> 470 : T2I<oops, iops, itin, opc, asm, pattern> { 471 bits<4> Rn; 472 bits<12> imm; 473 474 let Inst{19-16} = Rn; 475 let Inst{26} = imm{11}; 476 let Inst{14-12} = imm{10-8}; 477 let Inst{7-0} = imm{7-0}; 478} 479 480 481class T2OneRegShiftedReg<dag oops, dag iops, InstrItinClass itin, 482 string opc, string asm, list<dag> pattern> 483 : T2I<oops, iops, itin, opc, asm, pattern> { 484 bits<4> Rd; 485 bits<12> ShiftedRm; 486 487 let Inst{11-8} = Rd; 488 let Inst{3-0} = ShiftedRm{3-0}; 489 let Inst{5-4} = ShiftedRm{6-5}; 490 let Inst{14-12} = ShiftedRm{11-9}; 491 let Inst{7-6} = ShiftedRm{8-7}; 492} 493 494class T2sOneRegShiftedReg<dag oops, dag iops, InstrItinClass itin, 495 string opc, string asm, list<dag> pattern> 496 : T2sI<oops, iops, itin, opc, asm, pattern> { 497 bits<4> Rd; 498 bits<12> ShiftedRm; 499 500 let Inst{11-8} = Rd; 501 let Inst{3-0} = ShiftedRm{3-0}; 502 let Inst{5-4} = ShiftedRm{6-5}; 503 let Inst{14-12} = ShiftedRm{11-9}; 504 let Inst{7-6} = ShiftedRm{8-7}; 505} 506 507class T2OneRegCmpShiftedReg<dag oops, dag iops, InstrItinClass itin, 508 string opc, string asm, list<dag> pattern> 509 : T2I<oops, iops, itin, opc, asm, pattern> { 510 bits<4> Rn; 511 bits<12> ShiftedRm; 512 513 let Inst{19-16} = Rn; 514 let Inst{3-0} = ShiftedRm{3-0}; 515 let Inst{5-4} = ShiftedRm{6-5}; 516 let Inst{14-12} = ShiftedRm{11-9}; 517 let Inst{7-6} = ShiftedRm{8-7}; 518} 519 520class T2TwoReg<dag oops, dag iops, InstrItinClass itin, 521 string opc, string asm, list<dag> pattern> 522 : T2I<oops, iops, itin, opc, asm, pattern> { 523 bits<4> Rd; 524 bits<4> Rm; 525 526 let Inst{11-8} = Rd; 527 let Inst{3-0} = Rm; 528} 529 530class T2sTwoReg<dag oops, dag iops, InstrItinClass itin, 531 string opc, string asm, list<dag> pattern> 532 : T2sI<oops, iops, itin, opc, asm, pattern> { 533 bits<4> Rd; 534 bits<4> Rm; 535 536 let Inst{11-8} = Rd; 537 let Inst{3-0} = Rm; 538} 539 540class T2TwoRegCmp<dag oops, dag iops, InstrItinClass itin, 541 string opc, string asm, list<dag> pattern> 542 : T2I<oops, iops, itin, opc, asm, pattern> { 543 bits<4> Rn; 544 bits<4> Rm; 545 546 let Inst{19-16} = Rn; 547 let Inst{3-0} = Rm; 548} 549 550 551class T2TwoRegImm<dag oops, dag iops, InstrItinClass itin, 552 string opc, string asm, list<dag> pattern> 553 : T2I<oops, iops, itin, opc, asm, pattern> { 554 bits<4> Rd; 555 bits<4> Rn; 556 bits<12> imm; 557 558 let Inst{11-8} = Rd; 559 let Inst{19-16} = Rn; 560 let Inst{26} = imm{11}; 561 let Inst{14-12} = imm{10-8}; 562 let Inst{7-0} = imm{7-0}; 563} 564 565class T2sTwoRegImm<dag oops, dag iops, InstrItinClass itin, 566 string opc, string asm, list<dag> pattern> 567 : T2sI<oops, iops, itin, opc, asm, pattern> { 568 bits<4> Rd; 569 bits<4> Rn; 570 bits<12> imm; 571 572 let Inst{11-8} = Rd; 573 let Inst{19-16} = Rn; 574 let Inst{26} = imm{11}; 575 let Inst{14-12} = imm{10-8}; 576 let Inst{7-0} = imm{7-0}; 577} 578 579class T2TwoRegShiftImm<dag oops, dag iops, InstrItinClass itin, 580 string opc, string asm, list<dag> pattern> 581 : T2I<oops, iops, itin, opc, asm, pattern> { 582 bits<4> Rd; 583 bits<4> Rm; 584 bits<5> imm; 585 586 let Inst{11-8} = Rd; 587 let Inst{3-0} = Rm; 588 let Inst{14-12} = imm{4-2}; 589 let Inst{7-6} = imm{1-0}; 590} 591 592class T2sTwoRegShiftImm<dag oops, dag iops, InstrItinClass itin, 593 string opc, string asm, list<dag> pattern> 594 : T2sI<oops, iops, itin, opc, asm, pattern> { 595 bits<4> Rd; 596 bits<4> Rm; 597 bits<5> imm; 598 599 let Inst{11-8} = Rd; 600 let Inst{3-0} = Rm; 601 let Inst{14-12} = imm{4-2}; 602 let Inst{7-6} = imm{1-0}; 603} 604 605class T2ThreeReg<dag oops, dag iops, InstrItinClass itin, 606 string opc, string asm, list<dag> pattern> 607 : T2I<oops, iops, itin, opc, asm, pattern> { 608 bits<4> Rd; 609 bits<4> Rn; 610 bits<4> Rm; 611 612 let Inst{11-8} = Rd; 613 let Inst{19-16} = Rn; 614 let Inst{3-0} = Rm; 615} 616 617class T2ThreeRegNoP<dag oops, dag iops, InstrItinClass itin, 618 string asm, list<dag> pattern> 619 : T2XI<oops, iops, itin, asm, pattern> { 620 bits<4> Rd; 621 bits<4> Rn; 622 bits<4> Rm; 623 624 let Inst{11-8} = Rd; 625 let Inst{19-16} = Rn; 626 let Inst{3-0} = Rm; 627} 628 629class T2sThreeReg<dag oops, dag iops, InstrItinClass itin, 630 string opc, string asm, list<dag> pattern> 631 : T2sI<oops, iops, itin, opc, asm, pattern> { 632 bits<4> Rd; 633 bits<4> Rn; 634 bits<4> Rm; 635 636 let Inst{11-8} = Rd; 637 let Inst{19-16} = Rn; 638 let Inst{3-0} = Rm; 639} 640 641class T2TwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin, 642 string opc, string asm, list<dag> pattern> 643 : T2I<oops, iops, itin, opc, asm, pattern> { 644 bits<4> Rd; 645 bits<4> Rn; 646 bits<12> ShiftedRm; 647 648 let Inst{11-8} = Rd; 649 let Inst{19-16} = Rn; 650 let Inst{3-0} = ShiftedRm{3-0}; 651 let Inst{5-4} = ShiftedRm{6-5}; 652 let Inst{14-12} = ShiftedRm{11-9}; 653 let Inst{7-6} = ShiftedRm{8-7}; 654} 655 656class T2sTwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin, 657 string opc, string asm, list<dag> pattern> 658 : T2sI<oops, iops, itin, opc, asm, pattern> { 659 bits<4> Rd; 660 bits<4> Rn; 661 bits<12> ShiftedRm; 662 663 let Inst{11-8} = Rd; 664 let Inst{19-16} = Rn; 665 let Inst{3-0} = ShiftedRm{3-0}; 666 let Inst{5-4} = ShiftedRm{6-5}; 667 let Inst{14-12} = ShiftedRm{11-9}; 668 let Inst{7-6} = ShiftedRm{8-7}; 669} 670 671class T2FourReg<dag oops, dag iops, InstrItinClass itin, 672 string opc, string asm, list<dag> pattern> 673 : T2I<oops, iops, itin, opc, asm, pattern> { 674 bits<4> Rd; 675 bits<4> Rn; 676 bits<4> Rm; 677 bits<4> Ra; 678 679 let Inst{19-16} = Rn; 680 let Inst{15-12} = Ra; 681 let Inst{11-8} = Rd; 682 let Inst{3-0} = Rm; 683} 684 685class T2MulLong<bits<3> opc22_20, bits<4> opc7_4, 686 string opc, list<dag> pattern> 687 : T2I<(outs rGPR:$RdLo, rGPR:$RdHi), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL64, 688 opc, "\t$RdLo, $RdHi, $Rn, $Rm", pattern>, 689 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]> { 690 bits<4> RdLo; 691 bits<4> RdHi; 692 bits<4> Rn; 693 bits<4> Rm; 694 695 let Inst{31-23} = 0b111110111; 696 let Inst{22-20} = opc22_20; 697 let Inst{19-16} = Rn; 698 let Inst{15-12} = RdLo; 699 let Inst{11-8} = RdHi; 700 let Inst{7-4} = opc7_4; 701 let Inst{3-0} = Rm; 702} 703class T2MlaLong<bits<3> opc22_20, bits<4> opc7_4, string opc> 704 : T2I<(outs rGPR:$RdLo, rGPR:$RdHi), 705 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi), IIC_iMAC64, 706 opc, "\t$RdLo, $RdHi, $Rn, $Rm", []>, 707 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, 708 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]> { 709 bits<4> RdLo; 710 bits<4> RdHi; 711 bits<4> Rn; 712 bits<4> Rm; 713 714 let Inst{31-23} = 0b111110111; 715 let Inst{22-20} = opc22_20; 716 let Inst{19-16} = Rn; 717 let Inst{15-12} = RdLo; 718 let Inst{11-8} = RdHi; 719 let Inst{7-4} = opc7_4; 720 let Inst{3-0} = Rm; 721} 722 723 724/// T2I_bin_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a 725/// binary operation that produces a value. These are predicable and can be 726/// changed to modify CPSR. 727multiclass T2I_bin_irs<bits<4> opcod, string opc, 728 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis, 729 SDPatternOperator opnode, bit Commutable = 0, 730 string wide = ""> { 731 // shifted imm 732 def ri : T2sTwoRegImm< 733 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), iii, 734 opc, "\t$Rd, $Rn, $imm", 735 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]>, 736 Sched<[WriteALU, ReadALU]> { 737 let Inst{31-27} = 0b11110; 738 let Inst{25} = 0; 739 let Inst{24-21} = opcod; 740 let Inst{15} = 0; 741 } 742 // register 743 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), iir, 744 opc, !strconcat(wide, "\t$Rd, $Rn, $Rm"), 745 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]>, 746 Sched<[WriteALU, ReadALU, ReadALU]> { 747 let isCommutable = Commutable; 748 let Inst{31-27} = 0b11101; 749 let Inst{26-25} = 0b01; 750 let Inst{24-21} = opcod; 751 let Inst{15} = 0b0; 752 // In most of these instructions, and most versions of the Arm 753 // architecture, bit 15 of this encoding is listed as (0) rather 754 // than 0, i.e. setting it to 1 is UNPREDICTABLE or a soft-fail 755 // rather than a hard failure. In v8.1-M, this requirement is 756 // upgraded to a hard one for ORR, so that the encodings with 1 757 // in this bit can be reused for other instructions (such as 758 // CSEL). Setting Unpredictable{15} = 1 here would reintroduce 759 // that encoding clash in the auto- generated MC decoder, so I 760 // comment it out. 761 let Unpredictable{15} = !if(!eq(opcod, 0b0010), 0b0, 0b1); 762 let Inst{14-12} = 0b000; // imm3 763 let Inst{7-6} = 0b00; // imm2 764 let Inst{5-4} = 0b00; // type 765 } 766 // shifted register 767 def rs : T2sTwoRegShiftedReg< 768 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm), iis, 769 opc, !strconcat(wide, "\t$Rd, $Rn, $ShiftedRm"), 770 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]>, 771 Sched<[WriteALUsi, ReadALU]> { 772 let Inst{31-27} = 0b11101; 773 let Inst{26-25} = 0b01; 774 let Inst{24-21} = opcod; 775 let Inst{15} = 0; 776 let Unpredictable{15} = !if(!eq(opcod, 0b0010), 0b0, 0b1); // see above 777 } 778 // Assembly aliases for optional destination operand when it's the same 779 // as the source operand. 780 def : t2InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"), 781 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, 782 t2_so_imm:$imm, pred:$p, 783 cc_out:$s)>; 784 def : t2InstAlias<!strconcat(opc, "${s}${p}", wide, " $Rdn, $Rm"), 785 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, 786 rGPR:$Rm, pred:$p, 787 cc_out:$s)>; 788 def : t2InstAlias<!strconcat(opc, "${s}${p}", wide, " $Rdn, $shift"), 789 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn, 790 t2_so_reg:$shift, pred:$p, 791 cc_out:$s)>; 792} 793 794/// T2I_bin_w_irs - Same as T2I_bin_irs except these operations need 795// the ".w" suffix to indicate that they are wide. 796multiclass T2I_bin_w_irs<bits<4> opcod, string opc, 797 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis, 798 SDPatternOperator opnode, bit Commutable = 0> : 799 T2I_bin_irs<opcod, opc, iii, iir, iis, opnode, Commutable, ".w"> { 800 // Assembler aliases w/ the ".w" suffix. 801 def : t2InstAlias<!strconcat(opc, "${s}${p}.w", " $Rd, $Rn, $imm"), 802 (!cast<Instruction>(NAME#"ri") rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p, 803 cc_out:$s)>; 804 // Assembler aliases w/o the ".w" suffix. 805 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $Rm"), 806 (!cast<Instruction>(NAME#"rr") rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, 807 cc_out:$s)>; 808 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $shift"), 809 (!cast<Instruction>(NAME#"rs") rGPR:$Rd, rGPR:$Rn, t2_so_reg:$shift, 810 pred:$p, cc_out:$s)>; 811 812 // and with the optional destination operand, too. 813 def : t2InstAlias<!strconcat(opc, "${s}${p}.w", " $Rdn, $imm"), 814 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, 815 pred:$p, cc_out:$s)>; 816 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $Rm"), 817 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, 818 cc_out:$s)>; 819 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $shift"), 820 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$shift, 821 pred:$p, cc_out:$s)>; 822} 823 824/// T2I_rbin_is - Same as T2I_bin_irs except the order of operands are 825/// reversed. The 'rr' form is only defined for the disassembler; for codegen 826/// it is equivalent to the T2I_bin_irs counterpart. 827multiclass T2I_rbin_irs<bits<4> opcod, string opc, SDNode opnode> { 828 // shifted imm 829 def ri : T2sTwoRegImm< 830 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi, 831 opc, ".w\t$Rd, $Rn, $imm", 832 [(set rGPR:$Rd, (opnode t2_so_imm:$imm, rGPR:$Rn))]>, 833 Sched<[WriteALU, ReadALU]> { 834 let Inst{31-27} = 0b11110; 835 let Inst{25} = 0; 836 let Inst{24-21} = opcod; 837 let Inst{15} = 0; 838 } 839 // register 840 def rr : T2sThreeReg< 841 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr, 842 opc, "\t$Rd, $Rn, $Rm", 843 [/* For disassembly only; pattern left blank */]>, 844 Sched<[WriteALU, ReadALU, ReadALU]> { 845 let Inst{31-27} = 0b11101; 846 let Inst{26-25} = 0b01; 847 let Inst{24-21} = opcod; 848 let Inst{14-12} = 0b000; // imm3 849 let Inst{7-6} = 0b00; // imm2 850 let Inst{5-4} = 0b00; // type 851 } 852 // shifted register 853 def rs : T2sTwoRegShiftedReg< 854 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm), 855 IIC_iALUsir, opc, "\t$Rd, $Rn, $ShiftedRm", 856 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm, rGPR:$Rn))]>, 857 Sched<[WriteALUsi, ReadALU]> { 858 let Inst{31-27} = 0b11101; 859 let Inst{26-25} = 0b01; 860 let Inst{24-21} = opcod; 861 } 862} 863 864/// T2I_bin_s_irs - Similar to T2I_bin_irs except it sets the 's' bit so the 865/// instruction modifies the CPSR register. 866/// 867/// These opcodes will be converted to the real non-S opcodes by 868/// AdjustInstrPostInstrSelection after giving then an optional CPSR operand. 869let hasPostISelHook = 1, Defs = [CPSR] in { 870multiclass T2I_bin_s_irs<InstrItinClass iii, InstrItinClass iir, 871 InstrItinClass iis, SDNode opnode, 872 bit Commutable = 0> { 873 // shifted imm 874 def ri : t2PseudoInst<(outs rGPR:$Rd), 875 (ins GPRnopc:$Rn, t2_so_imm:$imm, pred:$p), 876 4, iii, 877 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn, 878 t2_so_imm:$imm))]>, 879 Sched<[WriteALU, ReadALU]>; 880 // register 881 def rr : t2PseudoInst<(outs rGPR:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm, pred:$p), 882 4, iir, 883 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn, 884 rGPR:$Rm))]>, 885 Sched<[WriteALU, ReadALU, ReadALU]> { 886 let isCommutable = Commutable; 887 } 888 // shifted register 889 def rs : t2PseudoInst<(outs rGPR:$Rd), 890 (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm, pred:$p), 891 4, iis, 892 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn, 893 t2_so_reg:$ShiftedRm))]>, 894 Sched<[WriteALUsi, ReadALUsr]>; 895} 896} 897 898/// T2I_rbin_s_is - Same as T2I_bin_s_irs, except selection DAG 899/// operands are reversed. 900let hasPostISelHook = 1, Defs = [CPSR] in { 901multiclass T2I_rbin_s_is<SDNode opnode> { 902 // shifted imm 903 def ri : t2PseudoInst<(outs rGPR:$Rd), 904 (ins rGPR:$Rn, t2_so_imm:$imm, pred:$p), 905 4, IIC_iALUi, 906 [(set rGPR:$Rd, CPSR, (opnode t2_so_imm:$imm, 907 rGPR:$Rn))]>, 908 Sched<[WriteALU, ReadALU]>; 909 // shifted register 910 def rs : t2PseudoInst<(outs rGPR:$Rd), 911 (ins rGPR:$Rn, t2_so_reg:$ShiftedRm, pred:$p), 912 4, IIC_iALUsi, 913 [(set rGPR:$Rd, CPSR, (opnode t2_so_reg:$ShiftedRm, 914 rGPR:$Rn))]>, 915 Sched<[WriteALUsi, ReadALU]>; 916} 917} 918 919/// T2I_bin_ii12rs - Defines a set of (op reg, {so_imm|imm0_4095|r|so_reg}) 920/// patterns for a binary operation that produces a value. 921multiclass T2I_bin_ii12rs<bits<3> op23_21, string opc, SDNode opnode, 922 bit Commutable = 0> { 923 // shifted imm 924 // The register-immediate version is re-materializable. This is useful 925 // in particular for taking the address of a local. 926 let isReMaterializable = 1 in { 927 def spImm : T2sTwoRegImm< 928 (outs GPRsp:$Rd), (ins GPRsp:$Rn, t2_so_imm:$imm), IIC_iALUi, 929 opc, ".w\t$Rd, $Rn, $imm", 930 []>, 931 Sched<[WriteALU, ReadALU]> { 932 let Rn = 13; 933 let Rd = 13; 934 935 let Inst{31-27} = 0b11110; 936 let Inst{25-24} = 0b01; 937 let Inst{23-21} = op23_21; 938 let Inst{15} = 0; 939 940 let DecoderMethod = "DecodeT2AddSubSPImm"; 941 } 942 943 def ri : T2sTwoRegImm< 944 (outs rGPR:$Rd), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iALUi, 945 opc, ".w\t$Rd, $Rn, $imm", 946 [(set rGPR:$Rd, (opnode GPRnopc:$Rn, t2_so_imm:$imm))]>, 947 Sched<[WriteALU, ReadALU]> { 948 let Inst{31-27} = 0b11110; 949 let Inst{25} = 0; 950 let Inst{24} = 1; 951 let Inst{23-21} = op23_21; 952 let Inst{15} = 0; 953 } 954 } 955 // 12-bit imm 956 def ri12 : T2I< 957 (outs rGPR:$Rd), (ins GPR:$Rn, imm0_4095:$imm), IIC_iALUi, 958 !strconcat(opc, "w"), "\t$Rd, $Rn, $imm", 959 [(set rGPR:$Rd, (opnode GPR:$Rn, imm0_4095:$imm))]>, 960 Sched<[WriteALU, ReadALU]> { 961 bits<4> Rd; 962 bits<4> Rn; 963 bits<12> imm; 964 let Inst{31-27} = 0b11110; 965 let Inst{26} = imm{11}; 966 let Inst{25-24} = 0b10; 967 let Inst{23-21} = op23_21; 968 let Inst{20} = 0; // The S bit. 969 let Inst{19-16} = Rn; 970 let Inst{15} = 0; 971 let Inst{14-12} = imm{10-8}; 972 let Inst{11-8} = Rd; 973 let Inst{7-0} = imm{7-0}; 974 } 975 def spImm12 : T2I< 976 (outs GPRsp:$Rd), (ins GPRsp:$Rn, imm0_4095:$imm), IIC_iALUi, 977 !strconcat(opc, "w"), "\t$Rd, $Rn, $imm", 978 []>, 979 Sched<[WriteALU, ReadALU]> { 980 bits<4> Rd = 13; 981 bits<4> Rn = 13; 982 bits<12> imm; 983 let Inst{31-27} = 0b11110; 984 let Inst{26} = imm{11}; 985 let Inst{25-24} = 0b10; 986 let Inst{23-21} = op23_21; 987 let Inst{20} = 0; // The S bit. 988 let Inst{19-16} = Rn; 989 let Inst{15} = 0; 990 let Inst{14-12} = imm{10-8}; 991 let Inst{11-8} = Rd; 992 let Inst{7-0} = imm{7-0}; 993 let DecoderMethod = "DecodeT2AddSubSPImm"; 994 } 995 // register 996 def rr : T2sThreeReg<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm), 997 IIC_iALUr, opc, ".w\t$Rd, $Rn, $Rm", 998 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, rGPR:$Rm))]>, 999 Sched<[WriteALU, ReadALU, ReadALU]> { 1000 let isCommutable = Commutable; 1001 let Inst{31-27} = 0b11101; 1002 let Inst{26-25} = 0b01; 1003 let Inst{24} = 1; 1004 let Inst{23-21} = op23_21; 1005 let Inst{14-12} = 0b000; // imm3 1006 let Inst{7-6} = 0b00; // imm2 1007 let Inst{5-4} = 0b00; // type 1008 } 1009 // shifted register 1010 def rs : T2sTwoRegShiftedReg< 1011 (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm), 1012 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm", 1013 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, t2_so_reg:$ShiftedRm))]>, 1014 Sched<[WriteALUsi, ReadALU]> { 1015 let Inst{31-27} = 0b11101; 1016 let Inst{26-25} = 0b01; 1017 let Inst{24} = 1; 1018 let Inst{23-21} = op23_21; 1019 } 1020} 1021 1022/// T2I_adde_sube_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns 1023/// for a binary operation that produces a value and use the carry 1024/// bit. It's not predicable. 1025multiclass T2I_adde_sube_irs<bits<4> opcod, string opc, SDNode opnode, 1026 bit Commutable = 0, bit PostISelHook = 0> { 1027 let Defs = [CPSR], Uses = [CPSR], hasPostISelHook = PostISelHook in { 1028 // shifted imm 1029 def ri : T2sTwoRegImm<(outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), 1030 IIC_iALUi, opc, "\t$Rd, $Rn, $imm", 1031 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, t2_so_imm:$imm, CPSR))]>, 1032 Requires<[IsThumb2]>, Sched<[WriteALU, ReadALU]> { 1033 let Inst{31-27} = 0b11110; 1034 let Inst{25} = 0; 1035 let Inst{24-21} = opcod; 1036 let Inst{15} = 0; 1037 } 1038 // register 1039 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr, 1040 opc, ".w\t$Rd, $Rn, $Rm", 1041 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, rGPR:$Rm, CPSR))]>, 1042 Requires<[IsThumb2]>, Sched<[WriteALU, ReadALU, ReadALU]> { 1043 let isCommutable = Commutable; 1044 let Inst{31-27} = 0b11101; 1045 let Inst{26-25} = 0b01; 1046 let Inst{24-21} = opcod; 1047 let Inst{14-12} = 0b000; // imm3 1048 let Inst{7-6} = 0b00; // imm2 1049 let Inst{5-4} = 0b00; // type 1050 } 1051 // shifted register 1052 def rs : T2sTwoRegShiftedReg< 1053 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm), 1054 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm", 1055 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm, CPSR))]>, 1056 Requires<[IsThumb2]>, Sched<[WriteALUsi, ReadALU]> { 1057 let Inst{31-27} = 0b11101; 1058 let Inst{26-25} = 0b01; 1059 let Inst{24-21} = opcod; 1060 } 1061 } 1062 // Shortened forms 1063 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $imm"), 1064 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p, 1065 cc_out:$s)>; 1066 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $Rm"), 1067 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, 1068 cc_out:$s)>; 1069 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $ShiftedRm"), 1070 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$ShiftedRm, pred:$p, 1071 cc_out:$s)>; 1072 def : t2InstAlias<!strconcat(opc, "${s}${p}", "$Rdn, $imm"), 1073 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p, 1074 cc_out:$s)>; 1075 def : t2InstAlias<!strconcat(opc, "${s}${p}", "$Rdn, $Rm"), 1076 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, 1077 cc_out:$s)>; 1078 def : t2InstAlias<!strconcat(opc, "${s}${p}", "$Rdn, $ShiftedRm"), 1079 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$ShiftedRm, pred:$p, 1080 cc_out:$s)>; 1081} 1082 1083/// T2I_sh_ir - Defines a set of (op reg, {so_imm|r}) patterns for a shift / 1084// rotate operation that produces a value. 1085multiclass T2I_sh_ir<bits<2> opcod, string opc, Operand ty, SDNode opnode> { 1086 // 5-bit imm 1087 def ri : T2sTwoRegShiftImm< 1088 (outs rGPR:$Rd), (ins rGPR:$Rm, ty:$imm), IIC_iMOVsi, 1089 opc, ".w\t$Rd, $Rm, $imm", 1090 [(set rGPR:$Rd, (opnode rGPR:$Rm, (i32 ty:$imm)))]>, 1091 Sched<[WriteALU]> { 1092 let Inst{31-27} = 0b11101; 1093 let Inst{26-21} = 0b010010; 1094 let Inst{19-16} = 0b1111; // Rn 1095 let Inst{15} = 0b0; 1096 let Inst{5-4} = opcod; 1097 } 1098 // register 1099 def rr : T2sThreeReg< 1100 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMOVsr, 1101 opc, ".w\t$Rd, $Rn, $Rm", 1102 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]>, 1103 Sched<[WriteALU]> { 1104 let Inst{31-27} = 0b11111; 1105 let Inst{26-23} = 0b0100; 1106 let Inst{22-21} = opcod; 1107 let Inst{15-12} = 0b1111; 1108 let Inst{7-4} = 0b0000; 1109 } 1110 1111 // Optional destination register 1112 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $imm"), 1113 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, ty:$imm, pred:$p, 1114 cc_out:$s)>; 1115 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $Rm"), 1116 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, 1117 cc_out:$s)>; 1118 1119 // Assembler aliases w/o the ".w" suffix. 1120 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $imm"), 1121 (!cast<Instruction>(NAME#"ri") rGPR:$Rd, rGPR:$Rn, ty:$imm, pred:$p, 1122 cc_out:$s)>; 1123 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $Rm"), 1124 (!cast<Instruction>(NAME#"rr") rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, 1125 cc_out:$s)>; 1126 1127 // and with the optional destination operand, too. 1128 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $imm"), 1129 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, ty:$imm, pred:$p, 1130 cc_out:$s)>; 1131 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $Rm"), 1132 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, 1133 cc_out:$s)>; 1134} 1135 1136/// T2I_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test 1137/// patterns. Similar to T2I_bin_irs except the instruction does not produce 1138/// a explicit result, only implicitly set CPSR. 1139multiclass T2I_cmp_irs<bits<4> opcod, string opc, RegisterClass LHSGPR, 1140 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis, 1141 SDPatternOperator opnode> { 1142let isCompare = 1, Defs = [CPSR] in { 1143 // shifted imm 1144 def ri : T2OneRegCmpImm< 1145 (outs), (ins LHSGPR:$Rn, t2_so_imm:$imm), iii, 1146 opc, ".w\t$Rn, $imm", 1147 [(opnode LHSGPR:$Rn, t2_so_imm:$imm)]>, Sched<[WriteCMP]> { 1148 let Inst{31-27} = 0b11110; 1149 let Inst{25} = 0; 1150 let Inst{24-21} = opcod; 1151 let Inst{20} = 1; // The S bit. 1152 let Inst{15} = 0; 1153 let Inst{11-8} = 0b1111; // Rd 1154 } 1155 // register 1156 def rr : T2TwoRegCmp< 1157 (outs), (ins LHSGPR:$Rn, rGPR:$Rm), iir, 1158 opc, ".w\t$Rn, $Rm", 1159 [(opnode LHSGPR:$Rn, rGPR:$Rm)]>, Sched<[WriteCMP]> { 1160 let Inst{31-27} = 0b11101; 1161 let Inst{26-25} = 0b01; 1162 let Inst{24-21} = opcod; 1163 let Inst{20} = 1; // The S bit. 1164 let Inst{14-12} = 0b000; // imm3 1165 let Inst{11-8} = 0b1111; // Rd 1166 let Inst{7-6} = 0b00; // imm2 1167 let Inst{5-4} = 0b00; // type 1168 } 1169 // shifted register 1170 def rs : T2OneRegCmpShiftedReg< 1171 (outs), (ins LHSGPR:$Rn, t2_so_reg:$ShiftedRm), iis, 1172 opc, ".w\t$Rn, $ShiftedRm", 1173 [(opnode LHSGPR:$Rn, t2_so_reg:$ShiftedRm)]>, 1174 Sched<[WriteCMPsi]> { 1175 let Inst{31-27} = 0b11101; 1176 let Inst{26-25} = 0b01; 1177 let Inst{24-21} = opcod; 1178 let Inst{20} = 1; // The S bit. 1179 let Inst{11-8} = 0b1111; // Rd 1180 } 1181} 1182 1183 // Assembler aliases w/o the ".w" suffix. 1184 // No alias here for 'rr' version as not all instantiations of this 1185 // multiclass want one (CMP in particular, does not). 1186 def : t2InstAlias<!strconcat(opc, "${p}", " $Rn, $imm"), 1187 (!cast<Instruction>(NAME#"ri") LHSGPR:$Rn, t2_so_imm:$imm, pred:$p)>; 1188 def : t2InstAlias<!strconcat(opc, "${p}", " $Rn, $shift"), 1189 (!cast<Instruction>(NAME#"rs") LHSGPR:$Rn, t2_so_reg:$shift, pred:$p)>; 1190} 1191 1192/// T2I_ld - Defines a set of (op r, {imm12|imm8|so_reg}) load patterns. 1193multiclass T2I_ld<bit signed, bits<2> opcod, string opc, 1194 InstrItinClass iii, InstrItinClass iis, RegisterClass target, 1195 PatFrag opnode> { 1196 def i12 : T2Ii12<(outs target:$Rt), (ins t2addrmode_imm12:$addr), iii, 1197 opc, ".w\t$Rt, $addr", 1198 [(set target:$Rt, (opnode t2addrmode_imm12:$addr))]>, 1199 Sched<[WriteLd]> { 1200 bits<4> Rt; 1201 bits<17> addr; 1202 let Inst{31-25} = 0b1111100; 1203 let Inst{24} = signed; 1204 let Inst{23} = 1; 1205 let Inst{22-21} = opcod; 1206 let Inst{20} = 1; // load 1207 let Inst{19-16} = addr{16-13}; // Rn 1208 let Inst{15-12} = Rt; 1209 let Inst{11-0} = addr{11-0}; // imm 1210 1211 let DecoderMethod = "DecodeT2LoadImm12"; 1212 } 1213 def i8 : T2Ii8n <(outs target:$Rt), (ins t2addrmode_negimm8:$addr), iii, 1214 opc, "\t$Rt, $addr", 1215 [(set target:$Rt, (opnode t2addrmode_negimm8:$addr))]>, 1216 Sched<[WriteLd]> { 1217 bits<4> Rt; 1218 bits<13> addr; 1219 let Inst{31-27} = 0b11111; 1220 let Inst{26-25} = 0b00; 1221 let Inst{24} = signed; 1222 let Inst{23} = 0; 1223 let Inst{22-21} = opcod; 1224 let Inst{20} = 1; // load 1225 let Inst{19-16} = addr{12-9}; // Rn 1226 let Inst{15-12} = Rt; 1227 let Inst{11} = 1; 1228 // Offset: index==TRUE, wback==FALSE 1229 let Inst{10} = 1; // The P bit. 1230 let Inst{9} = addr{8}; // U 1231 let Inst{8} = 0; // The W bit. 1232 let Inst{7-0} = addr{7-0}; // imm 1233 1234 let DecoderMethod = "DecodeT2LoadImm8"; 1235 } 1236 def s : T2Iso <(outs target:$Rt), (ins t2addrmode_so_reg:$addr), iis, 1237 opc, ".w\t$Rt, $addr", 1238 [(set target:$Rt, (opnode t2addrmode_so_reg:$addr))]>, 1239 Sched<[WriteLd]> { 1240 let Inst{31-27} = 0b11111; 1241 let Inst{26-25} = 0b00; 1242 let Inst{24} = signed; 1243 let Inst{23} = 0; 1244 let Inst{22-21} = opcod; 1245 let Inst{20} = 1; // load 1246 let Inst{11-6} = 0b000000; 1247 1248 bits<4> Rt; 1249 let Inst{15-12} = Rt; 1250 1251 bits<10> addr; 1252 let Inst{19-16} = addr{9-6}; // Rn 1253 let Inst{3-0} = addr{5-2}; // Rm 1254 let Inst{5-4} = addr{1-0}; // imm 1255 1256 let DecoderMethod = "DecodeT2LoadShift"; 1257 } 1258 1259 // pci variant is very similar to i12, but supports negative offsets 1260 // from the PC. 1261 def pci : T2Ipc <(outs target:$Rt), (ins t2ldrlabel:$addr), iii, 1262 opc, ".w\t$Rt, $addr", 1263 [(set target:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]>, 1264 Sched<[WriteLd]> { 1265 let isReMaterializable = 1; 1266 let Inst{31-27} = 0b11111; 1267 let Inst{26-25} = 0b00; 1268 let Inst{24} = signed; 1269 let Inst{22-21} = opcod; 1270 let Inst{20} = 1; // load 1271 let Inst{19-16} = 0b1111; // Rn 1272 1273 bits<4> Rt; 1274 let Inst{15-12} = Rt{3-0}; 1275 1276 bits<13> addr; 1277 let Inst{23} = addr{12}; // add = (U == '1') 1278 let Inst{11-0} = addr{11-0}; 1279 1280 let DecoderMethod = "DecodeT2LoadLabel"; 1281 } 1282} 1283 1284/// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns. 1285multiclass T2I_st<bits<2> opcod, string opc, 1286 InstrItinClass iii, InstrItinClass iis, RegisterClass target, 1287 PatFrag opnode> { 1288 def i12 : T2Ii12<(outs), (ins target:$Rt, t2addrmode_imm12:$addr), iii, 1289 opc, ".w\t$Rt, $addr", 1290 [(opnode target:$Rt, t2addrmode_imm12:$addr)]>, 1291 Sched<[WriteST]> { 1292 let Inst{31-27} = 0b11111; 1293 let Inst{26-23} = 0b0001; 1294 let Inst{22-21} = opcod; 1295 let Inst{20} = 0; // !load 1296 1297 bits<4> Rt; 1298 let Inst{15-12} = Rt; 1299 1300 bits<17> addr; 1301 let addr{12} = 1; // add = TRUE 1302 let Inst{19-16} = addr{16-13}; // Rn 1303 let Inst{23} = addr{12}; // U 1304 let Inst{11-0} = addr{11-0}; // imm 1305 } 1306 def i8 : T2Ii8n <(outs), (ins target:$Rt, t2addrmode_negimm8:$addr), iii, 1307 opc, "\t$Rt, $addr", 1308 [(opnode target:$Rt, t2addrmode_negimm8:$addr)]>, 1309 Sched<[WriteST]> { 1310 let Inst{31-27} = 0b11111; 1311 let Inst{26-23} = 0b0000; 1312 let Inst{22-21} = opcod; 1313 let Inst{20} = 0; // !load 1314 let Inst{11} = 1; 1315 // Offset: index==TRUE, wback==FALSE 1316 let Inst{10} = 1; // The P bit. 1317 let Inst{8} = 0; // The W bit. 1318 1319 bits<4> Rt; 1320 let Inst{15-12} = Rt; 1321 1322 bits<13> addr; 1323 let Inst{19-16} = addr{12-9}; // Rn 1324 let Inst{9} = addr{8}; // U 1325 let Inst{7-0} = addr{7-0}; // imm 1326 } 1327 def s : T2Iso <(outs), (ins target:$Rt, t2addrmode_so_reg:$addr), iis, 1328 opc, ".w\t$Rt, $addr", 1329 [(opnode target:$Rt, t2addrmode_so_reg:$addr)]>, 1330 Sched<[WriteST]> { 1331 let Inst{31-27} = 0b11111; 1332 let Inst{26-23} = 0b0000; 1333 let Inst{22-21} = opcod; 1334 let Inst{20} = 0; // !load 1335 let Inst{11-6} = 0b000000; 1336 1337 bits<4> Rt; 1338 let Inst{15-12} = Rt; 1339 1340 bits<10> addr; 1341 let Inst{19-16} = addr{9-6}; // Rn 1342 let Inst{3-0} = addr{5-2}; // Rm 1343 let Inst{5-4} = addr{1-0}; // imm 1344 } 1345} 1346 1347/// T2I_ext_rrot - A unary operation with two forms: one whose operand is a 1348/// register and one whose operand is a register rotated by 8/16/24. 1349class T2I_ext_rrot_base<bits<3> opcod, dag iops, dag oops, 1350 string opc, string oprs, 1351 list<dag> pattern> 1352 : T2TwoReg<iops, oops, IIC_iEXTr, opc, oprs, pattern> { 1353 bits<2> rot; 1354 let Inst{31-27} = 0b11111; 1355 let Inst{26-23} = 0b0100; 1356 let Inst{22-20} = opcod; 1357 let Inst{19-16} = 0b1111; // Rn 1358 let Inst{15-12} = 0b1111; 1359 let Inst{7} = 1; 1360 let Inst{5-4} = rot; // rotate 1361} 1362 1363class T2I_ext_rrot<bits<3> opcod, string opc> 1364 : T2I_ext_rrot_base<opcod, 1365 (outs rGPR:$Rd), 1366 (ins rGPR:$Rm, rot_imm:$rot), 1367 opc, ".w\t$Rd, $Rm$rot", []>, 1368 Requires<[IsThumb2]>, 1369 Sched<[WriteALU, ReadALU]>; 1370 1371// UXTB16, SXTB16 - Requires HasDSP, does not need the .w qualifier. 1372class T2I_ext_rrot_xtb16<bits<3> opcod, string opc> 1373 : T2I_ext_rrot_base<opcod, 1374 (outs rGPR:$Rd), 1375 (ins rGPR:$Rm, rot_imm:$rot), 1376 opc, "\t$Rd, $Rm$rot", []>, 1377 Requires<[HasDSP, IsThumb2]>, 1378 Sched<[WriteALU, ReadALU]>; 1379 1380/// T2I_exta_rrot - A binary operation with two forms: one whose operand is a 1381/// register and one whose operand is a register rotated by 8/16/24. 1382class T2I_exta_rrot<bits<3> opcod, string opc> 1383 : T2ThreeReg<(outs rGPR:$Rd), 1384 (ins rGPR:$Rn, rGPR:$Rm, rot_imm:$rot), 1385 IIC_iEXTAsr, opc, "\t$Rd, $Rn, $Rm$rot", []>, 1386 Requires<[HasDSP, IsThumb2]>, 1387 Sched<[WriteALU, ReadALU]> { 1388 bits<2> rot; 1389 let Inst{31-27} = 0b11111; 1390 let Inst{26-23} = 0b0100; 1391 let Inst{22-20} = opcod; 1392 let Inst{15-12} = 0b1111; 1393 let Inst{7} = 1; 1394 let Inst{5-4} = rot; 1395} 1396 1397//===----------------------------------------------------------------------===// 1398// Instructions 1399//===----------------------------------------------------------------------===// 1400 1401//===----------------------------------------------------------------------===// 1402// Miscellaneous Instructions. 1403// 1404 1405class T2PCOneRegImm<dag oops, dag iops, InstrItinClass itin, 1406 string asm, list<dag> pattern> 1407 : T2XI<oops, iops, itin, asm, pattern> { 1408 bits<4> Rd; 1409 bits<12> label; 1410 1411 let Inst{11-8} = Rd; 1412 let Inst{26} = label{11}; 1413 let Inst{14-12} = label{10-8}; 1414 let Inst{7-0} = label{7-0}; 1415} 1416 1417// LEApcrel - Load a pc-relative address into a register without offending the 1418// assembler. 1419def t2ADR : T2PCOneRegImm<(outs rGPR:$Rd), 1420 (ins t2adrlabel:$addr, pred:$p), 1421 IIC_iALUi, "adr{$p}.w\t$Rd, $addr", []>, 1422 Sched<[WriteALU, ReadALU]> { 1423 let Inst{31-27} = 0b11110; 1424 let Inst{25-24} = 0b10; 1425 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE) 1426 let Inst{22} = 0; 1427 let Inst{20} = 0; 1428 let Inst{19-16} = 0b1111; // Rn 1429 let Inst{15} = 0; 1430 1431 bits<4> Rd; 1432 bits<13> addr; 1433 let Inst{11-8} = Rd; 1434 let Inst{23} = addr{12}; 1435 let Inst{21} = addr{12}; 1436 let Inst{26} = addr{11}; 1437 let Inst{14-12} = addr{10-8}; 1438 let Inst{7-0} = addr{7-0}; 1439 1440 let DecoderMethod = "DecodeT2Adr"; 1441} 1442 1443let hasSideEffects = 0, isReMaterializable = 1 in 1444def t2LEApcrel : t2PseudoInst<(outs rGPR:$Rd), (ins i32imm:$label, pred:$p), 1445 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>; 1446let hasSideEffects = 1 in 1447def t2LEApcrelJT : t2PseudoInst<(outs rGPR:$Rd), 1448 (ins i32imm:$label, pred:$p), 1449 4, IIC_iALUi, 1450 []>, Sched<[WriteALU, ReadALU]>; 1451 1452 1453//===----------------------------------------------------------------------===// 1454// Load / store Instructions. 1455// 1456 1457// Load 1458let canFoldAsLoad = 1, isReMaterializable = 1 in 1459defm t2LDR : T2I_ld<0, 0b10, "ldr", IIC_iLoad_i, IIC_iLoad_si, GPR, load>; 1460 1461// Loads with zero extension 1462defm t2LDRH : T2I_ld<0, 0b01, "ldrh", IIC_iLoad_bh_i, IIC_iLoad_bh_si, 1463 GPRnopc, zextloadi16>; 1464defm t2LDRB : T2I_ld<0, 0b00, "ldrb", IIC_iLoad_bh_i, IIC_iLoad_bh_si, 1465 GPRnopc, zextloadi8>; 1466 1467// Loads with sign extension 1468defm t2LDRSH : T2I_ld<1, 0b01, "ldrsh", IIC_iLoad_bh_i, IIC_iLoad_bh_si, 1469 GPRnopc, sextloadi16>; 1470defm t2LDRSB : T2I_ld<1, 0b00, "ldrsb", IIC_iLoad_bh_i, IIC_iLoad_bh_si, 1471 GPRnopc, sextloadi8>; 1472 1473let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in { 1474// Load doubleword 1475def t2LDRDi8 : T2Ii8s4<1, 0, 1, (outs rGPR:$Rt, rGPR:$Rt2), 1476 (ins t2addrmode_imm8s4:$addr), 1477 IIC_iLoad_d_i, "ldrd", "\t$Rt, $Rt2, $addr", "", 1478 [(set rGPR:$Rt, rGPR:$Rt2, (ARMldrd t2addrmode_imm8s4:$addr))]>, 1479 Sched<[WriteLd]>; 1480} // mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 1481 1482// zextload i1 -> zextload i8 1483def : T2Pat<(zextloadi1 t2addrmode_imm12:$addr), 1484 (t2LDRBi12 t2addrmode_imm12:$addr)>; 1485def : T2Pat<(zextloadi1 t2addrmode_negimm8:$addr), 1486 (t2LDRBi8 t2addrmode_negimm8:$addr)>; 1487def : T2Pat<(zextloadi1 t2addrmode_so_reg:$addr), 1488 (t2LDRBs t2addrmode_so_reg:$addr)>; 1489def : T2Pat<(zextloadi1 (ARMWrapper tconstpool:$addr)), 1490 (t2LDRBpci tconstpool:$addr)>; 1491 1492// extload -> zextload 1493// FIXME: Reduce the number of patterns by legalizing extload to zextload 1494// earlier? 1495def : T2Pat<(extloadi1 t2addrmode_imm12:$addr), 1496 (t2LDRBi12 t2addrmode_imm12:$addr)>; 1497def : T2Pat<(extloadi1 t2addrmode_negimm8:$addr), 1498 (t2LDRBi8 t2addrmode_negimm8:$addr)>; 1499def : T2Pat<(extloadi1 t2addrmode_so_reg:$addr), 1500 (t2LDRBs t2addrmode_so_reg:$addr)>; 1501def : T2Pat<(extloadi1 (ARMWrapper tconstpool:$addr)), 1502 (t2LDRBpci tconstpool:$addr)>; 1503 1504def : T2Pat<(extloadi8 t2addrmode_imm12:$addr), 1505 (t2LDRBi12 t2addrmode_imm12:$addr)>; 1506def : T2Pat<(extloadi8 t2addrmode_negimm8:$addr), 1507 (t2LDRBi8 t2addrmode_negimm8:$addr)>; 1508def : T2Pat<(extloadi8 t2addrmode_so_reg:$addr), 1509 (t2LDRBs t2addrmode_so_reg:$addr)>; 1510def : T2Pat<(extloadi8 (ARMWrapper tconstpool:$addr)), 1511 (t2LDRBpci tconstpool:$addr)>; 1512 1513def : T2Pat<(extloadi16 t2addrmode_imm12:$addr), 1514 (t2LDRHi12 t2addrmode_imm12:$addr)>; 1515def : T2Pat<(extloadi16 t2addrmode_negimm8:$addr), 1516 (t2LDRHi8 t2addrmode_negimm8:$addr)>; 1517def : T2Pat<(extloadi16 t2addrmode_so_reg:$addr), 1518 (t2LDRHs t2addrmode_so_reg:$addr)>; 1519def : T2Pat<(extloadi16 (ARMWrapper tconstpool:$addr)), 1520 (t2LDRHpci tconstpool:$addr)>; 1521 1522// FIXME: The destination register of the loads and stores can't be PC, but 1523// can be SP. We need another regclass (similar to rGPR) to represent 1524// that. Not a pressing issue since these are selected manually, 1525// not via pattern. 1526 1527// Indexed loads 1528 1529let mayLoad = 1, hasSideEffects = 0 in { 1530def t2LDR_PRE : T2Ipreldst<0, 0b10, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb), 1531 (ins t2addrmode_imm8_pre:$addr), 1532 AddrModeT2_i8, IndexModePre, IIC_iLoad_iu, 1533 "ldr", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []>, 1534 Sched<[WriteLd]>; 1535 1536def t2LDR_POST : T2Ipostldst<0, 0b10, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb), 1537 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset), 1538 AddrModeT2_i8, IndexModePost, IIC_iLoad_iu, 1539 "ldr", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>, 1540 Sched<[WriteLd]>; 1541 1542def t2LDRB_PRE : T2Ipreldst<0, 0b00, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb), 1543 (ins t2addrmode_imm8_pre:$addr), 1544 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu, 1545 "ldrb", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []>, 1546 Sched<[WriteLd]>; 1547 1548def t2LDRB_POST : T2Ipostldst<0, 0b00, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb), 1549 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset), 1550 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu, 1551 "ldrb", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>, 1552 Sched<[WriteLd]>; 1553 1554def t2LDRH_PRE : T2Ipreldst<0, 0b01, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb), 1555 (ins t2addrmode_imm8_pre:$addr), 1556 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu, 1557 "ldrh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []>, 1558 Sched<[WriteLd]>; 1559 1560def t2LDRH_POST : T2Ipostldst<0, 0b01, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb), 1561 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset), 1562 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu, 1563 "ldrh", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>, 1564 Sched<[WriteLd]>; 1565 1566def t2LDRSB_PRE : T2Ipreldst<1, 0b00, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb), 1567 (ins t2addrmode_imm8_pre:$addr), 1568 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu, 1569 "ldrsb", "\t$Rt, $addr!", "$addr.base = $Rn_wb", 1570 []>, Sched<[WriteLd]>; 1571 1572def t2LDRSB_POST : T2Ipostldst<1, 0b00, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb), 1573 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset), 1574 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu, 1575 "ldrsb", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>, 1576 Sched<[WriteLd]>; 1577 1578def t2LDRSH_PRE : T2Ipreldst<1, 0b01, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb), 1579 (ins t2addrmode_imm8_pre:$addr), 1580 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu, 1581 "ldrsh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", 1582 []>, Sched<[WriteLd]>; 1583 1584def t2LDRSH_POST : T2Ipostldst<1, 0b01, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb), 1585 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset), 1586 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu, 1587 "ldrsh", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>, 1588 Sched<[WriteLd]>; 1589} // mayLoad = 1, hasSideEffects = 0 1590 1591// F5.1.72 LDR (immediate) T4 1592// .w suffixes; Constraints can't be used on t2InstAlias to describe 1593// "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE. 1594def t2LDR_PRE_imm : t2AsmPseudo<"ldr${p}.w $Rt, $addr!", 1595 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>; 1596def t2LDR_POST_imm : t2AsmPseudo<"ldr${p}.w $Rt, $Rn, $imm", 1597 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>; 1598 1599// A7.7.46 LDRB (immediate) T3 1600// .w suffixes; Constraints can't be used on t2InstAlias to describe 1601// "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE. 1602def t2LDRB_OFFSET_imm : t2AsmPseudo<"ldrb${p}.w $Rt, $addr", 1603 (ins GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>; 1604def t2LDRB_PRE_imm : t2AsmPseudo<"ldrb${p}.w $Rt, $addr!", 1605 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>; 1606def t2LDRB_POST_imm : t2AsmPseudo<"ldrb${p}.w $Rt, $Rn, $imm", 1607 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>; 1608 1609// A7.7.55 LDRH (immediate) T3 1610// .w suffixes; Constraints can't be used on t2InstAlias to describe 1611// "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE. 1612def t2LDRH_OFFSET_imm : t2AsmPseudo<"ldrh${p}.w $Rt, $addr", 1613 (ins GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>; 1614def t2LDRH_PRE_imm : t2AsmPseudo<"ldrh${p}.w $Rt, $addr!", 1615 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>; 1616def t2LDRH_POST_imm : t2AsmPseudo<"ldrh${p}.w $Rt, $Rn, $imm", 1617 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>; 1618 1619// A7.7.59 LDRSB (immediate) T2 1620// .w suffixes; Constraints can't be used on t2InstAlias to describe 1621// "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE. 1622def t2LDRSB_OFFSET_imm : t2AsmPseudo<"ldrsb${p}.w $Rt, $addr", 1623 (ins GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>; 1624def t2LDRSB_PRE_imm : t2AsmPseudo<"ldrsb${p}.w $Rt, $addr!", 1625 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>; 1626def t2LDRSB_POST_imm : t2AsmPseudo<"ldrsb${p}.w $Rt, $Rn, $imm", 1627 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>; 1628 1629// A7.7.63 LDRSH (immediate) T2 1630// .w suffixes; Constraints can't be used on t2InstAlias to describe 1631// "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE. 1632def t2LDRSH_OFFSET_imm : t2AsmPseudo<"ldrsh${p}.w $Rt, $addr", 1633 (ins GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>; 1634def t2LDRSH_PRE_imm : t2AsmPseudo<"ldrsh${p}.w $Rt, $addr!", 1635 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>; 1636def t2LDRSH_POST_imm : t2AsmPseudo<"ldrsh${p}.w $Rt, $Rn, $imm", 1637 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>; 1638 1639// LDRT, LDRBT, LDRHT, LDRSBT, LDRSHT all have offset mode (PUW=0b110). 1640// Ref: A8.6.57 LDR (immediate, Thumb) Encoding T4 1641class T2IldT<bit signed, bits<2> type, string opc, InstrItinClass ii> 1642 : T2Ii8p<(outs rGPR:$Rt), (ins t2addrmode_posimm8:$addr), ii, opc, 1643 "\t$Rt, $addr", []>, Sched<[WriteLd]> { 1644 bits<4> Rt; 1645 bits<13> addr; 1646 let Inst{31-27} = 0b11111; 1647 let Inst{26-25} = 0b00; 1648 let Inst{24} = signed; 1649 let Inst{23} = 0; 1650 let Inst{22-21} = type; 1651 let Inst{20} = 1; // load 1652 let Inst{19-16} = addr{12-9}; 1653 let Inst{15-12} = Rt; 1654 let Inst{11} = 1; 1655 let Inst{10-8} = 0b110; // PUW. 1656 let Inst{7-0} = addr{7-0}; 1657 1658 let DecoderMethod = "DecodeT2LoadT"; 1659} 1660 1661def t2LDRT : T2IldT<0, 0b10, "ldrt", IIC_iLoad_i>; 1662def t2LDRBT : T2IldT<0, 0b00, "ldrbt", IIC_iLoad_bh_i>; 1663def t2LDRHT : T2IldT<0, 0b01, "ldrht", IIC_iLoad_bh_i>; 1664def t2LDRSBT : T2IldT<1, 0b00, "ldrsbt", IIC_iLoad_bh_i>; 1665def t2LDRSHT : T2IldT<1, 0b01, "ldrsht", IIC_iLoad_bh_i>; 1666 1667class T2Ildacq<bits<4> bits23_20, bits<2> bit54, dag oops, dag iops, 1668 string opc, string asm, list<dag> pattern> 1669 : Thumb2I<oops, iops, AddrModeNone, 4, NoItinerary, 1670 opc, asm, "", pattern>, Requires<[IsThumb, HasAcquireRelease]> { 1671 bits<4> Rt; 1672 bits<4> addr; 1673 1674 let Inst{31-27} = 0b11101; 1675 let Inst{26-24} = 0b000; 1676 let Inst{23-20} = bits23_20; 1677 let Inst{11-6} = 0b111110; 1678 let Inst{5-4} = bit54; 1679 let Inst{3-0} = 0b1111; 1680 1681 // Encode instruction operands 1682 let Inst{19-16} = addr; 1683 let Inst{15-12} = Rt; 1684} 1685 1686def t2LDA : T2Ildacq<0b1101, 0b10, (outs rGPR:$Rt), 1687 (ins addr_offset_none:$addr), "lda", "\t$Rt, $addr", []>, 1688 Sched<[WriteLd]>; 1689def t2LDAB : T2Ildacq<0b1101, 0b00, (outs rGPR:$Rt), 1690 (ins addr_offset_none:$addr), "ldab", "\t$Rt, $addr", []>, 1691 Sched<[WriteLd]>; 1692def t2LDAH : T2Ildacq<0b1101, 0b01, (outs rGPR:$Rt), 1693 (ins addr_offset_none:$addr), "ldah", "\t$Rt, $addr", []>, 1694 Sched<[WriteLd]>; 1695 1696// Store 1697defm t2STR :T2I_st<0b10,"str", IIC_iStore_i, IIC_iStore_si, GPR, store>; 1698defm t2STRB:T2I_st<0b00,"strb", IIC_iStore_bh_i, IIC_iStore_bh_si, 1699 rGPR, truncstorei8>; 1700defm t2STRH:T2I_st<0b01,"strh", IIC_iStore_bh_i, IIC_iStore_bh_si, 1701 rGPR, truncstorei16>; 1702 1703// Store doubleword 1704let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in 1705def t2STRDi8 : T2Ii8s4<1, 0, 0, (outs), 1706 (ins rGPR:$Rt, rGPR:$Rt2, t2addrmode_imm8s4:$addr), 1707 IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", "", 1708 [(ARMstrd rGPR:$Rt, rGPR:$Rt2, t2addrmode_imm8s4:$addr)]>, 1709 Sched<[WriteST]>; 1710 1711// Indexed stores 1712 1713let mayStore = 1, hasSideEffects = 0 in { 1714def t2STR_PRE : T2Ipreldst<0, 0b10, 0, 1, (outs GPRnopc:$Rn_wb), 1715 (ins GPRnopc:$Rt, t2addrmode_imm8_pre:$addr), 1716 AddrModeT2_i8, IndexModePre, IIC_iStore_iu, 1717 "str", "\t$Rt, $addr!", 1718 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []>, 1719 Sched<[WriteST]>; 1720 1721def t2STRH_PRE : T2Ipreldst<0, 0b01, 0, 1, (outs GPRnopc:$Rn_wb), 1722 (ins rGPR:$Rt, t2addrmode_imm8_pre:$addr), 1723 AddrModeT2_i8, IndexModePre, IIC_iStore_iu, 1724 "strh", "\t$Rt, $addr!", 1725 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []>, 1726 Sched<[WriteST]>; 1727 1728def t2STRB_PRE : T2Ipreldst<0, 0b00, 0, 1, (outs GPRnopc:$Rn_wb), 1729 (ins rGPR:$Rt, t2addrmode_imm8_pre:$addr), 1730 AddrModeT2_i8, IndexModePre, IIC_iStore_bh_iu, 1731 "strb", "\t$Rt, $addr!", 1732 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []>, 1733 Sched<[WriteST]>; 1734} // mayStore = 1, hasSideEffects = 0 1735 1736def t2STR_POST : T2Ipostldst<0, 0b10, 0, 0, (outs GPRnopc:$Rn_wb), 1737 (ins GPRnopc:$Rt, addr_offset_none:$Rn, 1738 t2am_imm8_offset:$offset), 1739 AddrModeT2_i8, IndexModePost, IIC_iStore_iu, 1740 "str", "\t$Rt, $Rn$offset", 1741 "$Rn = $Rn_wb,@earlyclobber $Rn_wb", 1742 [(set GPRnopc:$Rn_wb, 1743 (post_store GPRnopc:$Rt, addr_offset_none:$Rn, 1744 t2am_imm8_offset:$offset))]>, 1745 Sched<[WriteST]>; 1746 1747def t2STRH_POST : T2Ipostldst<0, 0b01, 0, 0, (outs GPRnopc:$Rn_wb), 1748 (ins rGPR:$Rt, addr_offset_none:$Rn, 1749 t2am_imm8_offset:$offset), 1750 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu, 1751 "strh", "\t$Rt, $Rn$offset", 1752 "$Rn = $Rn_wb,@earlyclobber $Rn_wb", 1753 [(set GPRnopc:$Rn_wb, 1754 (post_truncsti16 rGPR:$Rt, addr_offset_none:$Rn, 1755 t2am_imm8_offset:$offset))]>, 1756 Sched<[WriteST]>; 1757 1758def t2STRB_POST : T2Ipostldst<0, 0b00, 0, 0, (outs GPRnopc:$Rn_wb), 1759 (ins rGPR:$Rt, addr_offset_none:$Rn, 1760 t2am_imm8_offset:$offset), 1761 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu, 1762 "strb", "\t$Rt, $Rn$offset", 1763 "$Rn = $Rn_wb,@earlyclobber $Rn_wb", 1764 [(set GPRnopc:$Rn_wb, 1765 (post_truncsti8 rGPR:$Rt, addr_offset_none:$Rn, 1766 t2am_imm8_offset:$offset))]>, 1767 Sched<[WriteST]>; 1768 1769// Pseudo-instructions for pattern matching the pre-indexed stores. We can't 1770// put the patterns on the instruction definitions directly as ISel wants 1771// the address base and offset to be separate operands, not a single 1772// complex operand like we represent the instructions themselves. The 1773// pseudos map between the two. 1774let usesCustomInserter = 1, 1775 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in { 1776def t2STR_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb), 1777 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p), 1778 4, IIC_iStore_ru, 1779 [(set GPRnopc:$Rn_wb, 1780 (pre_store rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>, 1781 Sched<[WriteST]>; 1782def t2STRB_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb), 1783 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p), 1784 4, IIC_iStore_ru, 1785 [(set GPRnopc:$Rn_wb, 1786 (pre_truncsti8 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>, 1787 Sched<[WriteST]>; 1788def t2STRH_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb), 1789 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p), 1790 4, IIC_iStore_ru, 1791 [(set GPRnopc:$Rn_wb, 1792 (pre_truncsti16 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>, 1793 Sched<[WriteST]>; 1794} 1795 1796// F5.1.229 STR (immediate) T4 1797// .w suffixes; Constraints can't be used on t2InstAlias to describe 1798// "$Rn = $Rn_wb,@earlyclobber $Rn_wb" on POST or 1799// "$addr.base = $Rn_wb,@earlyclobber $Rn_wb" on PRE. 1800def t2STR_PRE_imm : t2AsmPseudo<"str${p}.w $Rt, $addr!", 1801 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>; 1802def t2STR_POST_imm : t2AsmPseudo<"str${p}.w $Rt, $Rn, $imm", 1803 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>; 1804 1805// A7.7.163 STRB (immediate) T3 1806// .w suffixes; Constraints can't be used on t2InstAlias to describe 1807// "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE. 1808def t2STRB_OFFSET_imm : t2AsmPseudo<"strb${p}.w $Rt, $addr", 1809 (ins GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>; 1810def t2STRB_PRE_imm : t2AsmPseudo<"strb${p}.w $Rt, $addr!", 1811 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>; 1812def t2STRB_POST_imm : t2AsmPseudo<"strb${p}.w $Rt, $Rn, $imm", 1813 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>; 1814 1815// A7.7.170 STRH (immediate) T3 1816// .w suffixes; Constraints can't be used on t2InstAlias to describe 1817// "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE. 1818def t2STRH_OFFSET_imm : t2AsmPseudo<"strh${p}.w $Rt, $addr", 1819 (ins GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>; 1820def t2STRH_PRE_imm : t2AsmPseudo<"strh${p}.w $Rt, $addr!", 1821 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>; 1822def t2STRH_POST_imm : t2AsmPseudo<"strh${p}.w $Rt, $Rn, $imm", 1823 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>; 1824 1825// STRT, STRBT, STRHT all have offset mode (PUW=0b110) and are for disassembly 1826// only. 1827// Ref: A8.6.193 STR (immediate, Thumb) Encoding T4 1828class T2IstT<bits<2> type, string opc, InstrItinClass ii> 1829 : T2Ii8p<(outs), (ins rGPR:$Rt, t2addrmode_posimm8:$addr), ii, opc, 1830 "\t$Rt, $addr", []>, Sched<[WriteST]> { 1831 let Inst{31-27} = 0b11111; 1832 let Inst{26-25} = 0b00; 1833 let Inst{24} = 0; // not signed 1834 let Inst{23} = 0; 1835 let Inst{22-21} = type; 1836 let Inst{20} = 0; // store 1837 let Inst{11} = 1; 1838 let Inst{10-8} = 0b110; // PUW 1839 1840 bits<4> Rt; 1841 bits<13> addr; 1842 let Inst{15-12} = Rt; 1843 let Inst{19-16} = addr{12-9}; 1844 let Inst{7-0} = addr{7-0}; 1845} 1846 1847def t2STRT : T2IstT<0b10, "strt", IIC_iStore_i>; 1848def t2STRBT : T2IstT<0b00, "strbt", IIC_iStore_bh_i>; 1849def t2STRHT : T2IstT<0b01, "strht", IIC_iStore_bh_i>; 1850 1851// ldrd / strd pre / post variants 1852 1853let mayLoad = 1, hasSideEffects = 0 in 1854def t2LDRD_PRE : T2Ii8s4<1, 1, 1, (outs rGPR:$Rt, rGPR:$Rt2, GPR:$wb), 1855 (ins t2addrmode_imm8s4_pre:$addr), IIC_iLoad_d_ru, 1856 "ldrd", "\t$Rt, $Rt2, $addr!", "$addr.base = $wb", []>, 1857 Sched<[WriteLd]> { 1858 let DecoderMethod = "DecodeT2LDRDPreInstruction"; 1859} 1860 1861let mayLoad = 1, hasSideEffects = 0 in 1862def t2LDRD_POST : T2Ii8s4post<0, 1, 1, (outs rGPR:$Rt, rGPR:$Rt2, GPR:$wb), 1863 (ins addr_offset_none:$addr, t2am_imm8s4_offset:$imm), 1864 IIC_iLoad_d_ru, "ldrd", "\t$Rt, $Rt2, $addr$imm", 1865 "$addr.base = $wb", []>, Sched<[WriteLd]>; 1866 1867let mayStore = 1, hasSideEffects = 0 in 1868def t2STRD_PRE : T2Ii8s4<1, 1, 0, (outs GPR:$wb), 1869 (ins rGPR:$Rt, rGPR:$Rt2, t2addrmode_imm8s4_pre:$addr), 1870 IIC_iStore_d_ru, "strd", "\t$Rt, $Rt2, $addr!", 1871 "$addr.base = $wb", []>, Sched<[WriteST]> { 1872 let DecoderMethod = "DecodeT2STRDPreInstruction"; 1873} 1874 1875let mayStore = 1, hasSideEffects = 0 in 1876def t2STRD_POST : T2Ii8s4post<0, 1, 0, (outs GPR:$wb), 1877 (ins rGPR:$Rt, rGPR:$Rt2, addr_offset_none:$addr, 1878 t2am_imm8s4_offset:$imm), 1879 IIC_iStore_d_ru, "strd", "\t$Rt, $Rt2, $addr$imm", 1880 "$addr.base = $wb", []>, Sched<[WriteST]>; 1881 1882class T2Istrrel<bits<2> bit54, dag oops, dag iops, 1883 string opc, string asm, list<dag> pattern> 1884 : Thumb2I<oops, iops, AddrModeNone, 4, NoItinerary, opc, 1885 asm, "", pattern>, Requires<[IsThumb, HasAcquireRelease]>, 1886 Sched<[WriteST]> { 1887 bits<4> Rt; 1888 bits<4> addr; 1889 1890 let Inst{31-27} = 0b11101; 1891 let Inst{26-20} = 0b0001100; 1892 let Inst{11-6} = 0b111110; 1893 let Inst{5-4} = bit54; 1894 let Inst{3-0} = 0b1111; 1895 1896 // Encode instruction operands 1897 let Inst{19-16} = addr; 1898 let Inst{15-12} = Rt; 1899} 1900 1901def t2STL : T2Istrrel<0b10, (outs), (ins rGPR:$Rt, addr_offset_none:$addr), 1902 "stl", "\t$Rt, $addr", []>; 1903def t2STLB : T2Istrrel<0b00, (outs), (ins rGPR:$Rt, addr_offset_none:$addr), 1904 "stlb", "\t$Rt, $addr", []>; 1905def t2STLH : T2Istrrel<0b01, (outs), (ins rGPR:$Rt, addr_offset_none:$addr), 1906 "stlh", "\t$Rt, $addr", []>; 1907 1908// T2Ipl (Preload Data/Instruction) signals the memory system of possible future 1909// data/instruction access. 1910// instr_write is inverted for Thumb mode: (prefetch 3) -> (preload 0), 1911// (prefetch 1) -> (preload 2), (prefetch 2) -> (preload 1). 1912multiclass T2Ipl<bits<1> write, bits<1> instr, string opc> { 1913 1914 def i12 : T2Ii12<(outs), (ins t2addrmode_imm12:$addr), IIC_Preload, opc, 1915 "\t$addr", 1916 [(ARMPreload t2addrmode_imm12:$addr, (i32 write), (i32 instr))]>, 1917 Sched<[WritePreLd]> { 1918 let Inst{31-25} = 0b1111100; 1919 let Inst{24} = instr; 1920 let Inst{23} = 1; 1921 let Inst{22} = 0; 1922 let Inst{21} = write; 1923 let Inst{20} = 1; 1924 let Inst{15-12} = 0b1111; 1925 1926 bits<17> addr; 1927 let Inst{19-16} = addr{16-13}; // Rn 1928 let Inst{11-0} = addr{11-0}; // imm12 1929 1930 let DecoderMethod = "DecodeT2LoadImm12"; 1931 } 1932 1933 def i8 : T2Ii8n<(outs), (ins t2addrmode_negimm8:$addr), IIC_Preload, opc, 1934 "\t$addr", 1935 [(ARMPreload t2addrmode_negimm8:$addr, (i32 write), (i32 instr))]>, 1936 Sched<[WritePreLd]> { 1937 let Inst{31-25} = 0b1111100; 1938 let Inst{24} = instr; 1939 let Inst{23} = 0; // U = 0 1940 let Inst{22} = 0; 1941 let Inst{21} = write; 1942 let Inst{20} = 1; 1943 let Inst{15-12} = 0b1111; 1944 let Inst{11-8} = 0b1100; 1945 1946 bits<13> addr; 1947 let Inst{19-16} = addr{12-9}; // Rn 1948 let Inst{7-0} = addr{7-0}; // imm8 1949 1950 let DecoderMethod = "DecodeT2LoadImm8"; 1951 } 1952 1953 def s : T2Iso<(outs), (ins t2addrmode_so_reg:$addr), IIC_Preload, opc, 1954 "\t$addr", 1955 [(ARMPreload t2addrmode_so_reg:$addr, (i32 write), (i32 instr))]>, 1956 Sched<[WritePreLd]> { 1957 let Inst{31-25} = 0b1111100; 1958 let Inst{24} = instr; 1959 let Inst{23} = 0; // add = TRUE for T1 1960 let Inst{22} = 0; 1961 let Inst{21} = write; 1962 let Inst{20} = 1; 1963 let Inst{15-12} = 0b1111; 1964 let Inst{11-6} = 0b000000; 1965 1966 bits<10> addr; 1967 let Inst{19-16} = addr{9-6}; // Rn 1968 let Inst{3-0} = addr{5-2}; // Rm 1969 let Inst{5-4} = addr{1-0}; // imm2 1970 1971 let DecoderMethod = "DecodeT2LoadShift"; 1972 } 1973} 1974 1975defm t2PLD : T2Ipl<0, 0, "pld">, Requires<[IsThumb2]>; 1976defm t2PLDW : T2Ipl<1, 0, "pldw">, Requires<[IsThumb2,HasV7,HasMP]>; 1977defm t2PLI : T2Ipl<0, 1, "pli">, Requires<[IsThumb2,HasV7]>; 1978 1979// PLD/PLDW/PLI aliases w/ the optional .w suffix 1980def : t2InstAlias<"pld${p}.w\t$addr", 1981 (t2PLDi12 t2addrmode_imm12:$addr, pred:$p)>; 1982def : t2InstAlias<"pld${p}.w\t$addr", 1983 (t2PLDi8 t2addrmode_negimm8:$addr, pred:$p)>; 1984def : t2InstAlias<"pld${p}.w\t$addr", 1985 (t2PLDs t2addrmode_so_reg:$addr, pred:$p)>; 1986 1987def : InstAlias<"pldw${p}.w\t$addr", 1988 (t2PLDWi12 t2addrmode_imm12:$addr, pred:$p), 0>, 1989 Requires<[IsThumb2,HasV7,HasMP]>; 1990def : InstAlias<"pldw${p}.w\t$addr", 1991 (t2PLDWi8 t2addrmode_negimm8:$addr, pred:$p), 0>, 1992 Requires<[IsThumb2,HasV7,HasMP]>; 1993def : InstAlias<"pldw${p}.w\t$addr", 1994 (t2PLDWs t2addrmode_so_reg:$addr, pred:$p), 0>, 1995 Requires<[IsThumb2,HasV7,HasMP]>; 1996 1997def : InstAlias<"pli${p}.w\t$addr", 1998 (t2PLIi12 t2addrmode_imm12:$addr, pred:$p), 0>, 1999 Requires<[IsThumb2,HasV7]>; 2000def : InstAlias<"pli${p}.w\t$addr", 2001 (t2PLIi8 t2addrmode_negimm8:$addr, pred:$p), 0>, 2002 Requires<[IsThumb2,HasV7]>; 2003def : InstAlias<"pli${p}.w\t$addr", 2004 (t2PLIs t2addrmode_so_reg:$addr, pred:$p), 0>, 2005 Requires<[IsThumb2,HasV7]>; 2006 2007// pci variant is very similar to i12, but supports negative offsets 2008// from the PC. Only PLD and PLI have pci variants (not PLDW) 2009class T2Iplpci<bits<1> inst, string opc> : T2Ipc<(outs), (ins t2ldrlabel:$addr), 2010 IIC_Preload, opc, "\t$addr", 2011 [(ARMPreload (ARMWrapper tconstpool:$addr), 2012 (i32 0), (i32 inst))]>, Sched<[WritePreLd]> { 2013 let Inst{31-25} = 0b1111100; 2014 let Inst{24} = inst; 2015 let Inst{22-20} = 0b001; 2016 let Inst{19-16} = 0b1111; 2017 let Inst{15-12} = 0b1111; 2018 2019 bits<13> addr; 2020 let Inst{23} = addr{12}; // add = (U == '1') 2021 let Inst{11-0} = addr{11-0}; // imm12 2022 2023 let DecoderMethod = "DecodeT2LoadLabel"; 2024} 2025 2026def t2PLDpci : T2Iplpci<0, "pld">, Requires<[IsThumb2]>; 2027def t2PLIpci : T2Iplpci<1, "pli">, Requires<[IsThumb2,HasV7]>; 2028 2029def : t2InstAlias<"pld${p}.w $addr", 2030 (t2PLDpci t2ldrlabel:$addr, pred:$p)>; 2031def : InstAlias<"pli${p}.w $addr", 2032 (t2PLIpci t2ldrlabel:$addr, pred:$p), 0>, 2033 Requires<[IsThumb2,HasV7]>; 2034 2035// PLD/PLI with alternate literal form. 2036def : t2InstAlias<"pld${p} $addr", 2037 (t2PLDpci t2ldr_pcrel_imm12:$addr, pred:$p)>; 2038def : InstAlias<"pli${p} $addr", 2039 (t2PLIpci t2ldr_pcrel_imm12:$addr, pred:$p), 0>, 2040 Requires<[IsThumb2,HasV7]>; 2041def : t2InstAlias<"pld${p}.w $addr", 2042 (t2PLDpci t2ldr_pcrel_imm12:$addr, pred:$p)>; 2043def : InstAlias<"pli${p}.w $addr", 2044 (t2PLIpci t2ldr_pcrel_imm12:$addr, pred:$p), 0>, 2045 Requires<[IsThumb2,HasV7]>; 2046 2047//===----------------------------------------------------------------------===// 2048// Load / store multiple Instructions. 2049// 2050 2051multiclass thumb2_ld_mult<string asm, InstrItinClass itin, 2052 InstrItinClass itin_upd, bit L_bit> { 2053 def IA : 2054 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 2055 itin, !strconcat(asm, "${p}.w\t$Rn, $regs"), []> { 2056 bits<4> Rn; 2057 bits<16> regs; 2058 2059 let Inst{31-27} = 0b11101; 2060 let Inst{26-25} = 0b00; 2061 let Inst{24-23} = 0b01; // Increment After 2062 let Inst{22} = 0; 2063 let Inst{21} = 0; // No writeback 2064 let Inst{20} = L_bit; 2065 let Inst{19-16} = Rn; 2066 let Inst{15-0} = regs; 2067 } 2068 def IA_UPD : 2069 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 2070 itin_upd, !strconcat(asm, "${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> { 2071 bits<4> Rn; 2072 bits<16> regs; 2073 2074 let Inst{31-27} = 0b11101; 2075 let Inst{26-25} = 0b00; 2076 let Inst{24-23} = 0b01; // Increment After 2077 let Inst{22} = 0; 2078 let Inst{21} = 1; // Writeback 2079 let Inst{20} = L_bit; 2080 let Inst{19-16} = Rn; 2081 let Inst{15-0} = regs; 2082 } 2083 def DB : 2084 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 2085 itin, !strconcat(asm, "db${p}\t$Rn, $regs"), []> { 2086 bits<4> Rn; 2087 bits<16> regs; 2088 2089 let Inst{31-27} = 0b11101; 2090 let Inst{26-25} = 0b00; 2091 let Inst{24-23} = 0b10; // Decrement Before 2092 let Inst{22} = 0; 2093 let Inst{21} = 0; // No writeback 2094 let Inst{20} = L_bit; 2095 let Inst{19-16} = Rn; 2096 let Inst{15-0} = regs; 2097 } 2098 def DB_UPD : 2099 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 2100 itin_upd, !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> { 2101 bits<4> Rn; 2102 bits<16> regs; 2103 2104 let Inst{31-27} = 0b11101; 2105 let Inst{26-25} = 0b00; 2106 let Inst{24-23} = 0b10; // Decrement Before 2107 let Inst{22} = 0; 2108 let Inst{21} = 1; // Writeback 2109 let Inst{20} = L_bit; 2110 let Inst{19-16} = Rn; 2111 let Inst{15-0} = regs; 2112 } 2113} 2114 2115let hasSideEffects = 0 in { 2116 2117let mayLoad = 1, hasExtraDefRegAllocReq = 1, variadicOpsAreDefs = 1 in 2118defm t2LDM : thumb2_ld_mult<"ldm", IIC_iLoad_m, IIC_iLoad_mu, 1>; 2119 2120multiclass thumb2_st_mult<string asm, InstrItinClass itin, 2121 InstrItinClass itin_upd, bit L_bit> { 2122 def IA : 2123 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 2124 itin, !strconcat(asm, "${p}.w\t$Rn, $regs"), []> { 2125 bits<4> Rn; 2126 bits<16> regs; 2127 2128 let Inst{31-27} = 0b11101; 2129 let Inst{26-25} = 0b00; 2130 let Inst{24-23} = 0b01; // Increment After 2131 let Inst{22} = 0; 2132 let Inst{21} = 0; // No writeback 2133 let Inst{20} = L_bit; 2134 let Inst{19-16} = Rn; 2135 let Inst{15} = 0; 2136 let Inst{14} = regs{14}; 2137 let Inst{13} = 0; 2138 let Inst{12-0} = regs{12-0}; 2139 } 2140 def IA_UPD : 2141 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 2142 itin_upd, !strconcat(asm, "${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> { 2143 bits<4> Rn; 2144 bits<16> regs; 2145 2146 let Inst{31-27} = 0b11101; 2147 let Inst{26-25} = 0b00; 2148 let Inst{24-23} = 0b01; // Increment After 2149 let Inst{22} = 0; 2150 let Inst{21} = 1; // Writeback 2151 let Inst{20} = L_bit; 2152 let Inst{19-16} = Rn; 2153 let Inst{15} = 0; 2154 let Inst{14} = regs{14}; 2155 let Inst{13} = 0; 2156 let Inst{12-0} = regs{12-0}; 2157 } 2158 def DB : 2159 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 2160 itin, !strconcat(asm, "db${p}\t$Rn, $regs"), []> { 2161 bits<4> Rn; 2162 bits<16> regs; 2163 2164 let Inst{31-27} = 0b11101; 2165 let Inst{26-25} = 0b00; 2166 let Inst{24-23} = 0b10; // Decrement Before 2167 let Inst{22} = 0; 2168 let Inst{21} = 0; // No writeback 2169 let Inst{20} = L_bit; 2170 let Inst{19-16} = Rn; 2171 let Inst{15} = 0; 2172 let Inst{14} = regs{14}; 2173 let Inst{13} = 0; 2174 let Inst{12-0} = regs{12-0}; 2175 } 2176 def DB_UPD : 2177 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops), 2178 itin_upd, !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> { 2179 bits<4> Rn; 2180 bits<16> regs; 2181 2182 let Inst{31-27} = 0b11101; 2183 let Inst{26-25} = 0b00; 2184 let Inst{24-23} = 0b10; // Decrement Before 2185 let Inst{22} = 0; 2186 let Inst{21} = 1; // Writeback 2187 let Inst{20} = L_bit; 2188 let Inst{19-16} = Rn; 2189 let Inst{15} = 0; 2190 let Inst{14} = regs{14}; 2191 let Inst{13} = 0; 2192 let Inst{12-0} = regs{12-0}; 2193 } 2194} 2195 2196 2197let mayStore = 1, hasExtraSrcRegAllocReq = 1 in 2198defm t2STM : thumb2_st_mult<"stm", IIC_iStore_m, IIC_iStore_mu, 0>; 2199 2200} // hasSideEffects 2201 2202 2203//===----------------------------------------------------------------------===// 2204// Move Instructions. 2205// 2206 2207let hasSideEffects = 0 in 2208def t2MOVr : T2sTwoReg<(outs GPRnopc:$Rd), (ins GPRnopc:$Rm), IIC_iMOVr, 2209 "mov", ".w\t$Rd, $Rm", []>, Sched<[WriteALU]> { 2210 let Inst{31-27} = 0b11101; 2211 let Inst{26-25} = 0b01; 2212 let Inst{24-21} = 0b0010; 2213 let Inst{19-16} = 0b1111; // Rn 2214 let Inst{15} = 0b0; 2215 let Inst{14-12} = 0b000; 2216 let Inst{7-4} = 0b0000; 2217} 2218def : t2InstAlias<"mov${p}.w $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPRnopc:$Rm, 2219 pred:$p, zero_reg)>; 2220def : t2InstAlias<"movs${p}.w $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPRnopc:$Rm, 2221 pred:$p, CPSR)>; 2222def : t2InstAlias<"movs${p} $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPRnopc:$Rm, 2223 pred:$p, CPSR)>; 2224 2225// AddedComplexity to ensure isel tries t2MOVi before t2MOVi16. 2226let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1, 2227 AddedComplexity = 1 in 2228def t2MOVi : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), IIC_iMOVi, 2229 "mov", ".w\t$Rd, $imm", 2230 [(set rGPR:$Rd, t2_so_imm:$imm)]>, Sched<[WriteALU]> { 2231 let Inst{31-27} = 0b11110; 2232 let Inst{25} = 0; 2233 let Inst{24-21} = 0b0010; 2234 let Inst{19-16} = 0b1111; // Rn 2235 let Inst{15} = 0; 2236} 2237 2238// cc_out is handled as part of the explicit mnemonic in the parser for 'mov'. 2239// Use aliases to get that to play nice here. 2240def : t2InstAlias<"movs${p}.w $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm, 2241 pred:$p, CPSR)>; 2242def : t2InstAlias<"movs${p} $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm, 2243 pred:$p, CPSR)>; 2244 2245def : t2InstAlias<"mov${p}.w $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm, 2246 pred:$p, zero_reg)>; 2247def : t2InstAlias<"mov${p} $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm, 2248 pred:$p, zero_reg)>; 2249 2250let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in 2251def t2MOVi16 : T2I<(outs rGPR:$Rd), (ins imm0_65535_expr:$imm), IIC_iMOVi, 2252 "movw", "\t$Rd, $imm", 2253 [(set rGPR:$Rd, imm0_65535:$imm)]>, Sched<[WriteALU]>, 2254 Requires<[IsThumb, HasV8MBaseline]> { 2255 let Inst{31-27} = 0b11110; 2256 let Inst{25} = 1; 2257 let Inst{24-21} = 0b0010; 2258 let Inst{20} = 0; // The S bit. 2259 let Inst{15} = 0; 2260 2261 bits<4> Rd; 2262 bits<16> imm; 2263 2264 let Inst{11-8} = Rd; 2265 let Inst{19-16} = imm{15-12}; 2266 let Inst{26} = imm{11}; 2267 let Inst{14-12} = imm{10-8}; 2268 let Inst{7-0} = imm{7-0}; 2269 let DecoderMethod = "DecodeT2MOVTWInstruction"; 2270} 2271 2272def : InstAlias<"mov${p} $Rd, $imm", 2273 (t2MOVi16 rGPR:$Rd, imm256_65535_expr:$imm, pred:$p), 0>, 2274 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteALU]>; 2275 2276// This gets lowered to a single 4-byte instructions 2277let Size = 4 in 2278def t2MOVi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd), 2279 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>, 2280 Sched<[WriteALU]>; 2281 2282let Constraints = "$src = $Rd" in { 2283def t2MOVTi16 : T2I<(outs rGPR:$Rd), 2284 (ins rGPR:$src, imm0_65535_expr:$imm), IIC_iMOVi, 2285 "movt", "\t$Rd, $imm", 2286 [(set rGPR:$Rd, 2287 (or (and rGPR:$src, 0xffff), lo16AllZero:$imm))]>, 2288 Sched<[WriteALU]>, 2289 Requires<[IsThumb, HasV8MBaseline]> { 2290 let Inst{31-27} = 0b11110; 2291 let Inst{25} = 1; 2292 let Inst{24-21} = 0b0110; 2293 let Inst{20} = 0; // The S bit. 2294 let Inst{15} = 0; 2295 2296 bits<4> Rd; 2297 bits<16> imm; 2298 2299 let Inst{11-8} = Rd; 2300 let Inst{19-16} = imm{15-12}; 2301 let Inst{26} = imm{11}; 2302 let Inst{14-12} = imm{10-8}; 2303 let Inst{7-0} = imm{7-0}; 2304 let DecoderMethod = "DecodeT2MOVTWInstruction"; 2305} 2306 2307// This gets lowered to a single 4-byte instructions 2308let Size = 4 in 2309def t2MOVTi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd), 2310 (ins rGPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>, 2311 Sched<[WriteALU]>, Requires<[IsThumb, HasV8MBaseline]>; 2312} // Constraints 2313 2314def : T2Pat<(or rGPR:$src, 0xffff0000), (t2MOVTi16 rGPR:$src, 0xffff)>; 2315 2316//===----------------------------------------------------------------------===// 2317// Extend Instructions. 2318// 2319 2320// Sign extenders 2321 2322def t2SXTB : T2I_ext_rrot<0b100, "sxtb">; 2323def t2SXTH : T2I_ext_rrot<0b000, "sxth">; 2324def t2SXTB16 : T2I_ext_rrot_xtb16<0b010, "sxtb16">; 2325 2326def t2SXTAB : T2I_exta_rrot<0b100, "sxtab">; 2327def t2SXTAH : T2I_exta_rrot<0b000, "sxtah">; 2328def t2SXTAB16 : T2I_exta_rrot<0b010, "sxtab16">; 2329 2330def : T2Pat<(sext_inreg (rotr rGPR:$Rn, rot_imm:$rot), i8), 2331 (t2SXTB rGPR:$Rn, rot_imm:$rot)>; 2332def : T2Pat<(sext_inreg (rotr rGPR:$Rn, rot_imm:$rot), i16), 2333 (t2SXTH rGPR:$Rn, rot_imm:$rot)>; 2334def : Thumb2DSPPat<(add rGPR:$Rn, 2335 (sext_inreg (rotr rGPR:$Rm, rot_imm:$rot), i8)), 2336 (t2SXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 2337def : Thumb2DSPPat<(add rGPR:$Rn, 2338 (sext_inreg (rotr rGPR:$Rm, rot_imm:$rot), i16)), 2339 (t2SXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 2340def : Thumb2DSPPat<(int_arm_sxtb16 rGPR:$Rn), 2341 (t2SXTB16 rGPR:$Rn, 0)>; 2342def : Thumb2DSPPat<(int_arm_sxtab16 rGPR:$Rn, rGPR:$Rm), 2343 (t2SXTAB16 rGPR:$Rn, rGPR:$Rm, 0)>; 2344def : Thumb2DSPPat<(int_arm_sxtb16 (rotr rGPR:$Rn, rot_imm:$rot)), 2345 (t2SXTB16 rGPR:$Rn, rot_imm:$rot)>; 2346def : Thumb2DSPPat<(int_arm_sxtab16 rGPR:$Rn, (rotr rGPR:$Rm, rot_imm:$rot)), 2347 (t2SXTAB16 rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 2348 2349 2350// A simple right-shift can also be used in most cases (the exception is the 2351// SXTH operations with a rotate of 24: there the non-contiguous bits are 2352// relevant). 2353def : Thumb2DSPPat<(add rGPR:$Rn, (sext_inreg 2354 (srl rGPR:$Rm, rot_imm:$rot), i8)), 2355 (t2SXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 2356def : Thumb2DSPPat<(add rGPR:$Rn, (sext_inreg 2357 (srl rGPR:$Rm, imm8_or_16:$rot), i16)), 2358 (t2SXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 2359def : Thumb2DSPPat<(add rGPR:$Rn, (sext_inreg 2360 (rotr rGPR:$Rm, (i32 24)), i16)), 2361 (t2SXTAH rGPR:$Rn, rGPR:$Rm, (i32 3))>; 2362def : Thumb2DSPPat<(add rGPR:$Rn, (sext_inreg 2363 (or (srl rGPR:$Rm, (i32 24)), 2364 (shl rGPR:$Rm, (i32 8))), i16)), 2365 (t2SXTAH rGPR:$Rn, rGPR:$Rm, (i32 3))>; 2366 2367// Zero extenders 2368 2369let AddedComplexity = 16 in { 2370def t2UXTB : T2I_ext_rrot<0b101, "uxtb">; 2371def t2UXTH : T2I_ext_rrot<0b001, "uxth">; 2372def t2UXTB16 : T2I_ext_rrot_xtb16<0b011, "uxtb16">; 2373 2374def : Thumb2DSPPat<(and (rotr rGPR:$Rm, rot_imm:$rot), 0x000000FF), 2375 (t2UXTB rGPR:$Rm, rot_imm:$rot)>; 2376def : Thumb2DSPPat<(and (rotr rGPR:$Rm, rot_imm:$rot), 0x0000FFFF), 2377 (t2UXTH rGPR:$Rm, rot_imm:$rot)>; 2378def : Thumb2DSPPat<(and (rotr rGPR:$Rm, rot_imm:$rot), 0x00FF00FF), 2379 (t2UXTB16 rGPR:$Rm, rot_imm:$rot)>; 2380 2381def : Thumb2DSPPat<(int_arm_uxtb16 rGPR:$Rm), 2382 (t2UXTB16 rGPR:$Rm, 0)>; 2383def : Thumb2DSPPat<(int_arm_uxtb16 (rotr rGPR:$Rn, rot_imm:$rot)), 2384 (t2UXTB16 rGPR:$Rn, rot_imm:$rot)>; 2385 2386// FIXME: This pattern incorrectly assumes the shl operator is a rotate. 2387// The transformation should probably be done as a combiner action 2388// instead so we can include a check for masking back in the upper 2389// eight bits of the source into the lower eight bits of the result. 2390//def : T2Pat<(and (shl rGPR:$Src, (i32 8)), 0xFF00FF), 2391// (t2UXTB16 rGPR:$Src, 3)>, 2392// Requires<[HasDSP, IsThumb2]>; 2393def : T2Pat<(and (srl rGPR:$Src, (i32 8)), 0xFF00FF), 2394 (t2UXTB16 rGPR:$Src, 1)>, 2395 Requires<[HasDSP, IsThumb2]>; 2396 2397def t2UXTAB : T2I_exta_rrot<0b101, "uxtab">; 2398def t2UXTAH : T2I_exta_rrot<0b001, "uxtah">; 2399def t2UXTAB16 : T2I_exta_rrot<0b011, "uxtab16">; 2400 2401def : Thumb2DSPPat<(add rGPR:$Rn, (and (rotr rGPR:$Rm, rot_imm:$rot), 2402 0x00FF)), 2403 (t2UXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 2404def : Thumb2DSPPat<(add rGPR:$Rn, (and (rotr rGPR:$Rm, rot_imm:$rot), 2405 0xFFFF)), 2406 (t2UXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 2407def : Thumb2DSPPat<(add rGPR:$Rn, (and (srl rGPR:$Rm, rot_imm:$rot), 2408 0xFF)), 2409 (t2UXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 2410def : Thumb2DSPPat<(add rGPR:$Rn, (and (srl rGPR:$Rm, imm8_or_16:$rot), 2411 0xFFFF)), 2412 (t2UXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 2413def : Thumb2DSPPat<(int_arm_uxtab16 rGPR:$Rn, rGPR:$Rm), 2414 (t2UXTAB16 rGPR:$Rn, rGPR:$Rm, 0)>; 2415def : Thumb2DSPPat<(int_arm_uxtab16 rGPR:$Rn, (rotr rGPR:$Rm, rot_imm:$rot)), 2416 (t2UXTAB16 rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>; 2417} 2418 2419 2420//===----------------------------------------------------------------------===// 2421// Arithmetic Instructions. 2422// 2423 2424let isAdd = 1 in 2425defm t2ADD : T2I_bin_ii12rs<0b000, "add", add, 1>; 2426defm t2SUB : T2I_bin_ii12rs<0b101, "sub", sub>; 2427 2428// ADD and SUB with 's' bit set. No 12-bit immediate (T4) variants. 2429// 2430// Currently, t2ADDS/t2SUBS are pseudo opcodes that exist only in the 2431// selection DAG. They are "lowered" to real t2ADD/t2SUB opcodes by 2432// AdjustInstrPostInstrSelection where we determine whether or not to 2433// set the "s" bit based on CPSR liveness. 2434// 2435// FIXME: Eliminate t2ADDS/t2SUBS pseudo opcodes after adding tablegen 2436// support for an optional CPSR definition that corresponds to the DAG 2437// node's second value. We can then eliminate the implicit def of CPSR. 2438defm t2ADDS : T2I_bin_s_irs <IIC_iALUi, IIC_iALUr, IIC_iALUsi, ARMaddc, 1>; 2439defm t2SUBS : T2I_bin_s_irs <IIC_iALUi, IIC_iALUr, IIC_iALUsi, ARMsubc>; 2440 2441defm t2ADC : T2I_adde_sube_irs<0b1010, "adc", ARMadde, 1, 1>; 2442defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc", ARMsube, 0, 1>; 2443 2444def : t2InstSubst<"adc${s}${p} $rd, $rn, $imm", 2445 (t2SBCri rGPR:$rd, rGPR:$rn, t2_so_imm_not:$imm, pred:$p, s_cc_out:$s)>; 2446def : t2InstSubst<"adc${s}${p} $rdn, $imm", 2447 (t2SBCri rGPR:$rdn, rGPR:$rdn, t2_so_imm_not:$imm, pred:$p, s_cc_out:$s)>; 2448def : t2InstSubst<"sbc${s}${p} $rd, $rn, $imm", 2449 (t2ADCri rGPR:$rd, rGPR:$rn, t2_so_imm_not:$imm, pred:$p, s_cc_out:$s)>; 2450def : t2InstSubst<"sbc${s}${p} $rdn, $imm", 2451 (t2ADCri rGPR:$rdn, rGPR:$rdn, t2_so_imm_not:$imm, pred:$p, s_cc_out:$s)>; 2452 2453def : t2InstSubst<"add${s}${p}.w $rd, $rn, $imm", 2454 (t2SUBri rGPR:$rd, GPRnopc:$rn, t2_so_imm_neg:$imm, pred:$p, s_cc_out:$s)>; 2455def : t2InstSubst<"sub${s}${p}.w $rd, $rn, $imm", 2456 (t2ADDri rGPR:$rd, GPRnopc:$rn, t2_so_imm_neg:$imm, pred:$p, s_cc_out:$s)>; 2457def : t2InstSubst<"subw${p} $Rd, $Rn, $imm", 2458 (t2ADDri12 rGPR:$Rd, GPR:$Rn, imm0_4095_neg:$imm, pred:$p)>; 2459def : t2InstSubst<"sub${s}${p} $rd, $rn, $imm", 2460 (t2ADDri rGPR:$rd, GPRnopc:$rn, t2_so_imm_neg:$imm, pred:$p, s_cc_out:$s)>; 2461def : t2InstSubst<"sub${p} $rd, $rn, $imm", 2462 (t2ADDri12 rGPR:$rd, GPR:$rn, imm0_4095_neg:$imm, pred:$p)>; 2463 2464// SP to SP alike 2465def : t2InstSubst<"add${s}${p}.w $rd, $rn, $imm", 2466 (t2SUBspImm GPRsp:$rd, GPRsp:$rn, t2_so_imm_neg:$imm, pred:$p, s_cc_out:$s)>; 2467def : t2InstSubst<"sub${s}${p}.w $rd, $rn, $imm", 2468 (t2ADDspImm GPRsp:$rd, GPRsp:$rn, t2_so_imm_neg:$imm, pred:$p, s_cc_out:$s)>; 2469def : t2InstSubst<"subw${p} $Rd, $Rn, $imm", 2470 (t2ADDspImm12 GPRsp:$Rd, GPRsp:$Rn, imm0_4095_neg:$imm, pred:$p)>; 2471def : t2InstSubst<"sub${s}${p} $rd, $rn, $imm", 2472 (t2ADDspImm GPRsp:$rd, GPRsp:$rn, t2_so_imm_neg:$imm, pred:$p, s_cc_out:$s)>; 2473def : t2InstSubst<"sub${p} $rd, $rn, $imm", 2474 (t2ADDspImm12 GPRsp:$rd, GPRsp:$rn, imm0_4095_neg:$imm, pred:$p)>; 2475 2476 2477// RSB 2478defm t2RSB : T2I_rbin_irs <0b1110, "rsb", sub>; 2479 2480// FIXME: Eliminate them if we can write def : Pat patterns which defines 2481// CPSR and the implicit def of CPSR is not needed. 2482defm t2RSBS : T2I_rbin_s_is <ARMsubc>; 2483 2484// (sub X, imm) gets canonicalized to (add X, -imm). Match this form. 2485// The assume-no-carry-in form uses the negation of the input since add/sub 2486// assume opposite meanings of the carry flag (i.e., carry == !borrow). 2487// See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory 2488// details. 2489// The AddedComplexity preferences the first variant over the others since 2490// it can be shrunk to a 16-bit wide encoding, while the others cannot. 2491let AddedComplexity = 1 in 2492def : T2Pat<(add rGPR:$src, imm1_255_neg:$imm), 2493 (t2SUBri rGPR:$src, imm1_255_neg:$imm)>; 2494def : T2Pat<(add rGPR:$src, t2_so_imm_neg:$imm), 2495 (t2SUBri rGPR:$src, t2_so_imm_neg:$imm)>; 2496def : T2Pat<(add rGPR:$src, imm0_4095_neg:$imm), 2497 (t2SUBri12 rGPR:$src, imm0_4095_neg:$imm)>; 2498def : T2Pat<(add GPR:$src, imm0_65535_neg:$imm), 2499 (t2SUBrr GPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>; 2500 2501// Do the same for v8m targets since they support movw with a 16-bit value. 2502def : T1Pat<(add tGPR:$src, imm0_65535_neg:$imm), 2503 (tSUBrr tGPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>, 2504 Requires<[HasV8MBaseline]>; 2505 2506let AddedComplexity = 1 in 2507def : T2Pat<(ARMaddc rGPR:$src, imm1_255_neg:$imm), 2508 (t2SUBSri rGPR:$src, imm1_255_neg:$imm)>; 2509def : T2Pat<(ARMaddc rGPR:$src, t2_so_imm_neg:$imm), 2510 (t2SUBSri rGPR:$src, t2_so_imm_neg:$imm)>; 2511def : T2Pat<(ARMaddc rGPR:$src, imm0_65535_neg:$imm), 2512 (t2SUBSrr rGPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>; 2513// The with-carry-in form matches bitwise not instead of the negation. 2514// Effectively, the inverse interpretation of the carry flag already accounts 2515// for part of the negation. 2516let AddedComplexity = 1 in 2517def : T2Pat<(ARMadde rGPR:$src, imm0_255_not:$imm, CPSR), 2518 (t2SBCri rGPR:$src, imm0_255_not:$imm)>; 2519def : T2Pat<(ARMadde rGPR:$src, t2_so_imm_not:$imm, CPSR), 2520 (t2SBCri rGPR:$src, t2_so_imm_not:$imm)>; 2521def : T2Pat<(ARMadde rGPR:$src, imm0_65535_neg:$imm, CPSR), 2522 (t2SBCrr rGPR:$src, (t2MOVi16 (imm_not_XFORM imm:$imm)))>; 2523 2524def t2SEL : T2ThreeReg<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), 2525 NoItinerary, "sel", "\t$Rd, $Rn, $Rm", 2526 [(set GPR:$Rd, (int_arm_sel GPR:$Rn, GPR:$Rm))]>, 2527 Requires<[IsThumb2, HasDSP]> { 2528 let Inst{31-27} = 0b11111; 2529 let Inst{26-24} = 0b010; 2530 let Inst{23} = 0b1; 2531 let Inst{22-20} = 0b010; 2532 let Inst{15-12} = 0b1111; 2533 let Inst{7} = 0b1; 2534 let Inst{6-4} = 0b000; 2535} 2536 2537// A6.3.13, A6.3.14, A6.3.15 Parallel addition and subtraction (signed/unsigned) 2538// And Miscellaneous operations -- for disassembly only 2539class T2I_pam<bits<3> op22_20, bits<4> op7_4, string opc, 2540 list<dag> pat, dag iops, string asm> 2541 : T2I<(outs rGPR:$Rd), iops, NoItinerary, opc, asm, pat>, 2542 Requires<[IsThumb2, HasDSP]> { 2543 let Inst{31-27} = 0b11111; 2544 let Inst{26-23} = 0b0101; 2545 let Inst{22-20} = op22_20; 2546 let Inst{15-12} = 0b1111; 2547 let Inst{7-4} = op7_4; 2548 2549 bits<4> Rd; 2550 bits<4> Rn; 2551 bits<4> Rm; 2552 2553 let Inst{11-8} = Rd; 2554 let Inst{19-16} = Rn; 2555 let Inst{3-0} = Rm; 2556} 2557 2558class T2I_pam_intrinsics<bits<3> op22_20, bits<4> op7_4, string opc, 2559 Intrinsic intrinsic> 2560 : T2I_pam<op22_20, op7_4, opc, 2561 [(set rGPR:$Rd, (intrinsic rGPR:$Rn, rGPR:$Rm))], 2562 (ins rGPR:$Rn, rGPR:$Rm), "\t$Rd, $Rn, $Rm">; 2563 2564class T2I_pam_intrinsics_rev<bits<3> op22_20, bits<4> op7_4, string opc> 2565 : T2I_pam<op22_20, op7_4, opc, [], 2566 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">; 2567 2568// Saturating add/subtract 2569def t2QADD16 : T2I_pam_intrinsics<0b001, 0b0001, "qadd16", int_arm_qadd16>; 2570def t2QADD8 : T2I_pam_intrinsics<0b000, 0b0001, "qadd8", int_arm_qadd8>; 2571def t2QASX : T2I_pam_intrinsics<0b010, 0b0001, "qasx", int_arm_qasx>; 2572def t2UQSUB8 : T2I_pam_intrinsics<0b100, 0b0101, "uqsub8", int_arm_uqsub8>; 2573def t2QSAX : T2I_pam_intrinsics<0b110, 0b0001, "qsax", int_arm_qsax>; 2574def t2QSUB16 : T2I_pam_intrinsics<0b101, 0b0001, "qsub16", int_arm_qsub16>; 2575def t2QSUB8 : T2I_pam_intrinsics<0b100, 0b0001, "qsub8", int_arm_qsub8>; 2576def t2UQADD16 : T2I_pam_intrinsics<0b001, 0b0101, "uqadd16", int_arm_uqadd16>; 2577def t2UQADD8 : T2I_pam_intrinsics<0b000, 0b0101, "uqadd8", int_arm_uqadd8>; 2578def t2UQASX : T2I_pam_intrinsics<0b010, 0b0101, "uqasx", int_arm_uqasx>; 2579def t2UQSAX : T2I_pam_intrinsics<0b110, 0b0101, "uqsax", int_arm_uqsax>; 2580def t2UQSUB16 : T2I_pam_intrinsics<0b101, 0b0101, "uqsub16", int_arm_uqsub16>; 2581def t2QADD : T2I_pam_intrinsics_rev<0b000, 0b1000, "qadd">; 2582def t2QSUB : T2I_pam_intrinsics_rev<0b000, 0b1010, "qsub">; 2583def t2QDADD : T2I_pam_intrinsics_rev<0b000, 0b1001, "qdadd">; 2584def t2QDSUB : T2I_pam_intrinsics_rev<0b000, 0b1011, "qdsub">; 2585 2586def : Thumb2DSPPat<(int_arm_qadd rGPR:$Rm, rGPR:$Rn), 2587 (t2QADD rGPR:$Rm, rGPR:$Rn)>; 2588def : Thumb2DSPPat<(int_arm_qsub rGPR:$Rm, rGPR:$Rn), 2589 (t2QSUB rGPR:$Rm, rGPR:$Rn)>; 2590def : Thumb2DSPPat<(int_arm_qadd rGPR:$Rm, (int_arm_qadd rGPR:$Rn, rGPR:$Rn)), 2591 (t2QDADD rGPR:$Rm, rGPR:$Rn)>; 2592def : Thumb2DSPPat<(int_arm_qsub rGPR:$Rm, (int_arm_qadd rGPR:$Rn, rGPR:$Rn)), 2593 (t2QDSUB rGPR:$Rm, rGPR:$Rn)>; 2594 2595def : Thumb2DSPPat<(saddsat rGPR:$Rm, rGPR:$Rn), 2596 (t2QADD rGPR:$Rm, rGPR:$Rn)>; 2597def : Thumb2DSPPat<(ssubsat rGPR:$Rm, rGPR:$Rn), 2598 (t2QSUB rGPR:$Rm, rGPR:$Rn)>; 2599def : Thumb2DSPPat<(saddsat rGPR:$Rm, (saddsat rGPR:$Rn, rGPR:$Rn)), 2600 (t2QDADD rGPR:$Rm, rGPR:$Rn)>; 2601def : Thumb2DSPPat<(ssubsat rGPR:$Rm, (saddsat rGPR:$Rn, rGPR:$Rn)), 2602 (t2QDSUB rGPR:$Rm, rGPR:$Rn)>; 2603 2604def : Thumb2DSPPat<(ARMqadd8b rGPR:$Rm, rGPR:$Rn), 2605 (t2QADD8 rGPR:$Rm, rGPR:$Rn)>; 2606def : Thumb2DSPPat<(ARMqsub8b rGPR:$Rm, rGPR:$Rn), 2607 (t2QSUB8 rGPR:$Rm, rGPR:$Rn)>; 2608def : Thumb2DSPPat<(ARMqadd16b rGPR:$Rm, rGPR:$Rn), 2609 (t2QADD16 rGPR:$Rm, rGPR:$Rn)>; 2610def : Thumb2DSPPat<(ARMqsub16b rGPR:$Rm, rGPR:$Rn), 2611 (t2QSUB16 rGPR:$Rm, rGPR:$Rn)>; 2612 2613def : Thumb2DSPPat<(ARMuqadd8b rGPR:$Rm, rGPR:$Rn), 2614 (t2UQADD8 rGPR:$Rm, rGPR:$Rn)>; 2615def : Thumb2DSPPat<(ARMuqsub8b rGPR:$Rm, rGPR:$Rn), 2616 (t2UQSUB8 rGPR:$Rm, rGPR:$Rn)>; 2617def : Thumb2DSPPat<(ARMuqadd16b rGPR:$Rm, rGPR:$Rn), 2618 (t2UQADD16 rGPR:$Rm, rGPR:$Rn)>; 2619def : Thumb2DSPPat<(ARMuqsub16b rGPR:$Rm, rGPR:$Rn), 2620 (t2UQSUB16 rGPR:$Rm, rGPR:$Rn)>; 2621 2622// Signed/Unsigned add/subtract 2623 2624def t2SASX : T2I_pam_intrinsics<0b010, 0b0000, "sasx", int_arm_sasx>; 2625def t2SADD16 : T2I_pam_intrinsics<0b001, 0b0000, "sadd16", int_arm_sadd16>; 2626def t2SADD8 : T2I_pam_intrinsics<0b000, 0b0000, "sadd8", int_arm_sadd8>; 2627def t2SSAX : T2I_pam_intrinsics<0b110, 0b0000, "ssax", int_arm_ssax>; 2628def t2SSUB16 : T2I_pam_intrinsics<0b101, 0b0000, "ssub16", int_arm_ssub16>; 2629def t2SSUB8 : T2I_pam_intrinsics<0b100, 0b0000, "ssub8", int_arm_ssub8>; 2630def t2UASX : T2I_pam_intrinsics<0b010, 0b0100, "uasx", int_arm_uasx>; 2631def t2UADD16 : T2I_pam_intrinsics<0b001, 0b0100, "uadd16", int_arm_uadd16>; 2632def t2UADD8 : T2I_pam_intrinsics<0b000, 0b0100, "uadd8", int_arm_uadd8>; 2633def t2USAX : T2I_pam_intrinsics<0b110, 0b0100, "usax", int_arm_usax>; 2634def t2USUB16 : T2I_pam_intrinsics<0b101, 0b0100, "usub16", int_arm_usub16>; 2635def t2USUB8 : T2I_pam_intrinsics<0b100, 0b0100, "usub8", int_arm_usub8>; 2636 2637// Signed/Unsigned halving add/subtract 2638 2639def t2SHASX : T2I_pam_intrinsics<0b010, 0b0010, "shasx", int_arm_shasx>; 2640def t2SHADD16 : T2I_pam_intrinsics<0b001, 0b0010, "shadd16", int_arm_shadd16>; 2641def t2SHADD8 : T2I_pam_intrinsics<0b000, 0b0010, "shadd8", int_arm_shadd8>; 2642def t2SHSAX : T2I_pam_intrinsics<0b110, 0b0010, "shsax", int_arm_shsax>; 2643def t2SHSUB16 : T2I_pam_intrinsics<0b101, 0b0010, "shsub16", int_arm_shsub16>; 2644def t2SHSUB8 : T2I_pam_intrinsics<0b100, 0b0010, "shsub8", int_arm_shsub8>; 2645def t2UHASX : T2I_pam_intrinsics<0b010, 0b0110, "uhasx", int_arm_uhasx>; 2646def t2UHADD16 : T2I_pam_intrinsics<0b001, 0b0110, "uhadd16", int_arm_uhadd16>; 2647def t2UHADD8 : T2I_pam_intrinsics<0b000, 0b0110, "uhadd8", int_arm_uhadd8>; 2648def t2UHSAX : T2I_pam_intrinsics<0b110, 0b0110, "uhsax", int_arm_uhsax>; 2649def t2UHSUB16 : T2I_pam_intrinsics<0b101, 0b0110, "uhsub16", int_arm_uhsub16>; 2650def t2UHSUB8 : T2I_pam_intrinsics<0b100, 0b0110, "uhsub8", int_arm_uhsub8>; 2651 2652// Helper class for disassembly only 2653// A6.3.16 & A6.3.17 2654// T2Imac - Thumb2 multiply [accumulate, and absolute difference] instructions. 2655class T2ThreeReg_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops, 2656 dag iops, InstrItinClass itin, string opc, string asm, list<dag> pattern> 2657 : T2ThreeReg<oops, iops, itin, opc, asm, pattern> { 2658 let Inst{31-27} = 0b11111; 2659 let Inst{26-24} = 0b011; 2660 let Inst{23} = long; 2661 let Inst{22-20} = op22_20; 2662 let Inst{7-4} = op7_4; 2663} 2664 2665class T2FourReg_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops, 2666 dag iops, InstrItinClass itin, string opc, string asm, list<dag> pattern> 2667 : T2FourReg<oops, iops, itin, opc, asm, pattern> { 2668 let Inst{31-27} = 0b11111; 2669 let Inst{26-24} = 0b011; 2670 let Inst{23} = long; 2671 let Inst{22-20} = op22_20; 2672 let Inst{7-4} = op7_4; 2673} 2674 2675// Unsigned Sum of Absolute Differences [and Accumulate]. 2676def t2USAD8 : T2ThreeReg_mac<0, 0b111, 0b0000, (outs rGPR:$Rd), 2677 (ins rGPR:$Rn, rGPR:$Rm), 2678 NoItinerary, "usad8", "\t$Rd, $Rn, $Rm", 2679 [(set rGPR:$Rd, (int_arm_usad8 rGPR:$Rn, rGPR:$Rm))]>, 2680 Requires<[IsThumb2, HasDSP]> { 2681 let Inst{15-12} = 0b1111; 2682} 2683def t2USADA8 : T2FourReg_mac<0, 0b111, 0b0000, (outs rGPR:$Rd), 2684 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), NoItinerary, 2685 "usada8", "\t$Rd, $Rn, $Rm, $Ra", 2686 [(set rGPR:$Rd, (int_arm_usada8 rGPR:$Rn, rGPR:$Rm, rGPR:$Ra))]>, 2687 Requires<[IsThumb2, HasDSP]>; 2688 2689// Signed/Unsigned saturate. 2690class T2SatI<dag iops, string opc, string asm> 2691 : T2I<(outs rGPR:$Rd), iops, NoItinerary, opc, asm, []> { 2692 bits<4> Rd; 2693 bits<4> Rn; 2694 bits<5> sat_imm; 2695 bits<6> sh; 2696 2697 let Inst{31-24} = 0b11110011; 2698 let Inst{21} = sh{5}; 2699 let Inst{20} = 0; 2700 let Inst{19-16} = Rn; 2701 let Inst{15} = 0; 2702 let Inst{14-12} = sh{4-2}; 2703 let Inst{11-8} = Rd; 2704 let Inst{7-6} = sh{1-0}; 2705 let Inst{5} = 0; 2706 let Inst{4-0} = sat_imm; 2707} 2708 2709def t2SSAT: T2SatI<(ins imm1_32:$sat_imm, rGPR:$Rn, t2_shift_imm:$sh), 2710 "ssat", "\t$Rd, $sat_imm, $Rn$sh">, 2711 Requires<[IsThumb2]>, Sched<[WriteALU]> { 2712 let Inst{23-22} = 0b00; 2713 let Inst{5} = 0; 2714} 2715 2716def t2SSAT16: T2SatI<(ins imm1_16:$sat_imm, rGPR:$Rn), 2717 "ssat16", "\t$Rd, $sat_imm, $Rn">, 2718 Requires<[IsThumb2, HasDSP]>, Sched<[WriteALU]> { 2719 let Inst{23-22} = 0b00; 2720 let sh = 0b100000; 2721 let Inst{4} = 0; 2722} 2723 2724def t2USAT: T2SatI<(ins imm0_31:$sat_imm, rGPR:$Rn, t2_shift_imm:$sh), 2725 "usat", "\t$Rd, $sat_imm, $Rn$sh">, 2726 Requires<[IsThumb2]>, Sched<[WriteALU]> { 2727 let Inst{23-22} = 0b10; 2728} 2729 2730def t2USAT16: T2SatI<(ins imm0_15:$sat_imm, rGPR:$Rn), 2731 "usat16", "\t$Rd, $sat_imm, $Rn">, 2732 Requires<[IsThumb2, HasDSP]>, Sched<[WriteALU]> { 2733 let Inst{23-22} = 0b10; 2734 let sh = 0b100000; 2735 let Inst{4} = 0; 2736} 2737 2738def : T2Pat<(ARMssat GPRnopc:$Rn, imm0_31:$imm), 2739 (t2SSAT imm0_31:$imm, GPRnopc:$Rn, 0)>; 2740def : T2Pat<(ARMusat GPRnopc:$Rn, imm0_31:$imm), 2741 (t2USAT imm0_31:$imm, GPRnopc:$Rn, 0)>; 2742def : T2Pat<(int_arm_ssat GPR:$a, imm1_32:$pos), 2743 (t2SSAT imm1_32:$pos, GPR:$a, 0)>; 2744def : T2Pat<(int_arm_usat GPR:$a, imm0_31:$pos), 2745 (t2USAT imm0_31:$pos, GPR:$a, 0)>; 2746def : T2Pat<(int_arm_ssat16 GPR:$a, imm1_16:$pos), 2747 (t2SSAT16 imm1_16:$pos, GPR:$a)>; 2748def : T2Pat<(int_arm_usat16 GPR:$a, imm0_15:$pos), 2749 (t2USAT16 imm0_15:$pos, GPR:$a)>; 2750def : T2Pat<(int_arm_ssat (shl GPRnopc:$a, imm0_31:$shft), imm1_32:$pos), 2751 (t2SSAT imm1_32:$pos, GPRnopc:$a, imm0_31:$shft)>; 2752def : T2Pat<(int_arm_ssat (sra GPRnopc:$a, asr_imm:$shft), imm1_32:$pos), 2753 (t2SSAT imm1_32:$pos, GPRnopc:$a, asr_imm:$shft)>; 2754def : T2Pat<(int_arm_usat (shl GPRnopc:$a, imm0_31:$shft), imm0_31:$pos), 2755 (t2USAT imm0_31:$pos, GPRnopc:$a, imm0_31:$shft)>; 2756def : T2Pat<(int_arm_usat (sra GPRnopc:$a, asr_imm:$shft), imm0_31:$pos), 2757 (t2USAT imm0_31:$pos, GPRnopc:$a, asr_imm:$shft)>; 2758def : T2Pat<(ARMssat (shl GPRnopc:$a, imm0_31:$shft), imm0_31:$pos), 2759 (t2SSAT imm0_31:$pos, GPRnopc:$a, imm0_31:$shft)>; 2760def : T2Pat<(ARMssat (sra GPRnopc:$Rn, asr_imm:$shft), imm0_31:$pos), 2761 (t2SSAT imm0_31:$pos, GPRnopc:$Rn, asr_imm:$shft)>; 2762def : T2Pat<(ARMusat (shl GPRnopc:$a, imm0_31:$shft), imm0_31:$pos), 2763 (t2USAT imm0_31:$pos, GPRnopc:$a, imm0_31:$shft)>; 2764def : T2Pat<(ARMusat (sra GPRnopc:$Rn, asr_imm:$shft), imm0_31:$pos), 2765 (t2USAT imm0_31:$pos, GPRnopc:$Rn, asr_imm:$shft)>; 2766 2767 2768//===----------------------------------------------------------------------===// 2769// Shift and rotate Instructions. 2770// 2771 2772defm t2LSL : T2I_sh_ir<0b00, "lsl", imm1_31, shl>; 2773defm t2LSR : T2I_sh_ir<0b01, "lsr", imm_sr, srl>; 2774defm t2ASR : T2I_sh_ir<0b10, "asr", imm_sr, sra>; 2775defm t2ROR : T2I_sh_ir<0b11, "ror", imm1_31, rotr>; 2776 2777// LSL #0 is actually MOV, and has slightly different permitted registers to 2778// LSL with non-zero shift 2779def : t2InstAlias<"lsl${s}${p} $Rd, $Rm, #0", 2780 (t2MOVr GPRnopc:$Rd, GPRnopc:$Rm, pred:$p, cc_out:$s)>; 2781def : t2InstAlias<"lsl${s}${p}.w $Rd, $Rm, #0", 2782 (t2MOVr GPRnopc:$Rd, GPRnopc:$Rm, pred:$p, cc_out:$s)>; 2783 2784// (rotr x, (and y, 0x...1f)) ==> (ROR x, y) 2785def : T2Pat<(rotr rGPR:$lhs, (and rGPR:$rhs, lo5AllOne)), 2786 (t2RORrr rGPR:$lhs, rGPR:$rhs)>; 2787 2788let Uses = [CPSR] in { 2789def t2RRX : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi, 2790 "rrx", "\t$Rd, $Rm", 2791 [(set rGPR:$Rd, (ARMrrx rGPR:$Rm))]>, Sched<[WriteALU]> { 2792 let Inst{31-27} = 0b11101; 2793 let Inst{26-25} = 0b01; 2794 let Inst{24-21} = 0b0010; 2795 let Inst{19-16} = 0b1111; // Rn 2796 let Inst{15} = 0b0; 2797 let Unpredictable{15} = 0b1; 2798 let Inst{14-12} = 0b000; 2799 let Inst{7-4} = 0b0011; 2800} 2801} 2802 2803let isCodeGenOnly = 1, Defs = [CPSR] in { 2804def t2MOVsrl_glue : T2TwoRegShiftImm< 2805 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi, 2806 "lsrs", ".w\t$Rd, $Rm, #1", 2807 [(set rGPR:$Rd, (ARMsrl_glue rGPR:$Rm))]>, 2808 Sched<[WriteALU]> { 2809 let Inst{31-27} = 0b11101; 2810 let Inst{26-25} = 0b01; 2811 let Inst{24-21} = 0b0010; 2812 let Inst{20} = 1; // The S bit. 2813 let Inst{19-16} = 0b1111; // Rn 2814 let Inst{5-4} = 0b01; // Shift type. 2815 // Shift amount = Inst{14-12:7-6} = 1. 2816 let Inst{14-12} = 0b000; 2817 let Inst{7-6} = 0b01; 2818} 2819def t2MOVsra_glue : T2TwoRegShiftImm< 2820 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi, 2821 "asrs", ".w\t$Rd, $Rm, #1", 2822 [(set rGPR:$Rd, (ARMsra_glue rGPR:$Rm))]>, 2823 Sched<[WriteALU]> { 2824 let Inst{31-27} = 0b11101; 2825 let Inst{26-25} = 0b01; 2826 let Inst{24-21} = 0b0010; 2827 let Inst{20} = 1; // The S bit. 2828 let Inst{19-16} = 0b1111; // Rn 2829 let Inst{5-4} = 0b10; // Shift type. 2830 // Shift amount = Inst{14-12:7-6} = 1. 2831 let Inst{14-12} = 0b000; 2832 let Inst{7-6} = 0b01; 2833} 2834} 2835 2836//===----------------------------------------------------------------------===// 2837// Bitwise Instructions. 2838// 2839 2840defm t2AND : T2I_bin_w_irs<0b0000, "and", 2841 IIC_iBITi, IIC_iBITr, IIC_iBITsi, and, 1>; 2842defm t2ORR : T2I_bin_w_irs<0b0010, "orr", 2843 IIC_iBITi, IIC_iBITr, IIC_iBITsi, or, 1>; 2844defm t2EOR : T2I_bin_w_irs<0b0100, "eor", 2845 IIC_iBITi, IIC_iBITr, IIC_iBITsi, xor, 1>; 2846 2847defm t2BIC : T2I_bin_w_irs<0b0001, "bic", 2848 IIC_iBITi, IIC_iBITr, IIC_iBITsi, 2849 BinOpFrag<(and node:$LHS, (not node:$RHS))>>; 2850 2851class T2BitFI<dag oops, dag iops, InstrItinClass itin, 2852 string opc, string asm, list<dag> pattern> 2853 : T2I<oops, iops, itin, opc, asm, pattern> { 2854 bits<4> Rd; 2855 bits<5> msb; 2856 bits<5> lsb; 2857 2858 let Inst{11-8} = Rd; 2859 let Inst{4-0} = msb{4-0}; 2860 let Inst{14-12} = lsb{4-2}; 2861 let Inst{7-6} = lsb{1-0}; 2862} 2863 2864class T2TwoRegBitFI<dag oops, dag iops, InstrItinClass itin, 2865 string opc, string asm, list<dag> pattern> 2866 : T2BitFI<oops, iops, itin, opc, asm, pattern> { 2867 bits<4> Rn; 2868 2869 let Inst{19-16} = Rn; 2870} 2871 2872let Constraints = "$src = $Rd" in 2873def t2BFC : T2BitFI<(outs rGPR:$Rd), (ins rGPR:$src, bf_inv_mask_imm:$imm), 2874 IIC_iUNAsi, "bfc", "\t$Rd, $imm", 2875 [(set rGPR:$Rd, (and rGPR:$src, bf_inv_mask_imm:$imm))]>, Sched<[WriteALU]> { 2876 let Inst{31-27} = 0b11110; 2877 let Inst{26} = 0; // should be 0. 2878 let Inst{25} = 1; 2879 let Inst{24-20} = 0b10110; 2880 let Inst{19-16} = 0b1111; // Rn 2881 let Inst{15} = 0; 2882 let Inst{5} = 0; // should be 0. 2883 2884 bits<10> imm; 2885 let msb{4-0} = imm{9-5}; 2886 let lsb{4-0} = imm{4-0}; 2887} 2888 2889def t2SBFX: T2TwoRegBitFI< 2890 (outs rGPR:$Rd), (ins rGPR:$Rn, imm0_31:$lsb, imm1_32:$msb), 2891 IIC_iUNAsi, "sbfx", "\t$Rd, $Rn, $lsb, $msb", []>, Sched<[WriteALU]> { 2892 let Inst{31-27} = 0b11110; 2893 let Inst{25} = 1; 2894 let Inst{24-20} = 0b10100; 2895 let Inst{15} = 0; 2896 2897 let hasSideEffects = 0; 2898} 2899 2900def t2UBFX: T2TwoRegBitFI< 2901 (outs rGPR:$Rd), (ins rGPR:$Rn, imm0_31:$lsb, imm1_32:$msb), 2902 IIC_iUNAsi, "ubfx", "\t$Rd, $Rn, $lsb, $msb", []>, Sched<[WriteALU]> { 2903 let Inst{31-27} = 0b11110; 2904 let Inst{25} = 1; 2905 let Inst{24-20} = 0b11100; 2906 let Inst{15} = 0; 2907 2908 let hasSideEffects = 0; 2909} 2910 2911// A8.8.247 UDF - Undefined (Encoding T2) 2912def t2UDF : T2XI<(outs), (ins imm0_65535:$imm16), IIC_Br, "udf.w\t$imm16", 2913 [(int_arm_undefined imm0_65535:$imm16)]> { 2914 bits<16> imm16; 2915 let Inst{31-29} = 0b111; 2916 let Inst{28-27} = 0b10; 2917 let Inst{26-20} = 0b1111111; 2918 let Inst{19-16} = imm16{15-12}; 2919 let Inst{15} = 0b1; 2920 let Inst{14-12} = 0b010; 2921 let Inst{11-0} = imm16{11-0}; 2922} 2923 2924// A8.6.18 BFI - Bitfield insert (Encoding T1) 2925let Constraints = "$src = $Rd" in { 2926 def t2BFI : T2TwoRegBitFI<(outs rGPR:$Rd), 2927 (ins rGPR:$src, rGPR:$Rn, bf_inv_mask_imm:$imm), 2928 IIC_iBITi, "bfi", "\t$Rd, $Rn, $imm", 2929 [(set rGPR:$Rd, (ARMbfi rGPR:$src, rGPR:$Rn, 2930 bf_inv_mask_imm:$imm))]>, Sched<[WriteALU]> { 2931 let Inst{31-27} = 0b11110; 2932 let Inst{26} = 0; // should be 0. 2933 let Inst{25} = 1; 2934 let Inst{24-20} = 0b10110; 2935 let Inst{15} = 0; 2936 let Inst{5} = 0; // should be 0. 2937 2938 bits<10> imm; 2939 let msb{4-0} = imm{9-5}; 2940 let lsb{4-0} = imm{4-0}; 2941 } 2942} 2943 2944defm t2ORN : T2I_bin_irs<0b0011, "orn", 2945 IIC_iBITi, IIC_iBITr, IIC_iBITsi, 2946 BinOpFrag<(or node:$LHS, (not node:$RHS))>, 0, "">; 2947def : t2InstAlias<"orn${s}${p}.w $Rd, $Rn, $imm", 2948 (t2ORNri rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; 2949def : t2InstAlias<"orn${s}${p}.w $Rd, $Rn, $Rm", 2950 (t2ORNrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>; 2951def : t2InstAlias<"orn${s}${p}.w $Rd, $Rn, $ShiftedRm", 2952 (t2ORNrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm, pred:$p, cc_out:$s)>; 2953 2954/// T2I_un_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a 2955/// unary operation that produces a value. These are predicable and can be 2956/// changed to modify CPSR. 2957multiclass T2I_un_irs<bits<4> opcod, string opc, 2958 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis, 2959 PatFrag opnode, 2960 bit Cheap = 0, bit ReMat = 0, bit MoveImm = 0> { 2961 // shifted imm 2962 def i : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), iii, 2963 opc, "\t$Rd, $imm", 2964 [(set rGPR:$Rd, (opnode t2_so_imm:$imm))]>, Sched<[WriteALU]> { 2965 let isAsCheapAsAMove = Cheap; 2966 let isReMaterializable = ReMat; 2967 let isMoveImm = MoveImm; 2968 let Inst{31-27} = 0b11110; 2969 let Inst{25} = 0; 2970 let Inst{24-21} = opcod; 2971 let Inst{19-16} = 0b1111; // Rn 2972 let Inst{15} = 0; 2973 } 2974 // register 2975 def r : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), iir, 2976 opc, ".w\t$Rd, $Rm", 2977 [(set rGPR:$Rd, (opnode rGPR:$Rm))]>, Sched<[WriteALU]> { 2978 let Inst{31-27} = 0b11101; 2979 let Inst{26-25} = 0b01; 2980 let Inst{24-21} = opcod; 2981 let Inst{19-16} = 0b1111; // Rn 2982 let Inst{14-12} = 0b000; // imm3 2983 let Inst{7-6} = 0b00; // imm2 2984 let Inst{5-4} = 0b00; // type 2985 } 2986 // shifted register 2987 def s : T2sOneRegShiftedReg<(outs rGPR:$Rd), (ins t2_so_reg:$ShiftedRm), iis, 2988 opc, ".w\t$Rd, $ShiftedRm", 2989 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm))]>, 2990 Sched<[WriteALU]> { 2991 let Inst{31-27} = 0b11101; 2992 let Inst{26-25} = 0b01; 2993 let Inst{24-21} = opcod; 2994 let Inst{19-16} = 0b1111; // Rn 2995 } 2996} 2997 2998// Prefer over of t2EORri ra, rb, -1 because mvn has 16-bit version 2999let AddedComplexity = 1 in 3000defm t2MVN : T2I_un_irs <0b0011, "mvn", 3001 IIC_iMVNi, IIC_iMVNr, IIC_iMVNsi, 3002 not, 1, 1, 1>; 3003 3004let AddedComplexity = 1 in 3005def : T2Pat<(and rGPR:$src, t2_so_imm_not:$imm), 3006 (t2BICri rGPR:$src, t2_so_imm_not:$imm)>; 3007 3008// so_imm_notSext is needed instead of so_imm_not, as the value of imm 3009// will match the extended, not the original bitWidth for $src. 3010def : T2Pat<(and top16Zero:$src, t2_so_imm_notSext:$imm), 3011 (t2BICri rGPR:$src, t2_so_imm_notSext:$imm)>; 3012 3013// FIXME: Disable this pattern on Darwin to workaround an assembler bug. 3014def : T2Pat<(or rGPR:$src, t2_so_imm_not:$imm), 3015 (t2ORNri rGPR:$src, t2_so_imm_not:$imm)>, 3016 Requires<[IsThumb2]>; 3017 3018def : T2Pat<(t2_so_imm_not:$src), 3019 (t2MVNi t2_so_imm_not:$src)>; 3020 3021// There are shorter Thumb encodings for ADD than ORR, so to increase 3022// Thumb2SizeReduction's chances later on we select a t2ADD for an or where 3023// possible. 3024def : T2Pat<(or AddLikeOrOp:$Rn, t2_so_imm:$imm), 3025 (t2ADDri rGPR:$Rn, t2_so_imm:$imm)>; 3026 3027def : T2Pat<(or AddLikeOrOp:$Rn, imm0_4095:$Rm), 3028 (t2ADDri12 rGPR:$Rn, imm0_4095:$Rm)>; 3029 3030def : T2Pat<(or AddLikeOrOp:$Rn, non_imm32:$Rm), 3031 (t2ADDrr $Rn, $Rm)>; 3032 3033//===----------------------------------------------------------------------===// 3034// Multiply Instructions. 3035// 3036let isCommutable = 1 in 3037def t2MUL: T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32, 3038 "mul", "\t$Rd, $Rn, $Rm", 3039 [(set rGPR:$Rd, (mul rGPR:$Rn, rGPR:$Rm))]>, 3040 Sched<[WriteMUL32, ReadMUL, ReadMUL]> { 3041 let Inst{31-27} = 0b11111; 3042 let Inst{26-23} = 0b0110; 3043 let Inst{22-20} = 0b000; 3044 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate) 3045 let Inst{7-4} = 0b0000; // Multiply 3046} 3047 3048class T2FourRegMLA<bits<4> op7_4, string opc, list<dag> pattern> 3049 : T2FourReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, 3050 opc, "\t$Rd, $Rn, $Rm, $Ra", pattern>, 3051 Requires<[IsThumb2, UseMulOps]>, 3052 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> { 3053 let Inst{31-27} = 0b11111; 3054 let Inst{26-23} = 0b0110; 3055 let Inst{22-20} = 0b000; 3056 let Inst{7-4} = op7_4; 3057} 3058 3059def t2MLA : T2FourRegMLA<0b0000, "mla", 3060 [(set rGPR:$Rd, (add (mul rGPR:$Rn, rGPR:$Rm), 3061 rGPR:$Ra))]>; 3062def t2MLS: T2FourRegMLA<0b0001, "mls", 3063 [(set rGPR:$Rd, (sub rGPR:$Ra, (mul rGPR:$Rn, 3064 rGPR:$Rm)))]>; 3065 3066// Extra precision multiplies with low / high results 3067let hasSideEffects = 0 in { 3068let isCommutable = 1 in { 3069def t2SMULL : T2MulLong<0b000, 0b0000, "smull", 3070 [(set rGPR:$RdLo, rGPR:$RdHi, 3071 (smullohi rGPR:$Rn, rGPR:$Rm))]>; 3072def t2UMULL : T2MulLong<0b010, 0b0000, "umull", 3073 [(set rGPR:$RdLo, rGPR:$RdHi, 3074 (umullohi rGPR:$Rn, rGPR:$Rm))]>; 3075} // isCommutable 3076 3077// Multiply + accumulate 3078def t2SMLAL : T2MlaLong<0b100, 0b0000, "smlal">; 3079def t2UMLAL : T2MlaLong<0b110, 0b0000, "umlal">; 3080def t2UMAAL : T2MlaLong<0b110, 0b0110, "umaal">, Requires<[IsThumb2, HasDSP]>; 3081} // hasSideEffects 3082 3083// Rounding variants of the below included for disassembly only 3084 3085// Most significant word multiply 3086class T2SMMUL<bits<4> op7_4, string opc, list<dag> pattern> 3087 : T2ThreeReg<(outs rGPR:$Rd), 3088 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32, 3089 opc, "\t$Rd, $Rn, $Rm", pattern>, 3090 Requires<[IsThumb2, HasDSP]>, 3091 Sched<[WriteMUL32, ReadMUL, ReadMUL]> { 3092 let Inst{31-27} = 0b11111; 3093 let Inst{26-23} = 0b0110; 3094 let Inst{22-20} = 0b101; 3095 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate) 3096 let Inst{7-4} = op7_4; 3097} 3098def t2SMMUL : T2SMMUL<0b0000, "smmul", [(set rGPR:$Rd, (mulhs rGPR:$Rn, 3099 rGPR:$Rm))]>; 3100def t2SMMULR : 3101 T2SMMUL<0b0001, "smmulr", 3102 [(set rGPR:$Rd, (ARMsmmlar rGPR:$Rn, rGPR:$Rm, (i32 0)))]>; 3103 3104class T2FourRegSMMLA<bits<3> op22_20, bits<4> op7_4, string opc, 3105 list<dag> pattern> 3106 : T2FourReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, 3107 opc, "\t$Rd, $Rn, $Rm, $Ra", pattern>, 3108 Requires<[IsThumb2, HasDSP, UseMulOps]>, 3109 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> { 3110 let Inst{31-27} = 0b11111; 3111 let Inst{26-23} = 0b0110; 3112 let Inst{22-20} = op22_20; 3113 let Inst{7-4} = op7_4; 3114} 3115 3116def t2SMMLA : T2FourRegSMMLA<0b101, 0b0000, "smmla", 3117 [(set rGPR:$Rd, (add (mulhs rGPR:$Rm, rGPR:$Rn), rGPR:$Ra))]>; 3118def t2SMMLAR: T2FourRegSMMLA<0b101, 0b0001, "smmlar", 3119 [(set rGPR:$Rd, (ARMsmmlar rGPR:$Rn, rGPR:$Rm, rGPR:$Ra))]>; 3120def t2SMMLS: T2FourRegSMMLA<0b110, 0b0000, "smmls", []>; 3121def t2SMMLSR: T2FourRegSMMLA<0b110, 0b0001, "smmlsr", 3122 [(set rGPR:$Rd, (ARMsmmlsr rGPR:$Rn, rGPR:$Rm, rGPR:$Ra))]>; 3123 3124class T2ThreeRegSMUL<bits<3> op22_20, bits<2> op5_4, string opc, 3125 list<dag> pattern> 3126 : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16, opc, 3127 "\t$Rd, $Rn, $Rm", pattern>, 3128 Requires<[IsThumb2, HasDSP]>, 3129 Sched<[WriteMUL16, ReadMUL, ReadMUL]> { 3130 let Inst{31-27} = 0b11111; 3131 let Inst{26-23} = 0b0110; 3132 let Inst{22-20} = op22_20; 3133 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate) 3134 let Inst{7-6} = 0b00; 3135 let Inst{5-4} = op5_4; 3136} 3137 3138def t2SMULBB : T2ThreeRegSMUL<0b001, 0b00, "smulbb", 3139 [(set rGPR:$Rd, (bb_mul rGPR:$Rn, rGPR:$Rm))]>; 3140def t2SMULBT : T2ThreeRegSMUL<0b001, 0b01, "smulbt", 3141 [(set rGPR:$Rd, (bt_mul rGPR:$Rn, rGPR:$Rm))]>; 3142def t2SMULTB : T2ThreeRegSMUL<0b001, 0b10, "smultb", 3143 [(set rGPR:$Rd, (tb_mul rGPR:$Rn, rGPR:$Rm))]>; 3144def t2SMULTT : T2ThreeRegSMUL<0b001, 0b11, "smultt", 3145 [(set rGPR:$Rd, (tt_mul rGPR:$Rn, rGPR:$Rm))]>; 3146def t2SMULWB : T2ThreeRegSMUL<0b011, 0b00, "smulwb", 3147 [(set rGPR:$Rd, (ARMsmulwb rGPR:$Rn, rGPR:$Rm))]>; 3148def t2SMULWT : T2ThreeRegSMUL<0b011, 0b01, "smulwt", 3149 [(set rGPR:$Rd, (ARMsmulwt rGPR:$Rn, rGPR:$Rm))]>; 3150 3151def : Thumb2DSPPat<(mul sext_16_node:$Rn, (sext_bottom_16 rGPR:$Rm)), 3152 (t2SMULBB rGPR:$Rn, rGPR:$Rm)>; 3153def : Thumb2DSPPat<(mul sext_16_node:$Rn, (sext_top_16 rGPR:$Rm)), 3154 (t2SMULBT rGPR:$Rn, rGPR:$Rm)>; 3155def : Thumb2DSPPat<(mul (sext_top_16 rGPR:$Rn), sext_16_node:$Rm), 3156 (t2SMULTB rGPR:$Rn, rGPR:$Rm)>; 3157 3158def : Thumb2DSPPat<(int_arm_smulbb rGPR:$Rn, rGPR:$Rm), 3159 (t2SMULBB rGPR:$Rn, rGPR:$Rm)>; 3160def : Thumb2DSPPat<(int_arm_smulbt rGPR:$Rn, rGPR:$Rm), 3161 (t2SMULBT rGPR:$Rn, rGPR:$Rm)>; 3162def : Thumb2DSPPat<(int_arm_smultb rGPR:$Rn, rGPR:$Rm), 3163 (t2SMULTB rGPR:$Rn, rGPR:$Rm)>; 3164def : Thumb2DSPPat<(int_arm_smultt rGPR:$Rn, rGPR:$Rm), 3165 (t2SMULTT rGPR:$Rn, rGPR:$Rm)>; 3166def : Thumb2DSPPat<(int_arm_smulwb rGPR:$Rn, rGPR:$Rm), 3167 (t2SMULWB rGPR:$Rn, rGPR:$Rm)>; 3168def : Thumb2DSPPat<(int_arm_smulwt rGPR:$Rn, rGPR:$Rm), 3169 (t2SMULWT rGPR:$Rn, rGPR:$Rm)>; 3170 3171class T2FourRegSMLA<bits<3> op22_20, bits<2> op5_4, string opc, 3172 list<dag> pattern> 3173 : T2FourReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMUL16, 3174 opc, "\t$Rd, $Rn, $Rm, $Ra", pattern>, 3175 Requires<[IsThumb2, HasDSP, UseMulOps]>, 3176 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]> { 3177 let Inst{31-27} = 0b11111; 3178 let Inst{26-23} = 0b0110; 3179 let Inst{22-20} = op22_20; 3180 let Inst{7-6} = 0b00; 3181 let Inst{5-4} = op5_4; 3182} 3183 3184def t2SMLABB : T2FourRegSMLA<0b001, 0b00, "smlabb", 3185 [(set rGPR:$Rd, (add rGPR:$Ra, (bb_mul rGPR:$Rn, rGPR:$Rm)))]>; 3186def t2SMLABT : T2FourRegSMLA<0b001, 0b01, "smlabt", 3187 [(set rGPR:$Rd, (add rGPR:$Ra, (bt_mul rGPR:$Rn, rGPR:$Rm)))]>; 3188def t2SMLATB : T2FourRegSMLA<0b001, 0b10, "smlatb", 3189 [(set rGPR:$Rd, (add rGPR:$Ra, (tb_mul rGPR:$Rn, rGPR:$Rm)))]>; 3190def t2SMLATT : T2FourRegSMLA<0b001, 0b11, "smlatt", 3191 [(set rGPR:$Rd, (add rGPR:$Ra, (tt_mul rGPR:$Rn, rGPR:$Rm)))]>; 3192def t2SMLAWB : T2FourRegSMLA<0b011, 0b00, "smlawb", 3193 [(set rGPR:$Rd, (add rGPR:$Ra, (ARMsmulwb rGPR:$Rn, rGPR:$Rm)))]>; 3194def t2SMLAWT : T2FourRegSMLA<0b011, 0b01, "smlawt", 3195 [(set rGPR:$Rd, (add rGPR:$Ra, (ARMsmulwt rGPR:$Rn, rGPR:$Rm)))]>; 3196 3197def : Thumb2DSPMulPat<(add rGPR:$Ra, (mul sext_16_node:$Rn, sext_16_node:$Rm)), 3198 (t2SMLABB rGPR:$Rn, rGPR:$Rm, rGPR:$Ra)>; 3199def : Thumb2DSPMulPat<(add rGPR:$Ra, (mul sext_16_node:$Rn, 3200 (sext_bottom_16 rGPR:$Rm))), 3201 (t2SMLABB rGPR:$Rn, rGPR:$Rm, rGPR:$Ra)>; 3202def : Thumb2DSPMulPat<(add rGPR:$Ra, (mul sext_16_node:$Rn, 3203 (sext_top_16 rGPR:$Rm))), 3204 (t2SMLABT rGPR:$Rn, rGPR:$Rm, rGPR:$Ra)>; 3205def : Thumb2DSPMulPat<(add rGPR:$Ra, (mul (sext_top_16 rGPR:$Rn), 3206 sext_16_node:$Rm)), 3207 (t2SMLATB rGPR:$Rn, rGPR:$Rm, rGPR:$Ra)>; 3208 3209def : Thumb2DSPPat<(int_arm_smlabb GPR:$a, GPR:$b, GPR:$acc), 3210 (t2SMLABB GPR:$a, GPR:$b, GPR:$acc)>; 3211def : Thumb2DSPPat<(int_arm_smlabt GPR:$a, GPR:$b, GPR:$acc), 3212 (t2SMLABT GPR:$a, GPR:$b, GPR:$acc)>; 3213def : Thumb2DSPPat<(int_arm_smlatb GPR:$a, GPR:$b, GPR:$acc), 3214 (t2SMLATB GPR:$a, GPR:$b, GPR:$acc)>; 3215def : Thumb2DSPPat<(int_arm_smlatt GPR:$a, GPR:$b, GPR:$acc), 3216 (t2SMLATT GPR:$a, GPR:$b, GPR:$acc)>; 3217def : Thumb2DSPPat<(int_arm_smlawb GPR:$a, GPR:$b, GPR:$acc), 3218 (t2SMLAWB GPR:$a, GPR:$b, GPR:$acc)>; 3219def : Thumb2DSPPat<(int_arm_smlawt GPR:$a, GPR:$b, GPR:$acc), 3220 (t2SMLAWT GPR:$a, GPR:$b, GPR:$acc)>; 3221 3222// Halfword multiple accumulate long: SMLAL<x><y> 3223def t2SMLALBB : T2MlaLong<0b100, 0b1000, "smlalbb">, 3224 Requires<[IsThumb2, HasDSP]>; 3225def t2SMLALBT : T2MlaLong<0b100, 0b1001, "smlalbt">, 3226 Requires<[IsThumb2, HasDSP]>; 3227def t2SMLALTB : T2MlaLong<0b100, 0b1010, "smlaltb">, 3228 Requires<[IsThumb2, HasDSP]>; 3229def t2SMLALTT : T2MlaLong<0b100, 0b1011, "smlaltt">, 3230 Requires<[IsThumb2, HasDSP]>; 3231 3232def : Thumb2DSPPat<(ARMsmlalbb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), 3233 (t2SMLALBB $Rn, $Rm, $RLo, $RHi)>; 3234def : Thumb2DSPPat<(ARMsmlalbt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), 3235 (t2SMLALBT $Rn, $Rm, $RLo, $RHi)>; 3236def : Thumb2DSPPat<(ARMsmlaltb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), 3237 (t2SMLALTB $Rn, $Rm, $RLo, $RHi)>; 3238def : Thumb2DSPPat<(ARMsmlaltt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), 3239 (t2SMLALTT $Rn, $Rm, $RLo, $RHi)>; 3240 3241class T2DualHalfMul<bits<3> op22_20, bits<4> op7_4, string opc, 3242 Intrinsic intrinsic> 3243 : T2ThreeReg_mac<0, op22_20, op7_4, 3244 (outs rGPR:$Rd), 3245 (ins rGPR:$Rn, rGPR:$Rm), 3246 IIC_iMAC32, opc, "\t$Rd, $Rn, $Rm", 3247 [(set rGPR:$Rd, (intrinsic rGPR:$Rn, rGPR:$Rm))]>, 3248 Requires<[IsThumb2, HasDSP]>, 3249 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> { 3250 let Inst{15-12} = 0b1111; 3251} 3252 3253// Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD 3254def t2SMUAD: T2DualHalfMul<0b010, 0b0000, "smuad", int_arm_smuad>; 3255def t2SMUADX: T2DualHalfMul<0b010, 0b0001, "smuadx", int_arm_smuadx>; 3256def t2SMUSD: T2DualHalfMul<0b100, 0b0000, "smusd", int_arm_smusd>; 3257def t2SMUSDX: T2DualHalfMul<0b100, 0b0001, "smusdx", int_arm_smusdx>; 3258 3259class T2DualHalfMulAdd<bits<3> op22_20, bits<4> op7_4, string opc, 3260 Intrinsic intrinsic> 3261 : T2FourReg_mac<0, op22_20, op7_4, 3262 (outs rGPR:$Rd), 3263 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), 3264 IIC_iMAC32, opc, "\t$Rd, $Rn, $Rm, $Ra", 3265 [(set rGPR:$Rd, (intrinsic rGPR:$Rn, rGPR:$Rm, rGPR:$Ra))]>, 3266 Requires<[IsThumb2, HasDSP]>; 3267 3268def t2SMLAD : T2DualHalfMulAdd<0b010, 0b0000, "smlad", int_arm_smlad>; 3269def t2SMLADX : T2DualHalfMulAdd<0b010, 0b0001, "smladx", int_arm_smladx>; 3270def t2SMLSD : T2DualHalfMulAdd<0b100, 0b0000, "smlsd", int_arm_smlsd>; 3271def t2SMLSDX : T2DualHalfMulAdd<0b100, 0b0001, "smlsdx", int_arm_smlsdx>; 3272 3273class T2DualHalfMulAddLong<bits<3> op22_20, bits<4> op7_4, string opc> 3274 : T2FourReg_mac<1, op22_20, op7_4, 3275 (outs rGPR:$Ra, rGPR:$Rd), 3276 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi), 3277 IIC_iMAC64, opc, "\t$Ra, $Rd, $Rn, $Rm", []>, 3278 RegConstraint<"$Ra = $RLo, $Rd = $RHi">, 3279 Requires<[IsThumb2, HasDSP]>, 3280 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>; 3281 3282def t2SMLALD : T2DualHalfMulAddLong<0b100, 0b1100, "smlald">; 3283def t2SMLALDX : T2DualHalfMulAddLong<0b100, 0b1101, "smlaldx">; 3284def t2SMLSLD : T2DualHalfMulAddLong<0b101, 0b1100, "smlsld">; 3285def t2SMLSLDX : T2DualHalfMulAddLong<0b101, 0b1101, "smlsldx">; 3286 3287def : Thumb2DSPPat<(ARMSmlald rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi), 3288 (t2SMLALD rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi)>; 3289def : Thumb2DSPPat<(ARMSmlaldx rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi), 3290 (t2SMLALDX rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi)>; 3291def : Thumb2DSPPat<(ARMSmlsld rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi), 3292 (t2SMLSLD rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi)>; 3293def : Thumb2DSPPat<(ARMSmlsldx rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi), 3294 (t2SMLSLDX rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi)>; 3295 3296//===----------------------------------------------------------------------===// 3297// Division Instructions. 3298// Signed and unsigned division on v7-M 3299// 3300def t2SDIV : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iDIV, 3301 "sdiv", "\t$Rd, $Rn, $Rm", 3302 [(set rGPR:$Rd, (sdiv rGPR:$Rn, rGPR:$Rm))]>, 3303 Requires<[HasDivideInThumb, IsThumb, HasV8MBaseline]>, 3304 Sched<[WriteDIV]> { 3305 let Inst{31-27} = 0b11111; 3306 let Inst{26-21} = 0b011100; 3307 let Inst{20} = 0b1; 3308 let Inst{15-12} = 0b1111; 3309 let Inst{7-4} = 0b1111; 3310} 3311 3312def t2UDIV : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iDIV, 3313 "udiv", "\t$Rd, $Rn, $Rm", 3314 [(set rGPR:$Rd, (udiv rGPR:$Rn, rGPR:$Rm))]>, 3315 Requires<[HasDivideInThumb, IsThumb, HasV8MBaseline]>, 3316 Sched<[WriteDIV]> { 3317 let Inst{31-27} = 0b11111; 3318 let Inst{26-21} = 0b011101; 3319 let Inst{20} = 0b1; 3320 let Inst{15-12} = 0b1111; 3321 let Inst{7-4} = 0b1111; 3322} 3323 3324//===----------------------------------------------------------------------===// 3325// Misc. Arithmetic Instructions. 3326// 3327 3328class T2I_misc<bits<2> op1, bits<2> op2, dag oops, dag iops, 3329 InstrItinClass itin, string opc, string asm, list<dag> pattern> 3330 : T2ThreeReg<oops, iops, itin, opc, asm, pattern> { 3331 let Inst{31-27} = 0b11111; 3332 let Inst{26-22} = 0b01010; 3333 let Inst{21-20} = op1; 3334 let Inst{15-12} = 0b1111; 3335 let Inst{7-6} = 0b10; 3336 let Inst{5-4} = op2; 3337 let Rn{3-0} = Rm; 3338} 3339 3340def t2CLZ : T2I_misc<0b11, 0b00, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr, 3341 "clz", "\t$Rd, $Rm", [(set rGPR:$Rd, (ctlz rGPR:$Rm))]>, 3342 Sched<[WriteALU]>; 3343 3344def t2RBIT : T2I_misc<0b01, 0b10, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr, 3345 "rbit", "\t$Rd, $Rm", 3346 [(set rGPR:$Rd, (bitreverse rGPR:$Rm))]>, 3347 Sched<[WriteALU]>; 3348 3349def t2REV : T2I_misc<0b01, 0b00, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr, 3350 "rev", ".w\t$Rd, $Rm", [(set rGPR:$Rd, (bswap rGPR:$Rm))]>, 3351 Sched<[WriteALU]>; 3352 3353def t2REV16 : T2I_misc<0b01, 0b01, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr, 3354 "rev16", ".w\t$Rd, $Rm", 3355 [(set rGPR:$Rd, (rotr (bswap rGPR:$Rm), (i32 16)))]>, 3356 Sched<[WriteALU]>; 3357 3358def : T2Pat<(srl (bswap top16Zero:$Rn), (i32 16)), 3359 (t2REV16 rGPR:$Rn)>; 3360 3361def t2REVSH : T2I_misc<0b01, 0b11, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr, 3362 "revsh", ".w\t$Rd, $Rm", 3363 [(set rGPR:$Rd, (sra (bswap rGPR:$Rm), (i32 16)))]>, 3364 Sched<[WriteALU]>; 3365 3366def : T2Pat<(or (sra (shl rGPR:$Rm, (i32 24)), (i32 16)), 3367 (and (srl rGPR:$Rm, (i32 8)), 0xFF)), 3368 (t2REVSH rGPR:$Rm)>; 3369 3370def t2PKHBT : T2ThreeReg< 3371 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, pkh_lsl_amt:$sh), 3372 IIC_iBITsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh", 3373 [(set rGPR:$Rd, (or (and rGPR:$Rn, 0xFFFF), 3374 (and (shl rGPR:$Rm, pkh_lsl_amt:$sh), 3375 0xFFFF0000)))]>, 3376 Requires<[HasDSP, IsThumb2]>, 3377 Sched<[WriteALUsi, ReadALU]> { 3378 let Inst{31-27} = 0b11101; 3379 let Inst{26-25} = 0b01; 3380 let Inst{24-20} = 0b01100; 3381 let Inst{5} = 0; // BT form 3382 let Inst{4} = 0; 3383 3384 bits<5> sh; 3385 let Inst{14-12} = sh{4-2}; 3386 let Inst{7-6} = sh{1-0}; 3387} 3388 3389// Alternate cases for PKHBT where identities eliminate some nodes. 3390def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (and rGPR:$src2, 0xFFFF0000)), 3391 (t2PKHBT rGPR:$src1, rGPR:$src2, 0)>, 3392 Requires<[HasDSP, IsThumb2]>; 3393def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (shl rGPR:$src2, imm16_31:$sh)), 3394 (t2PKHBT rGPR:$src1, rGPR:$src2, imm16_31:$sh)>, 3395 Requires<[HasDSP, IsThumb2]>; 3396 3397// Note: Shifts of 1-15 bits will be transformed to srl instead of sra and 3398// will match the pattern below. 3399def t2PKHTB : T2ThreeReg< 3400 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, pkh_asr_amt:$sh), 3401 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh", 3402 [(set rGPR:$Rd, (or (and rGPR:$Rn, 0xFFFF0000), 3403 (and (sra rGPR:$Rm, pkh_asr_amt:$sh), 3404 0xFFFF)))]>, 3405 Requires<[HasDSP, IsThumb2]>, 3406 Sched<[WriteALUsi, ReadALU]> { 3407 let Inst{31-27} = 0b11101; 3408 let Inst{26-25} = 0b01; 3409 let Inst{24-20} = 0b01100; 3410 let Inst{5} = 1; // TB form 3411 let Inst{4} = 0; 3412 3413 bits<5> sh; 3414 let Inst{14-12} = sh{4-2}; 3415 let Inst{7-6} = sh{1-0}; 3416} 3417 3418// Alternate cases for PKHTB where identities eliminate some nodes. Note that 3419// a shift amount of 0 is *not legal* here, it is PKHBT instead. 3420// We also can not replace a srl (17..31) by an arithmetic shift we would use in 3421// pkhtb src1, src2, asr (17..31). 3422def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (srl rGPR:$src2, imm16:$sh)), 3423 (t2PKHTB rGPR:$src1, rGPR:$src2, imm16:$sh)>, 3424 Requires<[HasDSP, IsThumb2]>; 3425def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (sra rGPR:$src2, imm16_31:$sh)), 3426 (t2PKHTB rGPR:$src1, rGPR:$src2, imm16_31:$sh)>, 3427 Requires<[HasDSP, IsThumb2]>; 3428def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), 3429 (and (srl rGPR:$src2, imm1_15:$sh), 0xFFFF)), 3430 (t2PKHTB rGPR:$src1, rGPR:$src2, imm1_15:$sh)>, 3431 Requires<[HasDSP, IsThumb2]>; 3432 3433//===----------------------------------------------------------------------===// 3434// CRC32 Instructions 3435// 3436// Polynomials: 3437// + CRC32{B,H,W} 0x04C11DB7 3438// + CRC32C{B,H,W} 0x1EDC6F41 3439// 3440 3441class T2I_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin> 3442 : T2ThreeRegNoP<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), NoItinerary, 3443 !strconcat("crc32", suffix, "\t$Rd, $Rn, $Rm"), 3444 [(set rGPR:$Rd, (builtin rGPR:$Rn, rGPR:$Rm))]>, 3445 Requires<[IsThumb2, HasCRC]> { 3446 let Inst{31-27} = 0b11111; 3447 let Inst{26-21} = 0b010110; 3448 let Inst{20} = C; 3449 let Inst{15-12} = 0b1111; 3450 let Inst{7-6} = 0b10; 3451 let Inst{5-4} = sz; 3452} 3453 3454def t2CRC32B : T2I_crc32<0, 0b00, "b", int_arm_crc32b>; 3455def t2CRC32CB : T2I_crc32<1, 0b00, "cb", int_arm_crc32cb>; 3456def t2CRC32H : T2I_crc32<0, 0b01, "h", int_arm_crc32h>; 3457def t2CRC32CH : T2I_crc32<1, 0b01, "ch", int_arm_crc32ch>; 3458def t2CRC32W : T2I_crc32<0, 0b10, "w", int_arm_crc32w>; 3459def t2CRC32CW : T2I_crc32<1, 0b10, "cw", int_arm_crc32cw>; 3460 3461//===----------------------------------------------------------------------===// 3462// Comparison Instructions... 3463// 3464defm t2CMP : T2I_cmp_irs<0b1101, "cmp", GPRnopc, 3465 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi, ARMcmp>; 3466 3467def : T2Pat<(ARMcmpZ GPRnopc:$lhs, t2_so_imm:$imm), 3468 (t2CMPri GPRnopc:$lhs, t2_so_imm:$imm)>; 3469def : T2Pat<(ARMcmpZ GPRnopc:$lhs, rGPR:$rhs), 3470 (t2CMPrr GPRnopc:$lhs, rGPR:$rhs)>; 3471def : T2Pat<(ARMcmpZ GPRnopc:$lhs, t2_so_reg_oneuse:$rhs), 3472 (t2CMPrs GPRnopc:$lhs, t2_so_reg_oneuse:$rhs)>; 3473 3474let isCompare = 1, Defs = [CPSR] in { 3475 // shifted imm 3476 def t2CMNri : T2OneRegCmpImm< 3477 (outs), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iCMPi, 3478 "cmn", ".w\t$Rn, $imm", 3479 [(ARMcmn GPRnopc:$Rn, (ineg t2_so_imm:$imm))]>, 3480 Sched<[WriteCMP, ReadALU]> { 3481 let Inst{31-27} = 0b11110; 3482 let Inst{25} = 0; 3483 let Inst{24-21} = 0b1000; 3484 let Inst{20} = 1; // The S bit. 3485 let Inst{15} = 0; 3486 let Inst{11-8} = 0b1111; // Rd 3487 } 3488 // register 3489 def t2CMNzrr : T2TwoRegCmp< 3490 (outs), (ins GPRnopc:$Rn, rGPR:$Rm), IIC_iCMPr, 3491 "cmn", ".w\t$Rn, $Rm", 3492 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))> 3493 GPRnopc:$Rn, rGPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> { 3494 let Inst{31-27} = 0b11101; 3495 let Inst{26-25} = 0b01; 3496 let Inst{24-21} = 0b1000; 3497 let Inst{20} = 1; // The S bit. 3498 let Inst{14-12} = 0b000; // imm3 3499 let Inst{11-8} = 0b1111; // Rd 3500 let Inst{7-6} = 0b00; // imm2 3501 let Inst{5-4} = 0b00; // type 3502 } 3503 // shifted register 3504 def t2CMNzrs : T2OneRegCmpShiftedReg< 3505 (outs), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm), IIC_iCMPsi, 3506 "cmn", ".w\t$Rn, $ShiftedRm", 3507 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))> 3508 GPRnopc:$Rn, t2_so_reg:$ShiftedRm)]>, 3509 Sched<[WriteCMPsi, ReadALU, ReadALU]> { 3510 let Inst{31-27} = 0b11101; 3511 let Inst{26-25} = 0b01; 3512 let Inst{24-21} = 0b1000; 3513 let Inst{20} = 1; // The S bit. 3514 let Inst{11-8} = 0b1111; // Rd 3515 } 3516} 3517 3518// Assembler aliases w/o the ".w" suffix. 3519// No alias here for 'rr' version as not all instantiations of this multiclass 3520// want one (CMP in particular, does not). 3521def : t2InstAlias<"cmn${p} $Rn, $imm", 3522 (t2CMNri GPRnopc:$Rn, t2_so_imm:$imm, pred:$p)>; 3523def : t2InstAlias<"cmn${p} $Rn, $shift", 3524 (t2CMNzrs GPRnopc:$Rn, t2_so_reg:$shift, pred:$p)>; 3525 3526def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm), 3527 (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>; 3528 3529def : T2Pat<(ARMcmpZ GPRnopc:$src, t2_so_imm_neg:$imm), 3530 (t2CMNri GPRnopc:$src, t2_so_imm_neg:$imm)>; 3531 3532defm t2TST : T2I_cmp_irs<0b0000, "tst", rGPR, 3533 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi, 3534 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>>; 3535defm t2TEQ : T2I_cmp_irs<0b0100, "teq", rGPR, 3536 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi, 3537 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>>; 3538 3539// Conditional moves 3540let hasSideEffects = 0 in { 3541 3542let isCommutable = 1, isSelect = 1 in 3543def t2MOVCCr : t2PseudoInst<(outs rGPR:$Rd), 3544 (ins rGPR:$false, rGPR:$Rm, cmovpred:$p), 3545 4, IIC_iCMOVr, 3546 [(set rGPR:$Rd, (ARMcmov rGPR:$false, rGPR:$Rm, 3547 cmovpred:$p))]>, 3548 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>; 3549 3550let isMoveImm = 1 in 3551def t2MOVCCi 3552 : t2PseudoInst<(outs rGPR:$Rd), 3553 (ins rGPR:$false, t2_so_imm:$imm, cmovpred:$p), 3554 4, IIC_iCMOVi, 3555 [(set rGPR:$Rd, (ARMcmov rGPR:$false,t2_so_imm:$imm, 3556 cmovpred:$p))]>, 3557 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>; 3558 3559let isCodeGenOnly = 1 in { 3560let isMoveImm = 1 in 3561def t2MOVCCi16 3562 : t2PseudoInst<(outs rGPR:$Rd), 3563 (ins rGPR:$false, imm0_65535_expr:$imm, cmovpred:$p), 3564 4, IIC_iCMOVi, 3565 [(set rGPR:$Rd, (ARMcmov rGPR:$false, imm0_65535:$imm, 3566 cmovpred:$p))]>, 3567 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>; 3568 3569let isMoveImm = 1 in 3570def t2MVNCCi 3571 : t2PseudoInst<(outs rGPR:$Rd), 3572 (ins rGPR:$false, t2_so_imm:$imm, cmovpred:$p), 3573 4, IIC_iCMOVi, 3574 [(set rGPR:$Rd, 3575 (ARMcmov rGPR:$false, t2_so_imm_not:$imm, 3576 cmovpred:$p))]>, 3577 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>; 3578 3579class MOVCCShPseudo<SDPatternOperator opnode, Operand ty> 3580 : t2PseudoInst<(outs rGPR:$Rd), 3581 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm, cmovpred:$p), 3582 4, IIC_iCMOVsi, 3583 [(set rGPR:$Rd, (ARMcmov rGPR:$false, 3584 (opnode rGPR:$Rm, (i32 ty:$imm)), 3585 cmovpred:$p))]>, 3586 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>; 3587 3588def t2MOVCClsl : MOVCCShPseudo<shl, imm0_31>; 3589def t2MOVCClsr : MOVCCShPseudo<srl, imm_sr>; 3590def t2MOVCCasr : MOVCCShPseudo<sra, imm_sr>; 3591def t2MOVCCror : MOVCCShPseudo<rotr, imm0_31>; 3592 3593let isMoveImm = 1 in 3594def t2MOVCCi32imm 3595 : t2PseudoInst<(outs rGPR:$dst), 3596 (ins rGPR:$false, i32imm:$src, cmovpred:$p), 3597 8, IIC_iCMOVix2, 3598 [(set rGPR:$dst, (ARMcmov rGPR:$false, imm:$src, 3599 cmovpred:$p))]>, 3600 RegConstraint<"$false = $dst">; 3601} // isCodeGenOnly = 1 3602 3603} // hasSideEffects 3604 3605//===----------------------------------------------------------------------===// 3606// Atomic operations intrinsics 3607// 3608 3609// memory barriers protect the atomic sequences 3610let hasSideEffects = 1 in { 3611def t2DMB : T2I<(outs), (ins memb_opt:$opt), NoItinerary, 3612 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>, 3613 Requires<[IsThumb, HasDB]> { 3614 bits<4> opt; 3615 let Inst{31-4} = 0xf3bf8f5; 3616 let Inst{3-0} = opt; 3617} 3618 3619def t2DSB : T2I<(outs), (ins memb_opt:$opt), NoItinerary, 3620 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>, 3621 Requires<[IsThumb, HasDB]> { 3622 bits<4> opt; 3623 let Inst{31-4} = 0xf3bf8f4; 3624 let Inst{3-0} = opt; 3625} 3626 3627def t2ISB : T2I<(outs), (ins instsyncb_opt:$opt), NoItinerary, 3628 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>, 3629 Requires<[IsThumb, HasDB]> { 3630 bits<4> opt; 3631 let Inst{31-4} = 0xf3bf8f6; 3632 let Inst{3-0} = opt; 3633} 3634 3635let hasNoSchedulingInfo = 1 in 3636def t2TSB : T2I<(outs), (ins tsb_opt:$opt), NoItinerary, 3637 "tsb", "\t$opt", []>, Requires<[IsThumb, HasV8_4a]> { 3638 let Inst{31-0} = 0xf3af8012; 3639 let DecoderMethod = "DecodeTSBInstruction"; 3640} 3641} 3642 3643// Armv8.5-A speculation barrier 3644def t2SB : Thumb2XI<(outs), (ins), AddrModeNone, 4, NoItinerary, "sb", "", []>, 3645 Requires<[IsThumb2, HasSB]>, Sched<[]> { 3646 let Inst{31-0} = 0xf3bf8f70; 3647 let Unpredictable = 0x000f2f0f; 3648 let hasSideEffects = 1; 3649} 3650 3651class T2I_ldrex<bits<4> opcod, dag oops, dag iops, AddrMode am, int sz, 3652 InstrItinClass itin, string opc, string asm, string cstr, 3653 list<dag> pattern, bits<4> rt2 = 0b1111> 3654 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> { 3655 let Inst{31-27} = 0b11101; 3656 let Inst{26-20} = 0b0001101; 3657 let Inst{11-8} = rt2; 3658 let Inst{7-4} = opcod; 3659 let Inst{3-0} = 0b1111; 3660 3661 bits<4> addr; 3662 bits<4> Rt; 3663 let Inst{19-16} = addr; 3664 let Inst{15-12} = Rt; 3665} 3666class T2I_strex<bits<4> opcod, dag oops, dag iops, AddrMode am, int sz, 3667 InstrItinClass itin, string opc, string asm, string cstr, 3668 list<dag> pattern, bits<4> rt2 = 0b1111> 3669 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> { 3670 let Inst{31-27} = 0b11101; 3671 let Inst{26-20} = 0b0001100; 3672 let Inst{11-8} = rt2; 3673 let Inst{7-4} = opcod; 3674 3675 bits<4> Rd; 3676 bits<4> addr; 3677 bits<4> Rt; 3678 let Inst{3-0} = Rd; 3679 let Inst{19-16} = addr; 3680 let Inst{15-12} = Rt; 3681} 3682 3683let mayLoad = 1 in { 3684def t2LDREXB : T2I_ldrex<0b0100, (outs rGPR:$Rt), (ins addr_offset_none:$addr), 3685 AddrModeNone, 4, NoItinerary, 3686 "ldrexb", "\t$Rt, $addr", "", 3687 [(set rGPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>, 3688 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteLd]>; 3689def t2LDREXH : T2I_ldrex<0b0101, (outs rGPR:$Rt), (ins addr_offset_none:$addr), 3690 AddrModeNone, 4, NoItinerary, 3691 "ldrexh", "\t$Rt, $addr", "", 3692 [(set rGPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>, 3693 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteLd]>; 3694def t2LDREX : Thumb2I<(outs rGPR:$Rt), (ins t2addrmode_imm0_1020s4:$addr), 3695 AddrModeT2_ldrex, 4, NoItinerary, 3696 "ldrex", "\t$Rt, $addr", "", 3697 [(set rGPR:$Rt, (ldrex_4 t2addrmode_imm0_1020s4:$addr))]>, 3698 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteLd]> { 3699 bits<4> Rt; 3700 bits<12> addr; 3701 let Inst{31-27} = 0b11101; 3702 let Inst{26-20} = 0b0000101; 3703 let Inst{19-16} = addr{11-8}; 3704 let Inst{15-12} = Rt; 3705 let Inst{11-8} = 0b1111; 3706 let Inst{7-0} = addr{7-0}; 3707} 3708let hasExtraDefRegAllocReq = 1 in 3709def t2LDREXD : T2I_ldrex<0b0111, (outs rGPR:$Rt, rGPR:$Rt2), 3710 (ins addr_offset_none:$addr), 3711 AddrModeNone, 4, NoItinerary, 3712 "ldrexd", "\t$Rt, $Rt2, $addr", "", 3713 [], {?, ?, ?, ?}>, 3714 Requires<[IsThumb2, IsNotMClass]>, Sched<[WriteLd]> { 3715 bits<4> Rt2; 3716 let Inst{11-8} = Rt2; 3717} 3718def t2LDAEXB : T2I_ldrex<0b1100, (outs rGPR:$Rt), (ins addr_offset_none:$addr), 3719 AddrModeNone, 4, NoItinerary, 3720 "ldaexb", "\t$Rt, $addr", "", 3721 [(set rGPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>, 3722 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>, Sched<[WriteLd]>; 3723def t2LDAEXH : T2I_ldrex<0b1101, (outs rGPR:$Rt), (ins addr_offset_none:$addr), 3724 AddrModeNone, 4, NoItinerary, 3725 "ldaexh", "\t$Rt, $addr", "", 3726 [(set rGPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>, 3727 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>, Sched<[WriteLd]>; 3728def t2LDAEX : Thumb2I<(outs rGPR:$Rt), (ins addr_offset_none:$addr), 3729 AddrModeNone, 4, NoItinerary, 3730 "ldaex", "\t$Rt, $addr", "", 3731 [(set rGPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>, 3732 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>, Sched<[WriteLd]> { 3733 bits<4> Rt; 3734 bits<4> addr; 3735 let Inst{31-27} = 0b11101; 3736 let Inst{26-20} = 0b0001101; 3737 let Inst{19-16} = addr; 3738 let Inst{15-12} = Rt; 3739 let Inst{11-8} = 0b1111; 3740 let Inst{7-0} = 0b11101111; 3741} 3742let hasExtraDefRegAllocReq = 1 in 3743def t2LDAEXD : T2I_ldrex<0b1111, (outs rGPR:$Rt, rGPR:$Rt2), 3744 (ins addr_offset_none:$addr), 3745 AddrModeNone, 4, NoItinerary, 3746 "ldaexd", "\t$Rt, $Rt2, $addr", "", 3747 [], {?, ?, ?, ?}>, Requires<[IsThumb, 3748 HasAcquireRelease, HasV7Clrex, IsNotMClass]>, Sched<[WriteLd]> { 3749 bits<4> Rt2; 3750 let Inst{11-8} = Rt2; 3751 3752 let Inst{7} = 1; 3753} 3754} 3755 3756let mayStore = 1, Constraints = "@earlyclobber $Rd" in { 3757def t2STREXB : T2I_strex<0b0100, (outs rGPR:$Rd), 3758 (ins rGPR:$Rt, addr_offset_none:$addr), 3759 AddrModeNone, 4, NoItinerary, 3760 "strexb", "\t$Rd, $Rt, $addr", "", 3761 [(set rGPR:$Rd, 3762 (strex_1 rGPR:$Rt, addr_offset_none:$addr))]>, 3763 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteST]>; 3764def t2STREXH : T2I_strex<0b0101, (outs rGPR:$Rd), 3765 (ins rGPR:$Rt, addr_offset_none:$addr), 3766 AddrModeNone, 4, NoItinerary, 3767 "strexh", "\t$Rd, $Rt, $addr", "", 3768 [(set rGPR:$Rd, 3769 (strex_2 rGPR:$Rt, addr_offset_none:$addr))]>, 3770 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteST]>; 3771 3772def t2STREX : Thumb2I<(outs rGPR:$Rd), (ins rGPR:$Rt, 3773 t2addrmode_imm0_1020s4:$addr), 3774 AddrModeT2_ldrex, 4, NoItinerary, 3775 "strex", "\t$Rd, $Rt, $addr", "", 3776 [(set rGPR:$Rd, 3777 (strex_4 rGPR:$Rt, t2addrmode_imm0_1020s4:$addr))]>, 3778 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteST]> { 3779 bits<4> Rd; 3780 bits<4> Rt; 3781 bits<12> addr; 3782 let Inst{31-27} = 0b11101; 3783 let Inst{26-20} = 0b0000100; 3784 let Inst{19-16} = addr{11-8}; 3785 let Inst{15-12} = Rt; 3786 let Inst{11-8} = Rd; 3787 let Inst{7-0} = addr{7-0}; 3788} 3789let hasExtraSrcRegAllocReq = 1 in 3790def t2STREXD : T2I_strex<0b0111, (outs rGPR:$Rd), 3791 (ins rGPR:$Rt, rGPR:$Rt2, addr_offset_none:$addr), 3792 AddrModeNone, 4, NoItinerary, 3793 "strexd", "\t$Rd, $Rt, $Rt2, $addr", "", [], 3794 {?, ?, ?, ?}>, 3795 Requires<[IsThumb2, IsNotMClass]>, Sched<[WriteST]> { 3796 bits<4> Rt2; 3797 let Inst{11-8} = Rt2; 3798} 3799def t2STLEXB : T2I_strex<0b1100, (outs rGPR:$Rd), 3800 (ins rGPR:$Rt, addr_offset_none:$addr), 3801 AddrModeNone, 4, NoItinerary, 3802 "stlexb", "\t$Rd, $Rt, $addr", "", 3803 [(set rGPR:$Rd, 3804 (stlex_1 rGPR:$Rt, addr_offset_none:$addr))]>, 3805 Requires<[IsThumb, HasAcquireRelease, 3806 HasV7Clrex]>, Sched<[WriteST]>; 3807 3808def t2STLEXH : T2I_strex<0b1101, (outs rGPR:$Rd), 3809 (ins rGPR:$Rt, addr_offset_none:$addr), 3810 AddrModeNone, 4, NoItinerary, 3811 "stlexh", "\t$Rd, $Rt, $addr", "", 3812 [(set rGPR:$Rd, 3813 (stlex_2 rGPR:$Rt, addr_offset_none:$addr))]>, 3814 Requires<[IsThumb, HasAcquireRelease, 3815 HasV7Clrex]>, Sched<[WriteST]>; 3816 3817def t2STLEX : Thumb2I<(outs rGPR:$Rd), (ins rGPR:$Rt, 3818 addr_offset_none:$addr), 3819 AddrModeNone, 4, NoItinerary, 3820 "stlex", "\t$Rd, $Rt, $addr", "", 3821 [(set rGPR:$Rd, 3822 (stlex_4 rGPR:$Rt, addr_offset_none:$addr))]>, 3823 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>, 3824 Sched<[WriteST]> { 3825 bits<4> Rd; 3826 bits<4> Rt; 3827 bits<4> addr; 3828 let Inst{31-27} = 0b11101; 3829 let Inst{26-20} = 0b0001100; 3830 let Inst{19-16} = addr; 3831 let Inst{15-12} = Rt; 3832 let Inst{11-4} = 0b11111110; 3833 let Inst{3-0} = Rd; 3834} 3835let hasExtraSrcRegAllocReq = 1 in 3836def t2STLEXD : T2I_strex<0b1111, (outs rGPR:$Rd), 3837 (ins rGPR:$Rt, rGPR:$Rt2, addr_offset_none:$addr), 3838 AddrModeNone, 4, NoItinerary, 3839 "stlexd", "\t$Rd, $Rt, $Rt2, $addr", "", [], 3840 {?, ?, ?, ?}>, Requires<[IsThumb, HasAcquireRelease, 3841 HasV7Clrex, IsNotMClass]>, Sched<[WriteST]> { 3842 bits<4> Rt2; 3843 let Inst{11-8} = Rt2; 3844} 3845} 3846 3847def t2CLREX : T2I<(outs), (ins), NoItinerary, "clrex", "", [(int_arm_clrex)]>, 3848 Requires<[IsThumb, HasV7Clrex]> { 3849 let Inst{31-16} = 0xf3bf; 3850 let Inst{15-14} = 0b10; 3851 let Inst{13} = 0; 3852 let Inst{12} = 0; 3853 let Inst{11-8} = 0b1111; 3854 let Inst{7-4} = 0b0010; 3855 let Inst{3-0} = 0b1111; 3856} 3857 3858def : T2Pat<(and (ldrex_1 addr_offset_none:$addr), 0xff), 3859 (t2LDREXB addr_offset_none:$addr)>, 3860 Requires<[IsThumb, HasV8MBaseline]>; 3861def : T2Pat<(and (ldrex_2 addr_offset_none:$addr), 0xffff), 3862 (t2LDREXH addr_offset_none:$addr)>, 3863 Requires<[IsThumb, HasV8MBaseline]>; 3864def : T2Pat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr), 3865 (t2STREXB GPR:$Rt, addr_offset_none:$addr)>, 3866 Requires<[IsThumb, HasV8MBaseline]>; 3867def : T2Pat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr), 3868 (t2STREXH GPR:$Rt, addr_offset_none:$addr)>, 3869 Requires<[IsThumb, HasV8MBaseline]>; 3870 3871def : T2Pat<(and (ldaex_1 addr_offset_none:$addr), 0xff), 3872 (t2LDAEXB addr_offset_none:$addr)>, 3873 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>; 3874def : T2Pat<(and (ldaex_2 addr_offset_none:$addr), 0xffff), 3875 (t2LDAEXH addr_offset_none:$addr)>, 3876 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>; 3877def : T2Pat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr), 3878 (t2STLEXB GPR:$Rt, addr_offset_none:$addr)>, 3879 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>; 3880def : T2Pat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr), 3881 (t2STLEXH GPR:$Rt, addr_offset_none:$addr)>, 3882 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>; 3883 3884//===----------------------------------------------------------------------===// 3885// SJLJ Exception handling intrinsics 3886// eh_sjlj_setjmp() is an instruction sequence to store the return 3887// address and save #0 in R0 for the non-longjmp case. 3888// Since by its nature we may be coming from some other function to get 3889// here, and we're using the stack frame for the containing function to 3890// save/restore registers, we can't keep anything live in regs across 3891// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon 3892// when we get here from a longjmp(). We force everything out of registers 3893// except for our own input by listing the relevant registers in Defs. By 3894// doing so, we also cause the prologue/epilogue code to actively preserve 3895// all of the callee-saved registers, which is exactly what we want. 3896// $val is a scratch register for our use. 3897// This gets lowered to an instruction sequence of 12 bytes 3898let Defs = 3899 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR, 3900 Q0, Q1, Q2, Q3, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15], 3901 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1, Size = 12, 3902 usesCustomInserter = 1 in { 3903 def t2Int_eh_sjlj_setjmp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val), 3904 AddrModeNone, 0, NoItinerary, "", "", 3905 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>, 3906 Requires<[IsThumb2, HasVFP2]>; 3907} 3908 3909// This gets lowered to an instruction sequence of 12 bytes 3910let Defs = 3911 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ], 3912 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1, Size = 12, 3913 usesCustomInserter = 1 in { 3914 def t2Int_eh_sjlj_setjmp_nofp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val), 3915 AddrModeNone, 0, NoItinerary, "", "", 3916 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>, 3917 Requires<[IsThumb2, NoVFP]>; 3918} 3919 3920 3921//===----------------------------------------------------------------------===// 3922// Control-Flow Instructions 3923// 3924 3925// FIXME: remove when we have a way to marking a MI with these properties. 3926// FIXME: Should pc be an implicit operand like PICADD, etc? 3927let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1, 3928 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in 3929def t2LDMIA_RET: t2PseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, 3930 reglist:$regs, variable_ops), 3931 4, IIC_iLoad_mBr, [], 3932 (t2LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>, 3933 RegConstraint<"$Rn = $wb">; 3934 3935let isBranch = 1, isTerminator = 1, isBarrier = 1 in { 3936let isPredicable = 1 in 3937def t2B : T2I<(outs), (ins thumb_br_target:$target), IIC_Br, 3938 "b", ".w\t$target", 3939 [(br bb:$target)]>, Sched<[WriteBr]>, 3940 Requires<[IsThumb, HasV8MBaseline]> { 3941 let Inst{31-27} = 0b11110; 3942 let Inst{15-14} = 0b10; 3943 let Inst{12} = 1; 3944 3945 bits<24> target; 3946 let Inst{26} = target{23}; 3947 let Inst{13} = target{22}; 3948 let Inst{11} = target{21}; 3949 let Inst{25-16} = target{20-11}; 3950 let Inst{10-0} = target{10-0}; 3951 let DecoderMethod = "DecodeT2BInstruction"; 3952 let AsmMatchConverter = "cvtThumbBranches"; 3953} 3954 3955let Size = 4, isNotDuplicable = 1, isBranch = 1, isTerminator = 1, 3956 isBarrier = 1, isIndirectBranch = 1 in { 3957 3958// available in both v8-M.Baseline and Thumb2 targets 3959def t2BR_JT : t2basePseudoInst<(outs), 3960 (ins GPR:$target, GPR:$index, i32imm:$jt), 3961 0, IIC_Br, 3962 [(ARMbr2jt GPR:$target, GPR:$index, tjumptable:$jt)]>, 3963 Sched<[WriteBr]>; 3964 3965// FIXME: Add a case that can be predicated. 3966def t2TBB_JT : t2PseudoInst<(outs), 3967 (ins GPR:$base, GPR:$index, i32imm:$jt, i32imm:$pclbl), 0, IIC_Br, []>, 3968 Sched<[WriteBr]>; 3969 3970def t2TBH_JT : t2PseudoInst<(outs), 3971 (ins GPR:$base, GPR:$index, i32imm:$jt, i32imm:$pclbl), 0, IIC_Br, []>, 3972 Sched<[WriteBr]>; 3973 3974def t2TBB : T2I<(outs), (ins (addrmode_tbb $Rn, $Rm):$addr), IIC_Br, 3975 "tbb", "\t$addr", []>, Sched<[WriteBrTbl]> { 3976 bits<4> Rn; 3977 bits<4> Rm; 3978 let Inst{31-20} = 0b111010001101; 3979 let Inst{19-16} = Rn; 3980 let Inst{15-5} = 0b11110000000; 3981 let Inst{4} = 0; // B form 3982 let Inst{3-0} = Rm; 3983 3984 let DecoderMethod = "DecodeThumbTableBranch"; 3985} 3986 3987def t2TBH : T2I<(outs), (ins (addrmode_tbh $Rn, $Rm):$addr), IIC_Br, 3988 "tbh", "\t$addr", []>, Sched<[WriteBrTbl]> { 3989 bits<4> Rn; 3990 bits<4> Rm; 3991 let Inst{31-20} = 0b111010001101; 3992 let Inst{19-16} = Rn; 3993 let Inst{15-5} = 0b11110000000; 3994 let Inst{4} = 1; // H form 3995 let Inst{3-0} = Rm; 3996 3997 let DecoderMethod = "DecodeThumbTableBranch"; 3998} 3999} // isNotDuplicable, isIndirectBranch 4000 4001} // isBranch, isTerminator, isBarrier 4002 4003// FIXME: should be able to write a pattern for ARMBrcond, but can't use 4004// a two-value operand where a dag node expects ", "two operands. :( 4005let isBranch = 1, isTerminator = 1 in 4006def t2Bcc : T2I<(outs), (ins brtarget:$target), IIC_Br, 4007 "b", ".w\t$target", 4008 [/*(ARMbrcond bb:$target, imm:$cc)*/]>, Sched<[WriteBr]> { 4009 let Inst{31-27} = 0b11110; 4010 let Inst{15-14} = 0b10; 4011 let Inst{12} = 0; 4012 4013 bits<4> p; 4014 let Inst{25-22} = p; 4015 4016 bits<21> target; 4017 let Inst{26} = target{20}; 4018 let Inst{11} = target{19}; 4019 let Inst{13} = target{18}; 4020 let Inst{21-16} = target{17-12}; 4021 let Inst{10-0} = target{11-1}; 4022 4023 let DecoderMethod = "DecodeThumb2BCCInstruction"; 4024 let AsmMatchConverter = "cvtThumbBranches"; 4025} 4026 4027// Tail calls. The MachO version of thumb tail calls uses a t2 branch, so 4028// it goes here. 4029// Windows SEH unwinding also needs a strict t2 branch for tail calls. 4030let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in { 4031 // IOS version. 4032 let Uses = [SP] in 4033 def tTAILJMPd: tPseudoExpand<(outs), 4034 (ins thumb_br_target:$dst, pred:$p), 4035 4, IIC_Br, [], 4036 (t2B thumb_br_target:$dst, pred:$p)>, 4037 Requires<[IsThumb2]>, Sched<[WriteBr]>; 4038} 4039 4040// IT block 4041let Defs = [ITSTATE] in 4042def t2IT : Thumb2XI<(outs), (ins it_pred:$cc, it_mask:$mask), 4043 AddrModeNone, 2, IIC_iALUx, 4044 "it$mask\t$cc", "", []> { 4045 // 16-bit instruction. 4046 let Inst{31-16} = 0x0000; 4047 let Inst{15-8} = 0b10111111; 4048 4049 bits<4> cc; 4050 bits<4> mask; 4051 let Inst{7-4} = cc; 4052 let Inst{3-0} = mask; 4053 4054 let DecoderMethod = "DecodeIT"; 4055} 4056 4057// Branch and Exchange Jazelle -- for disassembly only 4058// Rm = Inst{19-16} 4059let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in 4060def t2BXJ : T2I<(outs), (ins GPRnopc:$func), NoItinerary, "bxj", "\t$func", []>, 4061 Sched<[WriteBr]>, Requires<[IsThumb2, IsNotMClass]> { 4062 bits<4> func; 4063 let Inst{31-27} = 0b11110; 4064 let Inst{26} = 0; 4065 let Inst{25-20} = 0b111100; 4066 let Inst{19-16} = func; 4067 let Inst{15-0} = 0b1000111100000000; 4068} 4069 4070def : t2InstAlias<"bl${p}.w $func", (tBL pred:$p, thumb_bl_target:$func), 0>; 4071 4072// Compare and branch on zero / non-zero 4073let isBranch = 1, isTerminator = 1 in { 4074 def tCBZ : T1I<(outs), (ins tGPR:$Rn, thumb_cb_target:$target), IIC_Br, 4075 "cbz\t$Rn, $target", []>, 4076 T1Misc<{0,0,?,1,?,?,?}>, 4077 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteBr]> { 4078 // A8.6.27 4079 bits<6> target; 4080 bits<3> Rn; 4081 let Inst{9} = target{5}; 4082 let Inst{7-3} = target{4-0}; 4083 let Inst{2-0} = Rn; 4084 } 4085 4086 def tCBNZ : T1I<(outs), (ins tGPR:$Rn, thumb_cb_target:$target), IIC_Br, 4087 "cbnz\t$Rn, $target", []>, 4088 T1Misc<{1,0,?,1,?,?,?}>, 4089 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteBr]> { 4090 // A8.6.27 4091 bits<6> target; 4092 bits<3> Rn; 4093 let Inst{9} = target{5}; 4094 let Inst{7-3} = target{4-0}; 4095 let Inst{2-0} = Rn; 4096 } 4097} 4098 4099 4100// Change Processor State is a system instruction. 4101// FIXME: Since the asm parser has currently no clean way to handle optional 4102// operands, create 3 versions of the same instruction. Once there's a clean 4103// framework to represent optional operands, change this behavior. 4104class t2CPS<dag iops, string asm_op> : T2XI<(outs), iops, NoItinerary, 4105 !strconcat("cps", asm_op), []>, 4106 Requires<[IsThumb2, IsNotMClass]> { 4107 bits<2> imod; 4108 bits<3> iflags; 4109 bits<5> mode; 4110 bit M; 4111 4112 let Inst{31-11} = 0b111100111010111110000; 4113 let Inst{10-9} = imod; 4114 let Inst{8} = M; 4115 let Inst{7-5} = iflags; 4116 let Inst{4-0} = mode; 4117 let DecoderMethod = "DecodeT2CPSInstruction"; 4118} 4119 4120let M = 1 in 4121 def t2CPS3p : t2CPS<(ins imod_op:$imod, iflags_op:$iflags, i32imm:$mode), 4122 "$imod\t$iflags, $mode">; 4123let mode = 0, M = 0 in 4124 def t2CPS2p : t2CPS<(ins imod_op:$imod, iflags_op:$iflags), 4125 "$imod.w\t$iflags">; 4126let imod = 0, iflags = 0, M = 1 in 4127 def t2CPS1p : t2CPS<(ins imm0_31:$mode), "\t$mode">; 4128 4129def : t2InstAlias<"cps$imod.w $iflags, $mode", 4130 (t2CPS3p imod_op:$imod, iflags_op:$iflags, i32imm:$mode), 0>; 4131def : t2InstAlias<"cps.w $mode", (t2CPS1p imm0_31:$mode), 0>; 4132 4133// A6.3.4 Branches and miscellaneous control 4134// Table A6-14 Change Processor State, and hint instructions 4135def t2HINT : T2I<(outs), (ins imm0_239:$imm), NoItinerary, "hint", ".w\t$imm", 4136 [(int_arm_hint imm0_239:$imm)]> { 4137 bits<8> imm; 4138 let Inst{31-3} = 0b11110011101011111000000000000; 4139 let Inst{7-0} = imm; 4140 4141 let DecoderMethod = "DecodeT2HintSpaceInstruction"; 4142} 4143 4144def : t2InstAlias<"hint$p $imm", (t2HINT imm0_239:$imm, pred:$p), 0>; 4145def : t2InstAlias<"nop$p.w", (t2HINT 0, pred:$p), 1>; 4146def : t2InstAlias<"yield$p.w", (t2HINT 1, pred:$p), 1>; 4147def : t2InstAlias<"wfe$p.w", (t2HINT 2, pred:$p), 1>; 4148def : t2InstAlias<"wfi$p.w", (t2HINT 3, pred:$p), 1>; 4149def : t2InstAlias<"sev$p.w", (t2HINT 4, pred:$p), 1>; 4150def : t2InstAlias<"sevl$p.w", (t2HINT 5, pred:$p), 1> { 4151 let Predicates = [IsThumb2, HasV8]; 4152} 4153def : t2InstAlias<"esb$p.w", (t2HINT 16, pred:$p), 1> { 4154 let Predicates = [IsThumb2, HasRAS]; 4155} 4156def : t2InstAlias<"esb$p", (t2HINT 16, pred:$p), 0> { 4157 let Predicates = [IsThumb2, HasRAS]; 4158} 4159def : t2InstAlias<"csdb$p.w", (t2HINT 20, pred:$p), 0>; 4160def : t2InstAlias<"csdb$p", (t2HINT 20, pred:$p), 1>; 4161 4162def : t2InstAlias<"pacbti$p r12,lr,sp", (t2HINT 13, pred:$p), 1>; 4163def : t2InstAlias<"bti$p", (t2HINT 15, pred:$p), 1>; 4164def : t2InstAlias<"pac$p r12,lr,sp", (t2HINT 29, pred:$p), 1>; 4165def : t2InstAlias<"aut$p r12,lr,sp", (t2HINT 45, pred:$p), 1>; 4166 4167// Clear BHB instruction 4168def : InstAlias<"clrbhb$p", (t2HINT 22, pred:$p), 0>, Requires<[IsThumb2, HasV8]>; 4169def : InstAlias<"clrbhb$p", (t2HINT 22, pred:$p), 1>, Requires<[IsThumb2, HasV8, HasCLRBHB]>; 4170 4171def t2DBG : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "dbg", "\t$opt", 4172 [(int_arm_dbg imm0_15:$opt)]> { 4173 bits<4> opt; 4174 let Inst{31-20} = 0b111100111010; 4175 let Inst{19-16} = 0b1111; 4176 let Inst{15-8} = 0b10000000; 4177 let Inst{7-4} = 0b1111; 4178 let Inst{3-0} = opt; 4179} 4180def : t2InstAlias<"dbg${p}.w $opt", (t2DBG imm0_15:$opt, pred:$p), 0>; 4181 4182// Secure Monitor Call is a system instruction. 4183// Option = Inst{19-16} 4184let isCall = 1, Uses = [SP] in 4185def t2SMC : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt", 4186 []>, Requires<[IsThumb2, HasTrustZone]> { 4187 let Inst{31-27} = 0b11110; 4188 let Inst{26-20} = 0b1111111; 4189 let Inst{15-12} = 0b1000; 4190 4191 bits<4> opt; 4192 let Inst{19-16} = opt; 4193} 4194 4195class T2DCPS<bits<2> opt, string opc> 4196 : T2I<(outs), (ins), NoItinerary, opc, "", []>, Requires<[IsThumb2, HasV8]> { 4197 let Inst{31-27} = 0b11110; 4198 let Inst{26-20} = 0b1111000; 4199 let Inst{19-16} = 0b1111; 4200 let Inst{15-12} = 0b1000; 4201 let Inst{11-2} = 0b0000000000; 4202 let Inst{1-0} = opt; 4203} 4204 4205def t2DCPS1 : T2DCPS<0b01, "dcps1">; 4206def t2DCPS2 : T2DCPS<0b10, "dcps2">; 4207def t2DCPS3 : T2DCPS<0b11, "dcps3">; 4208 4209class T2SRS<bits<2> Op, bit W, dag oops, dag iops, InstrItinClass itin, 4210 string opc, string asm, list<dag> pattern> 4211 : T2I<oops, iops, itin, opc, asm, pattern>, 4212 Requires<[IsThumb2,IsNotMClass]> { 4213 bits<5> mode; 4214 let Inst{31-25} = 0b1110100; 4215 let Inst{24-23} = Op; 4216 let Inst{22} = 0; 4217 let Inst{21} = W; 4218 let Inst{20-16} = 0b01101; 4219 let Inst{15-5} = 0b11000000000; 4220 let Inst{4-0} = mode{4-0}; 4221} 4222 4223// Store Return State is a system instruction. 4224def t2SRSDB_UPD : T2SRS<0b00, 1, (outs), (ins imm0_31:$mode), NoItinerary, 4225 "srsdb", "\tsp!, $mode", []>; 4226def t2SRSDB : T2SRS<0b00, 0, (outs), (ins imm0_31:$mode), NoItinerary, 4227 "srsdb","\tsp, $mode", []>; 4228def t2SRSIA_UPD : T2SRS<0b11, 1, (outs), (ins imm0_31:$mode), NoItinerary, 4229 "srsia","\tsp!, $mode", []>; 4230def t2SRSIA : T2SRS<0b11, 0, (outs), (ins imm0_31:$mode), NoItinerary, 4231 "srsia","\tsp, $mode", []>; 4232 4233 4234def : t2InstAlias<"srsdb${p} $mode", (t2SRSDB imm0_31:$mode, pred:$p)>; 4235def : t2InstAlias<"srsdb${p} $mode!", (t2SRSDB_UPD imm0_31:$mode, pred:$p)>; 4236 4237def : t2InstAlias<"srsia${p} $mode", (t2SRSIA imm0_31:$mode, pred:$p)>; 4238def : t2InstAlias<"srsia${p} $mode!", (t2SRSIA_UPD imm0_31:$mode, pred:$p)>; 4239 4240// Return From Exception is a system instruction. 4241let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in 4242class T2RFE<bits<12> op31_20, dag oops, dag iops, InstrItinClass itin, 4243 string opc, string asm, list<dag> pattern> 4244 : T2I<oops, iops, itin, opc, asm, pattern>, 4245 Requires<[IsThumb2,IsNotMClass]> { 4246 let Inst{31-20} = op31_20{11-0}; 4247 4248 bits<4> Rn; 4249 let Inst{19-16} = Rn; 4250 let Inst{15-0} = 0xc000; 4251} 4252 4253def t2RFEDBW : T2RFE<0b111010000011, 4254 (outs), (ins GPR:$Rn), NoItinerary, "rfedb", "\t$Rn!", 4255 [/* For disassembly only; pattern left blank */]>; 4256def t2RFEDB : T2RFE<0b111010000001, 4257 (outs), (ins GPR:$Rn), NoItinerary, "rfedb", "\t$Rn", 4258 [/* For disassembly only; pattern left blank */]>; 4259def t2RFEIAW : T2RFE<0b111010011011, 4260 (outs), (ins GPR:$Rn), NoItinerary, "rfeia", "\t$Rn!", 4261 [/* For disassembly only; pattern left blank */]>; 4262def t2RFEIA : T2RFE<0b111010011001, 4263 (outs), (ins GPR:$Rn), NoItinerary, "rfeia", "\t$Rn", 4264 [/* For disassembly only; pattern left blank */]>; 4265 4266// B9.3.19 SUBS PC, LR, #imm (Thumb2) system instruction. 4267// Exception return instruction is "subs pc, lr, #imm". 4268let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in 4269def t2SUBS_PC_LR : T2I <(outs), (ins imm0_255:$imm), NoItinerary, 4270 "subs", "\tpc, lr, $imm", 4271 [(ARMintretglue imm0_255:$imm)]>, 4272 Requires<[IsThumb2,IsNotMClass]> { 4273 let Inst{31-8} = 0b111100111101111010001111; 4274 4275 bits<8> imm; 4276 let Inst{7-0} = imm; 4277} 4278 4279// B9.3.19 SUBS PC, LR (Thumb) 4280// In the Thumb instruction set, MOVS{<c>}{<q>} PC, LR is a pseudo-instruction 4281// for SUBS{<c>}{<q>} PC, LR, #0. 4282def : t2InstAlias<"movs${p}\tpc, lr", (t2SUBS_PC_LR 0, pred:$p)>; 4283def : t2InstAlias<"movs${p}.w\tpc, lr", (t2SUBS_PC_LR 0, pred:$p)>; 4284 4285// ERET - Return from exception in Hypervisor mode. 4286// B9.3.3, B9.3.20: ERET is an alias for "SUBS PC, LR, #0" in an implementation that 4287// includes virtualization extensions. 4288def t2ERET : InstAlias<"eret${p}", (t2SUBS_PC_LR 0, pred:$p), 1>, 4289 Requires<[IsThumb2, HasVirtualization]>; 4290 4291// Hypervisor Call is a system instruction. 4292let isCall = 1 in { 4293def t2HVC : T2XI <(outs), (ins imm0_65535:$imm16), IIC_Br, "hvc.w\t$imm16", []>, 4294 Requires<[IsThumb2, HasVirtualization]>, Sched<[WriteBr]> { 4295 bits<16> imm16; 4296 let Inst{31-20} = 0b111101111110; 4297 let Inst{19-16} = imm16{15-12}; 4298 let Inst{15-12} = 0b1000; 4299 let Inst{11-0} = imm16{11-0}; 4300} 4301} 4302 4303// Alias for HVC without the ".w" optional width specifier 4304def : t2InstAlias<"hvc\t$imm16", (t2HVC imm0_65535:$imm16)>; 4305 4306//===----------------------------------------------------------------------===// 4307// Non-Instruction Patterns 4308// 4309 4310// 32-bit immediate using movw + movt. 4311// This is a single pseudo instruction to make it re-materializable. 4312// FIXME: Remove this when we can do generalized remat. 4313let isReMaterializable = 1, isMoveImm = 1, Size = 8 in 4314def t2MOVi32imm : PseudoInst<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVix2, 4315 [(set rGPR:$dst, (i32 imm:$src))]>, 4316 Requires<[IsThumb, UseMovt]>; 4317 4318// Pseudo instruction that combines movw + movt + add pc (if pic). 4319// It also makes it possible to rematerialize the instructions. 4320// FIXME: Remove this when we can do generalized remat and when machine licm 4321// can properly the instructions. 4322let isReMaterializable = 1 in { 4323def t2MOV_ga_pcrel : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr), 4324 IIC_iMOVix2addpc, 4325 [(set rGPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>, 4326 Requires<[IsThumb, HasV8MBaseline, UseMovtInPic]>; 4327 4328} 4329 4330def : T2Pat<(ARMWrapperPIC tglobaltlsaddr :$dst), 4331 (t2MOV_ga_pcrel tglobaltlsaddr:$dst)>, 4332 Requires<[IsThumb2, UseMovtInPic]>; 4333def : T2Pat<(ARMWrapper tglobaltlsaddr:$dst), 4334 (t2MOVi32imm tglobaltlsaddr:$dst)>, 4335 Requires<[IsThumb2, UseMovt]>; 4336 4337// ConstantPool, GlobalAddress, and JumpTable 4338def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>; 4339def : T2Pat<(ARMWrapper texternalsym :$dst), (t2MOVi32imm texternalsym :$dst)>, 4340 Requires<[IsThumb, HasV8MBaseline, UseMovt]>; 4341def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2MOVi32imm tglobaladdr :$dst)>, 4342 Requires<[IsThumb, HasV8MBaseline, UseMovt]>; 4343 4344def : T2Pat<(ARMWrapperJT tjumptable:$dst), (t2LEApcrelJT tjumptable:$dst)>; 4345 4346let hasNoSchedulingInfo = 1 in { 4347def t2LDRLIT_ga_pcrel : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr), 4348 IIC_iLoadiALU, 4349 [(set rGPR:$dst, 4350 (ARMWrapperPIC tglobaladdr:$addr))]>, 4351 Requires<[IsThumb, HasV8MBaseline, DontUseMovtInPic]>; 4352} 4353 4354// TLS globals 4355def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr), 4356 (t2LDRLIT_ga_pcrel tglobaltlsaddr:$addr)>, 4357 Requires<[IsThumb, HasV8MBaseline, DontUseMovtInPic]>; 4358 4359// Pseudo instruction that combines ldr from constpool and add pc. This should 4360// be expanded into two instructions late to allow if-conversion and 4361// scheduling. 4362let canFoldAsLoad = 1, isReMaterializable = 1 in 4363def t2LDRpci_pic : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr, pclabel:$cp), 4364 IIC_iLoadiALU, 4365 [(set rGPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)), 4366 imm:$cp))]>, 4367 Requires<[IsThumb2]>; 4368 4369// Pseudo instruction that combines movs + predicated rsbmi 4370// to implement integer ABS 4371let usesCustomInserter = 1, Defs = [CPSR], hasNoSchedulingInfo = 1 in { 4372def t2ABS : PseudoInst<(outs rGPR:$dst), (ins rGPR:$src), 4373 NoItinerary, []>, Requires<[IsThumb2]>; 4374} 4375 4376//===----------------------------------------------------------------------===// 4377// Coprocessor load/store -- for disassembly only 4378// 4379class T2CI<bits<4> op31_28, dag oops, dag iops, string opc, string asm, 4380 list<dag> pattern, AddrMode am = AddrModeNone> 4381 : T2I<oops, iops, NoItinerary, opc, asm, pattern, am> { 4382 let Inst{31-28} = op31_28; 4383 let Inst{27-25} = 0b110; 4384} 4385 4386multiclass t2LdStCop<bits<4> op31_28, bit load, bit Dbit, string asm, list<dag> pattern> { 4387 def _OFFSET : T2CI<op31_28, 4388 (outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr), 4389 asm, "\t$cop, $CRd, $addr", pattern, AddrMode5> { 4390 bits<13> addr; 4391 bits<4> cop; 4392 bits<4> CRd; 4393 let Inst{24} = 1; // P = 1 4394 let Inst{23} = addr{8}; 4395 let Inst{22} = Dbit; 4396 let Inst{21} = 0; // W = 0 4397 let Inst{20} = load; 4398 let Inst{19-16} = addr{12-9}; 4399 let Inst{15-12} = CRd; 4400 let Inst{11-8} = cop; 4401 let Inst{7-0} = addr{7-0}; 4402 let DecoderMethod = "DecodeCopMemInstruction"; 4403 } 4404 def _PRE : T2CI<op31_28, 4405 (outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr), 4406 asm, "\t$cop, $CRd, $addr!", []> { 4407 bits<13> addr; 4408 bits<4> cop; 4409 bits<4> CRd; 4410 let Inst{24} = 1; // P = 1 4411 let Inst{23} = addr{8}; 4412 let Inst{22} = Dbit; 4413 let Inst{21} = 1; // W = 1 4414 let Inst{20} = load; 4415 let Inst{19-16} = addr{12-9}; 4416 let Inst{15-12} = CRd; 4417 let Inst{11-8} = cop; 4418 let Inst{7-0} = addr{7-0}; 4419 let DecoderMethod = "DecodeCopMemInstruction"; 4420 } 4421 def _POST: T2CI<op31_28, 4422 (outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr, 4423 postidx_imm8s4:$offset), 4424 asm, "\t$cop, $CRd, $addr, $offset", []> { 4425 bits<9> offset; 4426 bits<4> addr; 4427 bits<4> cop; 4428 bits<4> CRd; 4429 let Inst{24} = 0; // P = 0 4430 let Inst{23} = offset{8}; 4431 let Inst{22} = Dbit; 4432 let Inst{21} = 1; // W = 1 4433 let Inst{20} = load; 4434 let Inst{19-16} = addr; 4435 let Inst{15-12} = CRd; 4436 let Inst{11-8} = cop; 4437 let Inst{7-0} = offset{7-0}; 4438 let DecoderMethod = "DecodeCopMemInstruction"; 4439 } 4440 def _OPTION : T2CI<op31_28, (outs), 4441 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr, 4442 coproc_option_imm:$option), 4443 asm, "\t$cop, $CRd, $addr, $option", []> { 4444 bits<8> option; 4445 bits<4> addr; 4446 bits<4> cop; 4447 bits<4> CRd; 4448 let Inst{24} = 0; // P = 0 4449 let Inst{23} = 1; // U = 1 4450 let Inst{22} = Dbit; 4451 let Inst{21} = 0; // W = 0 4452 let Inst{20} = load; 4453 let Inst{19-16} = addr; 4454 let Inst{15-12} = CRd; 4455 let Inst{11-8} = cop; 4456 let Inst{7-0} = option; 4457 let DecoderMethod = "DecodeCopMemInstruction"; 4458 } 4459} 4460 4461let DecoderNamespace = "Thumb2CoProc" in { 4462defm t2LDC : t2LdStCop<0b1110, 1, 0, "ldc", [(int_arm_ldc timm:$cop, timm:$CRd, addrmode5:$addr)]>; 4463defm t2LDCL : t2LdStCop<0b1110, 1, 1, "ldcl", [(int_arm_ldcl timm:$cop, timm:$CRd, addrmode5:$addr)]>; 4464defm t2LDC2 : t2LdStCop<0b1111, 1, 0, "ldc2", [(int_arm_ldc2 timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[PreV8,IsThumb2]>; 4465defm t2LDC2L : t2LdStCop<0b1111, 1, 1, "ldc2l", [(int_arm_ldc2l timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[PreV8,IsThumb2]>; 4466 4467defm t2STC : t2LdStCop<0b1110, 0, 0, "stc", [(int_arm_stc timm:$cop, timm:$CRd, addrmode5:$addr)]>; 4468defm t2STCL : t2LdStCop<0b1110, 0, 1, "stcl", [(int_arm_stcl timm:$cop, timm:$CRd, addrmode5:$addr)]>; 4469defm t2STC2 : t2LdStCop<0b1111, 0, 0, "stc2", [(int_arm_stc2 timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[PreV8,IsThumb2]>; 4470defm t2STC2L : t2LdStCop<0b1111, 0, 1, "stc2l", [(int_arm_stc2l timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[PreV8,IsThumb2]>; 4471} 4472 4473 4474//===----------------------------------------------------------------------===// 4475// Move between special register and ARM core register -- for disassembly only 4476// 4477// Move to ARM core register from Special Register 4478 4479// A/R class MRS. 4480// 4481// A/R class can only move from CPSR or SPSR. 4482def t2MRS_AR : T2I<(outs GPR:$Rd), (ins), NoItinerary, "mrs", "\t$Rd, apsr", 4483 []>, Requires<[IsThumb2,IsNotMClass]> { 4484 bits<4> Rd; 4485 let Inst{31-12} = 0b11110011111011111000; 4486 let Inst{11-8} = Rd; 4487 let Inst{7-0} = 0b00000000; 4488} 4489 4490def : t2InstAlias<"mrs${p} $Rd, cpsr", (t2MRS_AR GPR:$Rd, pred:$p)>; 4491 4492def t2MRSsys_AR: T2I<(outs GPR:$Rd), (ins), NoItinerary, "mrs", "\t$Rd, spsr", 4493 []>, Requires<[IsThumb2,IsNotMClass]> { 4494 bits<4> Rd; 4495 let Inst{31-12} = 0b11110011111111111000; 4496 let Inst{11-8} = Rd; 4497 let Inst{7-0} = 0b00000000; 4498} 4499 4500def t2MRSbanked : T2I<(outs rGPR:$Rd), (ins banked_reg:$banked), 4501 NoItinerary, "mrs", "\t$Rd, $banked", []>, 4502 Requires<[IsThumb, HasVirtualization]> { 4503 bits<6> banked; 4504 bits<4> Rd; 4505 4506 let Inst{31-21} = 0b11110011111; 4507 let Inst{20} = banked{5}; // R bit 4508 let Inst{19-16} = banked{3-0}; 4509 let Inst{15-12} = 0b1000; 4510 let Inst{11-8} = Rd; 4511 let Inst{7-5} = 0b001; 4512 let Inst{4} = banked{4}; 4513 let Inst{3-0} = 0b0000; 4514} 4515 4516 4517// M class MRS. 4518// 4519// This MRS has a mask field in bits 7-0 and can take more values than 4520// the A/R class (a full msr_mask). 4521def t2MRS_M : T2I<(outs rGPR:$Rd), (ins msr_mask:$SYSm), NoItinerary, 4522 "mrs", "\t$Rd, $SYSm", []>, 4523 Requires<[IsThumb,IsMClass]> { 4524 bits<4> Rd; 4525 bits<8> SYSm; 4526 let Inst{31-12} = 0b11110011111011111000; 4527 let Inst{11-8} = Rd; 4528 let Inst{7-0} = SYSm; 4529 4530 let Unpredictable{20-16} = 0b11111; 4531 let Unpredictable{13} = 0b1; 4532} 4533 4534 4535// Move from ARM core register to Special Register 4536// 4537// A/R class MSR. 4538// 4539// No need to have both system and application versions, the encodings are the 4540// same and the assembly parser has no way to distinguish between them. The mask 4541// operand contains the special register (R Bit) in bit 4 and bits 3-0 contains 4542// the mask with the fields to be accessed in the special register. 4543let Defs = [CPSR] in 4544def t2MSR_AR : T2I<(outs), (ins msr_mask:$mask, rGPR:$Rn), 4545 NoItinerary, "msr", "\t$mask, $Rn", []>, 4546 Requires<[IsThumb2,IsNotMClass]> { 4547 bits<5> mask; 4548 bits<4> Rn; 4549 let Inst{31-21} = 0b11110011100; 4550 let Inst{20} = mask{4}; // R Bit 4551 let Inst{19-16} = Rn; 4552 let Inst{15-12} = 0b1000; 4553 let Inst{11-8} = mask{3-0}; 4554 let Inst{7-0} = 0; 4555} 4556 4557// However, the MSR (banked register) system instruction (ARMv7VE) *does* have a 4558// separate encoding (distinguished by bit 5. 4559def t2MSRbanked : T2I<(outs), (ins banked_reg:$banked, rGPR:$Rn), 4560 NoItinerary, "msr", "\t$banked, $Rn", []>, 4561 Requires<[IsThumb, HasVirtualization]> { 4562 bits<6> banked; 4563 bits<4> Rn; 4564 4565 let Inst{31-21} = 0b11110011100; 4566 let Inst{20} = banked{5}; // R bit 4567 let Inst{19-16} = Rn; 4568 let Inst{15-12} = 0b1000; 4569 let Inst{11-8} = banked{3-0}; 4570 let Inst{7-5} = 0b001; 4571 let Inst{4} = banked{4}; 4572 let Inst{3-0} = 0b0000; 4573} 4574 4575 4576// M class MSR. 4577// 4578// Move from ARM core register to Special Register 4579let Defs = [CPSR] in 4580def t2MSR_M : T2I<(outs), (ins msr_mask:$SYSm, rGPR:$Rn), 4581 NoItinerary, "msr", "\t$SYSm, $Rn", []>, 4582 Requires<[IsThumb,IsMClass]> { 4583 bits<12> SYSm; 4584 bits<4> Rn; 4585 let Inst{31-21} = 0b11110011100; 4586 let Inst{20} = 0b0; 4587 let Inst{19-16} = Rn; 4588 let Inst{15-12} = 0b1000; 4589 let Inst{11-10} = SYSm{11-10}; 4590 let Inst{9-8} = 0b00; 4591 let Inst{7-0} = SYSm{7-0}; 4592 4593 let Unpredictable{20} = 0b1; 4594 let Unpredictable{13} = 0b1; 4595 let Unpredictable{9-8} = 0b11; 4596} 4597 4598 4599//===----------------------------------------------------------------------===// 4600// Move between coprocessor and ARM core register 4601// 4602 4603class t2MovRCopro<bits<4> Op, string opc, bit direction, dag oops, dag iops, 4604 list<dag> pattern> 4605 : T2Cop<Op, oops, iops, opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", 4606 pattern> { 4607 let Inst{27-24} = 0b1110; 4608 let Inst{20} = direction; 4609 let Inst{4} = 1; 4610 4611 bits<4> Rt; 4612 bits<4> cop; 4613 bits<3> opc1; 4614 bits<3> opc2; 4615 bits<4> CRm; 4616 bits<4> CRn; 4617 4618 let Inst{15-12} = Rt; 4619 let Inst{11-8} = cop; 4620 let Inst{23-21} = opc1; 4621 let Inst{7-5} = opc2; 4622 let Inst{3-0} = CRm; 4623 let Inst{19-16} = CRn; 4624 4625 let DecoderNamespace = "Thumb2CoProc"; 4626} 4627 4628class t2MovRRCopro<bits<4> Op, string opc, bit direction, dag oops, dag iops, 4629 list<dag> pattern = []> 4630 : T2Cop<Op, oops, iops, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> { 4631 let Inst{27-24} = 0b1100; 4632 let Inst{23-21} = 0b010; 4633 let Inst{20} = direction; 4634 4635 bits<4> Rt; 4636 bits<4> Rt2; 4637 bits<4> cop; 4638 bits<4> opc1; 4639 bits<4> CRm; 4640 4641 let Inst{15-12} = Rt; 4642 let Inst{19-16} = Rt2; 4643 let Inst{11-8} = cop; 4644 let Inst{7-4} = opc1; 4645 let Inst{3-0} = CRm; 4646 4647 let DecoderNamespace = "Thumb2CoProc"; 4648} 4649 4650/* from ARM core register to coprocessor */ 4651def t2MCR : t2MovRCopro<0b1110, "mcr", 0, 4652 (outs), 4653 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn, 4654 c_imm:$CRm, imm0_7:$opc2), 4655 [(int_arm_mcr timm:$cop, timm:$opc1, GPR:$Rt, timm:$CRn, 4656 timm:$CRm, timm:$opc2)]>, 4657 ComplexDeprecationPredicate<"MCR">; 4658def : t2InstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm", 4659 (t2MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn, 4660 c_imm:$CRm, 0, pred:$p)>; 4661def t2MCR2 : t2MovRCopro<0b1111, "mcr2", 0, 4662 (outs), (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn, 4663 c_imm:$CRm, imm0_7:$opc2), 4664 [(int_arm_mcr2 timm:$cop, timm:$opc1, GPR:$Rt, timm:$CRn, 4665 timm:$CRm, timm:$opc2)]> { 4666 let Predicates = [IsThumb2, PreV8]; 4667} 4668def : t2InstAlias<"mcr2${p} $cop, $opc1, $Rt, $CRn, $CRm", 4669 (t2MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn, 4670 c_imm:$CRm, 0, pred:$p)>; 4671 4672/* from coprocessor to ARM core register */ 4673def t2MRC : t2MovRCopro<0b1110, "mrc", 1, 4674 (outs GPRwithAPSR:$Rt), (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, 4675 c_imm:$CRm, imm0_7:$opc2), []>; 4676def : t2InstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm", 4677 (t2MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, 4678 c_imm:$CRm, 0, pred:$p)>; 4679 4680def t2MRC2 : t2MovRCopro<0b1111, "mrc2", 1, 4681 (outs GPRwithAPSR:$Rt), (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, 4682 c_imm:$CRm, imm0_7:$opc2), []> { 4683 let Predicates = [IsThumb2, PreV8]; 4684} 4685def : t2InstAlias<"mrc2${p} $cop, $opc1, $Rt, $CRn, $CRm", 4686 (t2MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, 4687 c_imm:$CRm, 0, pred:$p)>; 4688 4689def : T2v6Pat<(int_arm_mrc timm:$cop, timm:$opc1, timm:$CRn, timm:$CRm, timm:$opc2), 4690 (t2MRC p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2)>; 4691 4692def : T2v6Pat<(int_arm_mrc2 timm:$cop, timm:$opc1, timm:$CRn, timm:$CRm, timm:$opc2), 4693 (t2MRC2 p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2)>; 4694 4695 4696/* from ARM core register to coprocessor */ 4697def t2MCRR : t2MovRRCopro<0b1110, "mcrr", 0, (outs), 4698 (ins p_imm:$cop, imm0_15:$opc1, GPR:$Rt, GPR:$Rt2, 4699 c_imm:$CRm), 4700 [(int_arm_mcrr timm:$cop, timm:$opc1, GPR:$Rt, GPR:$Rt2, 4701 timm:$CRm)]>; 4702def t2MCRR2 : t2MovRRCopro<0b1111, "mcrr2", 0, (outs), 4703 (ins p_imm:$cop, imm0_15:$opc1, GPR:$Rt, GPR:$Rt2, 4704 c_imm:$CRm), 4705 [(int_arm_mcrr2 timm:$cop, timm:$opc1, GPR:$Rt, 4706 GPR:$Rt2, timm:$CRm)]> { 4707 let Predicates = [IsThumb2, PreV8]; 4708} 4709 4710/* from coprocessor to ARM core register */ 4711def t2MRRC : t2MovRRCopro<0b1110, "mrrc", 1, (outs GPR:$Rt, GPR:$Rt2), 4712 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm)>; 4713 4714def t2MRRC2 : t2MovRRCopro<0b1111, "mrrc2", 1, (outs GPR:$Rt, GPR:$Rt2), 4715 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm)> { 4716 let Predicates = [IsThumb2, PreV8]; 4717} 4718 4719//===----------------------------------------------------------------------===// 4720// Other Coprocessor Instructions. 4721// 4722 4723def t2CDP : T2Cop<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1, 4724 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2), 4725 "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2", 4726 [(int_arm_cdp timm:$cop, timm:$opc1, timm:$CRd, timm:$CRn, 4727 timm:$CRm, timm:$opc2)]> { 4728 let Inst{27-24} = 0b1110; 4729 4730 bits<4> opc1; 4731 bits<4> CRn; 4732 bits<4> CRd; 4733 bits<4> cop; 4734 bits<3> opc2; 4735 bits<4> CRm; 4736 4737 let Inst{3-0} = CRm; 4738 let Inst{4} = 0; 4739 let Inst{7-5} = opc2; 4740 let Inst{11-8} = cop; 4741 let Inst{15-12} = CRd; 4742 let Inst{19-16} = CRn; 4743 let Inst{23-20} = opc1; 4744 4745 let Predicates = [IsThumb2, PreV8]; 4746 let DecoderNamespace = "Thumb2CoProc"; 4747} 4748 4749def t2CDP2 : T2Cop<0b1111, (outs), (ins p_imm:$cop, imm0_15:$opc1, 4750 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2), 4751 "cdp2", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2", 4752 [(int_arm_cdp2 timm:$cop, timm:$opc1, timm:$CRd, timm:$CRn, 4753 timm:$CRm, timm:$opc2)]> { 4754 let Inst{27-24} = 0b1110; 4755 4756 bits<4> opc1; 4757 bits<4> CRn; 4758 bits<4> CRd; 4759 bits<4> cop; 4760 bits<3> opc2; 4761 bits<4> CRm; 4762 4763 let Inst{3-0} = CRm; 4764 let Inst{4} = 0; 4765 let Inst{7-5} = opc2; 4766 let Inst{11-8} = cop; 4767 let Inst{15-12} = CRd; 4768 let Inst{19-16} = CRn; 4769 let Inst{23-20} = opc1; 4770 4771 let Predicates = [IsThumb2, PreV8]; 4772 let DecoderNamespace = "Thumb2CoProc"; 4773} 4774 4775 4776// Reading thread pointer from coprocessor register 4777def : T2Pat<(ARMthread_pointer), (t2MRC 15, 0, 13, 0, 2)>, 4778 Requires<[IsThumb2, IsReadTPTPIDRURW]>; 4779def : T2Pat<(ARMthread_pointer), (t2MRC 15, 0, 13, 0, 3)>, 4780 Requires<[IsThumb2, IsReadTPTPIDRURO]>; 4781def : T2Pat<(ARMthread_pointer), (t2MRC 15, 0, 13, 0, 4)>, 4782 Requires<[IsThumb2, IsReadTPTPIDRPRW]>; 4783 4784//===----------------------------------------------------------------------===// 4785// ARMv8.1 Privilege Access Never extension 4786// 4787// SETPAN #imm1 4788 4789def t2SETPAN : T1I<(outs), (ins imm0_1:$imm), NoItinerary, "setpan\t$imm", []>, 4790 T1Misc<0b0110000>, Requires<[IsThumb2, HasV8, HasV8_1a]> { 4791 bits<1> imm; 4792 4793 let Inst{4} = 0b1; 4794 let Inst{3} = imm; 4795 let Inst{2-0} = 0b000; 4796 4797 let Unpredictable{4} = 0b1; 4798 let Unpredictable{2-0} = 0b111; 4799} 4800 4801//===----------------------------------------------------------------------===// 4802// ARMv8-M Security Extensions instructions 4803// 4804 4805let hasSideEffects = 1 in 4806def t2SG : T2I<(outs), (ins), NoItinerary, "sg", "", []>, 4807 Requires<[Has8MSecExt]> { 4808 let Inst = 0xe97fe97f; 4809} 4810 4811class T2TT<bits<2> at, string asm, list<dag> pattern> 4812 : T2I<(outs rGPR:$Rt), (ins GPRnopc:$Rn), NoItinerary, asm, "\t$Rt, $Rn", 4813 pattern> { 4814 bits<4> Rn; 4815 bits<4> Rt; 4816 4817 let Inst{31-20} = 0b111010000100; 4818 let Inst{19-16} = Rn; 4819 let Inst{15-12} = 0b1111; 4820 let Inst{11-8} = Rt; 4821 let Inst{7-6} = at; 4822 let Inst{5-0} = 0b000000; 4823 4824 let Unpredictable{5-0} = 0b111111; 4825} 4826 4827def t2TT : T2TT<0b00, "tt", 4828 [(set rGPR:$Rt, (int_arm_cmse_tt GPRnopc:$Rn))]>, 4829 Requires<[IsThumb, Has8MSecExt]>; 4830def t2TTT : T2TT<0b01, "ttt", 4831 [(set rGPR:$Rt, (int_arm_cmse_ttt GPRnopc:$Rn))]>, 4832 Requires<[IsThumb, Has8MSecExt]>; 4833def t2TTA : T2TT<0b10, "tta", 4834 [(set rGPR:$Rt, (int_arm_cmse_tta GPRnopc:$Rn))]>, 4835 Requires<[IsThumb, Has8MSecExt]>; 4836def t2TTAT : T2TT<0b11, "ttat", 4837 [(set rGPR:$Rt, (int_arm_cmse_ttat GPRnopc:$Rn))]>, 4838 Requires<[IsThumb, Has8MSecExt]>; 4839 4840//===----------------------------------------------------------------------===// 4841// Non-Instruction Patterns 4842// 4843 4844// SXT/UXT with no rotate 4845let AddedComplexity = 16 in { 4846def : T2Pat<(and rGPR:$Rm, 0x000000FF), (t2UXTB rGPR:$Rm, 0)>, 4847 Requires<[IsThumb2]>; 4848def : T2Pat<(and rGPR:$Rm, 0x0000FFFF), (t2UXTH rGPR:$Rm, 0)>, 4849 Requires<[IsThumb2]>; 4850def : T2Pat<(and rGPR:$Rm, 0x00FF00FF), (t2UXTB16 rGPR:$Rm, 0)>, 4851 Requires<[HasDSP, IsThumb2]>; 4852def : T2Pat<(add rGPR:$Rn, (and rGPR:$Rm, 0x00FF)), 4853 (t2UXTAB rGPR:$Rn, rGPR:$Rm, 0)>, 4854 Requires<[HasDSP, IsThumb2]>; 4855def : T2Pat<(add rGPR:$Rn, (and rGPR:$Rm, 0xFFFF)), 4856 (t2UXTAH rGPR:$Rn, rGPR:$Rm, 0)>, 4857 Requires<[HasDSP, IsThumb2]>; 4858} 4859 4860def : T2Pat<(sext_inreg rGPR:$Src, i8), (t2SXTB rGPR:$Src, 0)>, 4861 Requires<[IsThumb2]>; 4862def : T2Pat<(sext_inreg rGPR:$Src, i16), (t2SXTH rGPR:$Src, 0)>, 4863 Requires<[IsThumb2]>; 4864def : T2Pat<(add rGPR:$Rn, (sext_inreg rGPR:$Rm, i8)), 4865 (t2SXTAB rGPR:$Rn, rGPR:$Rm, 0)>, 4866 Requires<[HasDSP, IsThumb2]>; 4867def : T2Pat<(add rGPR:$Rn, (sext_inreg rGPR:$Rm, i16)), 4868 (t2SXTAH rGPR:$Rn, rGPR:$Rm, 0)>, 4869 Requires<[HasDSP, IsThumb2]>; 4870 4871// Atomic load/store patterns 4872def : T2Pat<(atomic_load_8 t2addrmode_imm12:$addr), 4873 (t2LDRBi12 t2addrmode_imm12:$addr)>; 4874def : T2Pat<(atomic_load_8 t2addrmode_negimm8:$addr), 4875 (t2LDRBi8 t2addrmode_negimm8:$addr)>; 4876def : T2Pat<(atomic_load_8 t2addrmode_so_reg:$addr), 4877 (t2LDRBs t2addrmode_so_reg:$addr)>; 4878def : T2Pat<(atomic_load_16 t2addrmode_imm12:$addr), 4879 (t2LDRHi12 t2addrmode_imm12:$addr)>; 4880def : T2Pat<(atomic_load_16 t2addrmode_negimm8:$addr), 4881 (t2LDRHi8 t2addrmode_negimm8:$addr)>; 4882def : T2Pat<(atomic_load_16 t2addrmode_so_reg:$addr), 4883 (t2LDRHs t2addrmode_so_reg:$addr)>; 4884def : T2Pat<(atomic_load_32 t2addrmode_imm12:$addr), 4885 (t2LDRi12 t2addrmode_imm12:$addr)>; 4886def : T2Pat<(atomic_load_32 t2addrmode_negimm8:$addr), 4887 (t2LDRi8 t2addrmode_negimm8:$addr)>; 4888def : T2Pat<(atomic_load_32 t2addrmode_so_reg:$addr), 4889 (t2LDRs t2addrmode_so_reg:$addr)>; 4890def : T2Pat<(atomic_store_8 GPR:$val, t2addrmode_imm12:$addr), 4891 (t2STRBi12 GPR:$val, t2addrmode_imm12:$addr)>; 4892def : T2Pat<(atomic_store_8 GPR:$val, t2addrmode_negimm8:$addr), 4893 (t2STRBi8 GPR:$val, t2addrmode_negimm8:$addr)>; 4894def : T2Pat<(atomic_store_8 GPR:$val, t2addrmode_so_reg:$addr), 4895 (t2STRBs GPR:$val, t2addrmode_so_reg:$addr)>; 4896def : T2Pat<(atomic_store_16 GPR:$val, t2addrmode_imm12:$addr), 4897 (t2STRHi12 GPR:$val, t2addrmode_imm12:$addr)>; 4898def : T2Pat<(atomic_store_16 GPR:$val, t2addrmode_negimm8:$addr), 4899 (t2STRHi8 GPR:$val, t2addrmode_negimm8:$addr)>; 4900def : T2Pat<(atomic_store_16 GPR:$val, t2addrmode_so_reg:$addr), 4901 (t2STRHs GPR:$val, t2addrmode_so_reg:$addr)>; 4902def : T2Pat<(atomic_store_32 GPR:$val,t2addrmode_imm12:$addr), 4903 (t2STRi12 GPR:$val, t2addrmode_imm12:$addr)>; 4904def : T2Pat<(atomic_store_32 GPR:$val, t2addrmode_negimm8:$addr), 4905 (t2STRi8 GPR:$val, t2addrmode_negimm8:$addr)>; 4906def : T2Pat<(atomic_store_32 GPR:$val, t2addrmode_so_reg:$addr), 4907 (t2STRs GPR:$val, t2addrmode_so_reg:$addr)>; 4908 4909let AddedComplexity = 8, Predicates = [IsThumb, HasAcquireRelease, HasV7Clrex] in { 4910 def : Pat<(atomic_load_acquire_8 addr_offset_none:$addr), (t2LDAB addr_offset_none:$addr)>; 4911 def : Pat<(atomic_load_acquire_16 addr_offset_none:$addr), (t2LDAH addr_offset_none:$addr)>; 4912 def : Pat<(atomic_load_acquire_32 addr_offset_none:$addr), (t2LDA addr_offset_none:$addr)>; 4913 def : Pat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (t2STLB GPR:$val, addr_offset_none:$addr)>; 4914 def : Pat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (t2STLH GPR:$val, addr_offset_none:$addr)>; 4915 def : Pat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (t2STL GPR:$val, addr_offset_none:$addr)>; 4916} 4917 4918 4919//===----------------------------------------------------------------------===// 4920// Assembler aliases 4921// 4922 4923// Aliases for ADC without the ".w" optional width specifier. 4924def : t2InstAlias<"adc${s}${p} $Rd, $Rn, $Rm", 4925 (t2ADCrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>; 4926def : t2InstAlias<"adc${s}${p} $Rd, $Rn, $ShiftedRm", 4927 (t2ADCrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm, 4928 pred:$p, cc_out:$s)>; 4929def : t2InstAlias<"adc${s}${p} $Rdn, $Rm", 4930 (t2ADCrr rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>; 4931def : t2InstAlias<"adc${s}${p} $Rdn, $ShiftedRm", 4932 (t2ADCrs rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$ShiftedRm, 4933 pred:$p, cc_out:$s)>; 4934 4935// Aliases for SBC without the ".w" optional width specifier. 4936def : t2InstAlias<"sbc${s}${p} $Rd, $Rn, $Rm", 4937 (t2SBCrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>; 4938def : t2InstAlias<"sbc${s}${p} $Rd, $Rn, $ShiftedRm", 4939 (t2SBCrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm, 4940 pred:$p, cc_out:$s)>; 4941 4942// Aliases for ADD without the ".w" optional width specifier. 4943def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm", 4944 (t2ADDri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, 4945 cc_out:$s)>; 4946def : t2InstAlias<"add${p} $Rd, $Rn, $imm", 4947 (t2ADDri12 rGPR:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>; 4948def : t2InstAlias<"add${s}${p} $Rd, $Rn, $Rm", 4949 (t2ADDrr GPRnopc:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>; 4950def : t2InstAlias<"add${s}${p} $Rd, $Rn, $ShiftedRm", 4951 (t2ADDrs GPRnopc:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm, 4952 pred:$p, cc_out:$s)>; 4953// ... and with the destination and source register combined. 4954def : t2InstAlias<"add${s}${p} $Rdn, $imm", 4955 (t2ADDri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; 4956def : t2InstAlias<"add${p} $Rdn, $imm", 4957 (t2ADDri12 rGPR:$Rdn, rGPR:$Rdn, imm0_4095:$imm, pred:$p)>; 4958def : t2InstAlias<"addw${p} $Rdn, $imm", 4959 (t2ADDri12 rGPR:$Rdn, rGPR:$Rdn, imm0_4095:$imm, pred:$p)>; 4960def : t2InstAlias<"add${s}${p} $Rdn, $Rm", 4961 (t2ADDrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>; 4962def : t2InstAlias<"add${s}${p} $Rdn, $ShiftedRm", 4963 (t2ADDrs GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_reg:$ShiftedRm, 4964 pred:$p, cc_out:$s)>; 4965 4966// add w/ negative immediates is just a sub. 4967def : t2InstSubst<"add${s}${p} $Rd, $Rn, $imm", 4968 (t2SUBri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm, pred:$p, 4969 cc_out:$s)>; 4970def : t2InstSubst<"add${p} $Rd, $Rn, $imm", 4971 (t2SUBri12 rGPR:$Rd, GPR:$Rn, imm0_4095_neg:$imm, pred:$p)>; 4972def : t2InstSubst<"add${s}${p} $Rdn, $imm", 4973 (t2SUBri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_neg:$imm, pred:$p, 4974 cc_out:$s)>; 4975def : t2InstSubst<"add${p} $Rdn, $imm", 4976 (t2SUBri12 rGPR:$Rdn, rGPR:$Rdn, imm0_4095_neg:$imm, pred:$p)>; 4977 4978def : t2InstSubst<"add${s}${p}.w $Rd, $Rn, $imm", 4979 (t2SUBri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm, pred:$p, 4980 cc_out:$s)>; 4981def : t2InstSubst<"addw${p} $Rd, $Rn, $imm", 4982 (t2SUBri12 rGPR:$Rd, rGPR:$Rn, imm0_4095_neg:$imm, pred:$p)>; 4983def : t2InstSubst<"add${s}${p}.w $Rdn, $imm", 4984 (t2SUBri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_neg:$imm, pred:$p, 4985 cc_out:$s)>; 4986def : t2InstSubst<"addw${p} $Rdn, $imm", 4987 (t2SUBri12 rGPR:$Rdn, rGPR:$Rdn, imm0_4095_neg:$imm, pred:$p)>; 4988 4989 4990// Aliases for SUB without the ".w" optional width specifier. 4991def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $imm", 4992 (t2SUBri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; 4993def : t2InstAlias<"sub${p} $Rd, $Rn, $imm", 4994 (t2SUBri12 rGPR:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>; 4995def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $Rm", 4996 (t2SUBrr GPRnopc:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>; 4997def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $ShiftedRm", 4998 (t2SUBrs GPRnopc:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm, 4999 pred:$p, cc_out:$s)>; 5000// ... and with the destination and source register combined. 5001def : t2InstAlias<"sub${s}${p} $Rdn, $imm", 5002 (t2SUBri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; 5003def : t2InstAlias<"sub${p} $Rdn, $imm", 5004 (t2SUBri12 rGPR:$Rdn, rGPR:$Rdn, imm0_4095:$imm, pred:$p)>; 5005def : t2InstAlias<"subw${p} $Rdn, $imm", 5006 (t2SUBri12 rGPR:$Rdn, rGPR:$Rdn, imm0_4095:$imm, pred:$p)>; 5007def : t2InstAlias<"sub${s}${p}.w $Rdn, $Rm", 5008 (t2SUBrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>; 5009def : t2InstAlias<"sub${s}${p} $Rdn, $Rm", 5010 (t2SUBrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>; 5011def : t2InstAlias<"sub${s}${p} $Rdn, $ShiftedRm", 5012 (t2SUBrs GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_reg:$ShiftedRm, 5013 pred:$p, cc_out:$s)>; 5014 5015// SP to SP alike aliases 5016// Aliases for ADD without the ".w" optional width specifier. 5017def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm", 5018 (t2ADDspImm GPRsp:$Rd, GPRsp:$Rn, t2_so_imm:$imm, pred:$p, 5019 cc_out:$s)>; 5020def : t2InstAlias<"add${p} $Rd, $Rn, $imm", 5021 (t2ADDspImm12 GPRsp:$Rd, GPRsp:$Rn, imm0_4095:$imm, pred:$p)>; 5022// ... and with the destination and source register combined. 5023def : t2InstAlias<"add${s}${p} $Rdn, $imm", 5024 (t2ADDspImm GPRsp:$Rdn, GPRsp:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; 5025 5026def : t2InstAlias<"add${s}${p}.w $Rdn, $imm", 5027 (t2ADDspImm GPRsp:$Rdn, GPRsp:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; 5028 5029def : t2InstAlias<"add${p} $Rdn, $imm", 5030 (t2ADDspImm12 GPRsp:$Rdn, GPRsp:$Rdn, imm0_4095:$imm, pred:$p)>; 5031 5032def : t2InstAlias<"addw${p} $Rdn, $imm", 5033 (t2ADDspImm12 GPRsp:$Rdn, GPRsp:$Rdn, imm0_4095:$imm, pred:$p)>; 5034 5035// add w/ negative immediates is just a sub. 5036def : t2InstSubst<"add${s}${p} $Rd, $Rn, $imm", 5037 (t2SUBspImm GPRsp:$Rd, GPRsp:$Rn, t2_so_imm_neg:$imm, pred:$p, 5038 cc_out:$s)>; 5039def : t2InstSubst<"add${p} $Rd, $Rn, $imm", 5040 (t2SUBspImm12 GPRsp:$Rd, GPRsp:$Rn, imm0_4095_neg:$imm, pred:$p)>; 5041def : t2InstSubst<"add${s}${p} $Rdn, $imm", 5042 (t2SUBspImm GPRsp:$Rdn, GPRsp:$Rdn, t2_so_imm_neg:$imm, pred:$p, 5043 cc_out:$s)>; 5044def : t2InstSubst<"add${p} $Rdn, $imm", 5045 (t2SUBspImm12 GPRsp:$Rdn, GPRsp:$Rdn, imm0_4095_neg:$imm, pred:$p)>; 5046 5047def : t2InstSubst<"add${s}${p}.w $Rd, $Rn, $imm", 5048 (t2SUBspImm GPRsp:$Rd, GPRsp:$Rn, t2_so_imm_neg:$imm, pred:$p, 5049 cc_out:$s)>; 5050def : t2InstSubst<"addw${p} $Rd, $Rn, $imm", 5051 (t2SUBspImm12 GPRsp:$Rd, GPRsp:$Rn, imm0_4095_neg:$imm, pred:$p)>; 5052def : t2InstSubst<"add${s}${p}.w $Rdn, $imm", 5053 (t2SUBspImm GPRsp:$Rdn, GPRsp:$Rdn, t2_so_imm_neg:$imm, pred:$p, 5054 cc_out:$s)>; 5055def : t2InstSubst<"addw${p} $Rdn, $imm", 5056 (t2SUBspImm12 GPRsp:$Rdn, GPRsp:$Rdn, imm0_4095_neg:$imm, pred:$p)>; 5057 5058 5059// Aliases for SUB without the ".w" optional width specifier. 5060def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $imm", 5061 (t2SUBspImm GPRsp:$Rd, GPRsp:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; 5062def : t2InstAlias<"sub${p} $Rd, $Rn, $imm", 5063 (t2SUBspImm12 GPRsp:$Rd, GPRsp:$Rn, imm0_4095:$imm, pred:$p)>; 5064// ... and with the destination and source register combined. 5065def : t2InstAlias<"sub${s}${p} $Rdn, $imm", 5066 (t2SUBspImm GPRsp:$Rdn, GPRsp:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; 5067def : t2InstAlias<"sub${s}${p}.w $Rdn, $imm", 5068 (t2SUBspImm GPRsp:$Rdn, GPRsp:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; 5069def : t2InstAlias<"sub${p} $Rdn, $imm", 5070 (t2SUBspImm12 GPRsp:$Rdn, GPRsp:$Rdn, imm0_4095:$imm, pred:$p)>; 5071def : t2InstAlias<"subw${p} $Rdn, $imm", 5072 (t2SUBspImm12 GPRsp:$Rdn, GPRsp:$Rdn, imm0_4095:$imm, pred:$p)>; 5073 5074// Alias for compares without the ".w" optional width specifier. 5075def : t2InstAlias<"cmn${p} $Rn, $Rm", 5076 (t2CMNzrr GPRnopc:$Rn, rGPR:$Rm, pred:$p)>; 5077def : t2InstAlias<"teq${p} $Rn, $Rm", 5078 (t2TEQrr rGPR:$Rn, rGPR:$Rm, pred:$p)>; 5079def : t2InstAlias<"tst${p} $Rn, $Rm", 5080 (t2TSTrr rGPR:$Rn, rGPR:$Rm, pred:$p)>; 5081 5082// Memory barriers 5083def : InstAlias<"dmb${p}.w\t$opt", (t2DMB memb_opt:$opt, pred:$p), 0>, Requires<[HasDB]>; 5084def : InstAlias<"dmb${p}", (t2DMB 0xf, pred:$p), 0>, Requires<[HasDB]>; 5085def : InstAlias<"dmb${p}.w", (t2DMB 0xf, pred:$p), 0>, Requires<[HasDB]>; 5086def : InstAlias<"dsb${p}.w\t$opt", (t2DSB memb_opt:$opt, pred:$p), 0>, Requires<[HasDB]>; 5087def : InstAlias<"dsb${p}", (t2DSB 0xf, pred:$p), 0>, Requires<[HasDB]>; 5088def : InstAlias<"dsb${p}.w", (t2DSB 0xf, pred:$p), 0>, Requires<[HasDB]>; 5089def : InstAlias<"isb${p}.w\t$opt", (t2ISB instsyncb_opt:$opt, pred:$p), 0>, Requires<[HasDB]>; 5090def : InstAlias<"isb${p}", (t2ISB 0xf, pred:$p), 0>, Requires<[HasDB]>; 5091def : InstAlias<"isb${p}.w", (t2ISB 0xf, pred:$p), 0>, Requires<[HasDB]>; 5092 5093// Non-predicable aliases of a predicable DSB: the predicate is (14, zero_reg) where 5094// 14 = AL (always execute) and zero_reg = "instruction doesn't read the CPSR". 5095def : InstAlias<"ssbb", (t2DSB 0x0, 14, zero_reg), 1>, Requires<[HasDB, IsThumb2]>; 5096def : InstAlias<"pssbb", (t2DSB 0x4, 14, zero_reg), 1>, Requires<[HasDB, IsThumb2]>; 5097 5098// Armv8-R 'Data Full Barrier' 5099def : InstAlias<"dfb${p}", (t2DSB 0xc, pred:$p), 1>, Requires<[HasDFB]>; 5100 5101// SpeculationBarrierEndBB must only be used after an unconditional control 5102// flow, i.e. after a terminator for which isBarrier is True. 5103let hasSideEffects = 1, isCodeGenOnly = 1, isTerminator = 1, isBarrier = 1 in { 5104 // This gets lowered to a pair of 4-byte instructions 5105 let Size = 8 in 5106 def t2SpeculationBarrierISBDSBEndBB 5107 : PseudoInst<(outs), (ins), NoItinerary, []>, Sched<[]>; 5108 // This gets lowered to a single 4-byte instructions 5109 let Size = 4 in 5110 def t2SpeculationBarrierSBEndBB 5111 : PseudoInst<(outs), (ins), NoItinerary, []>, Sched<[]>; 5112} 5113 5114// Alias for LDR, LDRB, LDRH, LDRSB, and LDRSH without the ".w" optional 5115// width specifier. 5116def : t2InstAlias<"ldr${p} $Rt, $addr", 5117 (t2LDRi12 GPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>; 5118def : t2InstAlias<"ldrb${p} $Rt, $addr", 5119 (t2LDRBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>; 5120def : t2InstAlias<"ldrh${p} $Rt, $addr", 5121 (t2LDRHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>; 5122def : t2InstAlias<"ldrsb${p} $Rt, $addr", 5123 (t2LDRSBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>; 5124def : t2InstAlias<"ldrsh${p} $Rt, $addr", 5125 (t2LDRSHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>; 5126 5127def : t2InstAlias<"ldr${p} $Rt, $addr", 5128 (t2LDRs GPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>; 5129def : t2InstAlias<"ldrb${p} $Rt, $addr", 5130 (t2LDRBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>; 5131def : t2InstAlias<"ldrh${p} $Rt, $addr", 5132 (t2LDRHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>; 5133def : t2InstAlias<"ldrsb${p} $Rt, $addr", 5134 (t2LDRSBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>; 5135def : t2InstAlias<"ldrsh${p} $Rt, $addr", 5136 (t2LDRSHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>; 5137 5138def : t2InstAlias<"ldr${p} $Rt, $addr", 5139 (t2LDRpci GPR:$Rt, t2ldrlabel:$addr, pred:$p)>; 5140def : t2InstAlias<"ldrb${p} $Rt, $addr", 5141 (t2LDRBpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>; 5142def : t2InstAlias<"ldrh${p} $Rt, $addr", 5143 (t2LDRHpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>; 5144def : t2InstAlias<"ldrsb${p} $Rt, $addr", 5145 (t2LDRSBpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>; 5146def : t2InstAlias<"ldrsh${p} $Rt, $addr", 5147 (t2LDRSHpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>; 5148 5149// Alias for MVN with(out) the ".w" optional width specifier. 5150def : t2InstAlias<"mvn${s}${p}.w $Rd, $imm", 5151 (t2MVNi rGPR:$Rd, t2_so_imm:$imm, pred:$p, cc_out:$s)>; 5152def : t2InstAlias<"mvn${s}${p} $Rd, $Rm", 5153 (t2MVNr rGPR:$Rd, rGPR:$Rm, pred:$p, cc_out:$s)>; 5154def : t2InstAlias<"mvn${s}${p} $Rd, $ShiftedRm", 5155 (t2MVNs rGPR:$Rd, t2_so_reg:$ShiftedRm, pred:$p, cc_out:$s)>; 5156 5157// PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT with the 5158// input operands swapped when the shift amount is zero (i.e., unspecified). 5159def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm", 5160 (t2PKHBT rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>, 5161 Requires<[HasDSP, IsThumb2]>; 5162def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm", 5163 (t2PKHBT rGPR:$Rd, rGPR:$Rm, rGPR:$Rn, 0, pred:$p), 0>, 5164 Requires<[HasDSP, IsThumb2]>; 5165 5166// PUSH/POP aliases for STM/LDM 5167def : t2InstAlias<"push${p}.w $regs", (t2STMDB_UPD SP, pred:$p, reglist:$regs)>; 5168def : t2InstAlias<"push${p} $regs", (t2STMDB_UPD SP, pred:$p, reglist:$regs)>; 5169def : t2InstAlias<"pop${p}.w $regs", (t2LDMIA_UPD SP, pred:$p, reglist:$regs)>; 5170def : t2InstAlias<"pop${p} $regs", (t2LDMIA_UPD SP, pred:$p, reglist:$regs)>; 5171 5172// STMIA/STMIA_UPD aliases w/o the optional .w suffix 5173def : t2InstAlias<"stm${p} $Rn, $regs", 5174 (t2STMIA GPR:$Rn, pred:$p, reglist:$regs)>; 5175def : t2InstAlias<"stm${p} $Rn!, $regs", 5176 (t2STMIA_UPD GPR:$Rn, pred:$p, reglist:$regs)>; 5177 5178// LDMIA/LDMIA_UPD aliases w/o the optional .w suffix 5179def : t2InstAlias<"ldm${p} $Rn, $regs", 5180 (t2LDMIA GPR:$Rn, pred:$p, reglist:$regs)>; 5181def : t2InstAlias<"ldm${p} $Rn!, $regs", 5182 (t2LDMIA_UPD GPR:$Rn, pred:$p, reglist:$regs)>; 5183 5184// STMDB/STMDB_UPD aliases w/ the optional .w suffix 5185def : t2InstAlias<"stmdb${p}.w $Rn, $regs", 5186 (t2STMDB GPR:$Rn, pred:$p, reglist:$regs)>; 5187def : t2InstAlias<"stmdb${p}.w $Rn!, $regs", 5188 (t2STMDB_UPD GPR:$Rn, pred:$p, reglist:$regs)>; 5189 5190// LDMDB/LDMDB_UPD aliases w/ the optional .w suffix 5191def : t2InstAlias<"ldmdb${p}.w $Rn, $regs", 5192 (t2LDMDB GPR:$Rn, pred:$p, reglist:$regs)>; 5193def : t2InstAlias<"ldmdb${p}.w $Rn!, $regs", 5194 (t2LDMDB_UPD GPR:$Rn, pred:$p, reglist:$regs)>; 5195 5196// Alias for REV/REV16/REVSH without the ".w" optional width specifier. 5197def : t2InstAlias<"rev${p} $Rd, $Rm", (t2REV rGPR:$Rd, rGPR:$Rm, pred:$p)>; 5198def : t2InstAlias<"rev16${p} $Rd, $Rm", (t2REV16 rGPR:$Rd, rGPR:$Rm, pred:$p)>; 5199def : t2InstAlias<"revsh${p} $Rd, $Rm", (t2REVSH rGPR:$Rd, rGPR:$Rm, pred:$p)>; 5200 5201 5202// Alias for RSB with and without the ".w" optional width specifier, with and 5203// without explicit destination register. 5204def : t2InstAlias<"rsb${s}${p} $Rd, $Rn, $imm", 5205 (t2RSBri rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; 5206def : t2InstAlias<"rsb${s}${p} $Rdn, $imm", 5207 (t2RSBri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; 5208def : t2InstAlias<"rsb${s}${p} $Rdn, $Rm", 5209 (t2RSBrr rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>; 5210def : t2InstAlias<"rsb${s}${p} $Rdn, $ShiftedRm", 5211 (t2RSBrs rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$ShiftedRm, pred:$p, 5212 cc_out:$s)>; 5213def : t2InstAlias<"rsb${s}${p}.w $Rdn, $Rm", 5214 (t2RSBrr rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>; 5215def : t2InstAlias<"rsb${s}${p}.w $Rd, $Rn, $Rm", 5216 (t2RSBrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>; 5217def : t2InstAlias<"rsb${s}${p}.w $Rd, $Rn, $ShiftedRm", 5218 (t2RSBrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm, pred:$p, 5219 cc_out:$s)>; 5220 5221// SSAT/USAT optional shift operand. 5222def : t2InstAlias<"ssat${p} $Rd, $sat_imm, $Rn", 5223 (t2SSAT rGPR:$Rd, imm1_32:$sat_imm, rGPR:$Rn, 0, pred:$p)>; 5224def : t2InstAlias<"usat${p} $Rd, $sat_imm, $Rn", 5225 (t2USAT rGPR:$Rd, imm0_31:$sat_imm, rGPR:$Rn, 0, pred:$p)>; 5226 5227// STM w/o the .w suffix. 5228def : t2InstAlias<"stm${p} $Rn, $regs", 5229 (t2STMIA GPR:$Rn, pred:$p, reglist:$regs)>; 5230 5231// Alias for STR, STRB, and STRH without the ".w" optional 5232// width specifier. 5233def : t2InstAlias<"str${p} $Rt, $addr", 5234 (t2STRi12 GPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>; 5235def : t2InstAlias<"strb${p} $Rt, $addr", 5236 (t2STRBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>; 5237def : t2InstAlias<"strh${p} $Rt, $addr", 5238 (t2STRHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>; 5239 5240def : t2InstAlias<"str${p} $Rt, $addr", 5241 (t2STRs GPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>; 5242def : t2InstAlias<"strb${p} $Rt, $addr", 5243 (t2STRBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>; 5244def : t2InstAlias<"strh${p} $Rt, $addr", 5245 (t2STRHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>; 5246 5247// Extend instruction optional rotate operand. 5248def : InstAlias<"sxtab${p} $Rd, $Rn, $Rm", 5249 (t2SXTAB rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>, 5250 Requires<[HasDSP, IsThumb2]>; 5251def : InstAlias<"sxtah${p} $Rd, $Rn, $Rm", 5252 (t2SXTAH rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>, 5253 Requires<[HasDSP, IsThumb2]>; 5254def : InstAlias<"sxtab16${p} $Rd, $Rn, $Rm", 5255 (t2SXTAB16 rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>, 5256 Requires<[HasDSP, IsThumb2]>; 5257def : InstAlias<"sxtb16${p} $Rd, $Rm", 5258 (t2SXTB16 rGPR:$Rd, rGPR:$Rm, 0, pred:$p), 0>, 5259 Requires<[HasDSP, IsThumb2]>; 5260 5261def : t2InstAlias<"sxtb${p} $Rd, $Rm", 5262 (t2SXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>; 5263def : t2InstAlias<"sxth${p} $Rd, $Rm", 5264 (t2SXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>; 5265def : t2InstAlias<"sxtb${p}.w $Rd, $Rm", 5266 (t2SXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>; 5267def : t2InstAlias<"sxth${p}.w $Rd, $Rm", 5268 (t2SXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>; 5269 5270def : InstAlias<"uxtab${p} $Rd, $Rn, $Rm", 5271 (t2UXTAB rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>, 5272 Requires<[HasDSP, IsThumb2]>; 5273def : InstAlias<"uxtah${p} $Rd, $Rn, $Rm", 5274 (t2UXTAH rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>, 5275 Requires<[HasDSP, IsThumb2]>; 5276def : InstAlias<"uxtab16${p} $Rd, $Rn, $Rm", 5277 (t2UXTAB16 rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>, 5278 Requires<[HasDSP, IsThumb2]>; 5279def : InstAlias<"uxtb16${p} $Rd, $Rm", 5280 (t2UXTB16 rGPR:$Rd, rGPR:$Rm, 0, pred:$p), 0>, 5281 Requires<[HasDSP, IsThumb2]>; 5282 5283def : t2InstAlias<"uxtb${p} $Rd, $Rm", 5284 (t2UXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>; 5285def : t2InstAlias<"uxth${p} $Rd, $Rm", 5286 (t2UXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>; 5287def : t2InstAlias<"uxtb${p}.w $Rd, $Rm", 5288 (t2UXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>; 5289def : t2InstAlias<"uxth${p}.w $Rd, $Rm", 5290 (t2UXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>; 5291 5292// Extend instruction w/o the ".w" optional width specifier. 5293def : t2InstAlias<"uxtb${p} $Rd, $Rm$rot", 5294 (t2UXTB rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>; 5295def : InstAlias<"uxtb16${p} $Rd, $Rm$rot", 5296 (t2UXTB16 rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p), 0>, 5297 Requires<[HasDSP, IsThumb2]>; 5298def : t2InstAlias<"uxth${p} $Rd, $Rm$rot", 5299 (t2UXTH rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>; 5300 5301def : t2InstAlias<"sxtb${p} $Rd, $Rm$rot", 5302 (t2SXTB rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>; 5303def : InstAlias<"sxtb16${p} $Rd, $Rm$rot", 5304 (t2SXTB16 rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p), 0>, 5305 Requires<[HasDSP, IsThumb2]>; 5306def : t2InstAlias<"sxth${p} $Rd, $Rm$rot", 5307 (t2SXTH rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>; 5308 5309 5310// "mov Rd, t2_so_imm_not" can be handled via "mvn" in assembly, just like 5311// for isel. 5312def : t2InstSubst<"mov${p} $Rd, $imm", 5313 (t2MVNi rGPR:$Rd, t2_so_imm_not:$imm, pred:$p, zero_reg)>; 5314def : t2InstSubst<"mvn${s}${p} $Rd, $imm", 5315 (t2MOVi rGPR:$Rd, t2_so_imm_not:$imm, pred:$p, s_cc_out:$s)>; 5316// Same for AND <--> BIC 5317def : t2InstSubst<"bic${s}${p} $Rd, $Rn, $imm", 5318 (t2ANDri rGPR:$Rd, rGPR:$Rn, t2_so_imm_not:$imm, 5319 pred:$p, cc_out:$s)>; 5320def : t2InstSubst<"bic${s}${p} $Rdn, $imm", 5321 (t2ANDri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_not:$imm, 5322 pred:$p, cc_out:$s)>; 5323def : t2InstSubst<"bic${s}${p}.w $Rd, $Rn, $imm", 5324 (t2ANDri rGPR:$Rd, rGPR:$Rn, t2_so_imm_not:$imm, 5325 pred:$p, cc_out:$s)>; 5326def : t2InstSubst<"bic${s}${p}.w $Rdn, $imm", 5327 (t2ANDri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_not:$imm, 5328 pred:$p, cc_out:$s)>; 5329def : t2InstSubst<"and${s}${p} $Rd, $Rn, $imm", 5330 (t2BICri rGPR:$Rd, rGPR:$Rn, t2_so_imm_not:$imm, 5331 pred:$p, cc_out:$s)>; 5332def : t2InstSubst<"and${s}${p} $Rdn, $imm", 5333 (t2BICri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_not:$imm, 5334 pred:$p, cc_out:$s)>; 5335def : t2InstSubst<"and${s}${p}.w $Rd, $Rn, $imm", 5336 (t2BICri rGPR:$Rd, rGPR:$Rn, t2_so_imm_not:$imm, 5337 pred:$p, cc_out:$s)>; 5338def : t2InstSubst<"and${s}${p}.w $Rdn, $imm", 5339 (t2BICri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_not:$imm, 5340 pred:$p, cc_out:$s)>; 5341// And ORR <--> ORN 5342def : t2InstSubst<"orn${s}${p} $Rd, $Rn, $imm", 5343 (t2ORRri rGPR:$Rd, rGPR:$Rn, t2_so_imm_not:$imm, 5344 pred:$p, cc_out:$s)>; 5345def : t2InstSubst<"orn${s}${p} $Rdn, $imm", 5346 (t2ORRri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_not:$imm, 5347 pred:$p, cc_out:$s)>; 5348def : t2InstSubst<"orr${s}${p} $Rd, $Rn, $imm", 5349 (t2ORNri rGPR:$Rd, rGPR:$Rn, t2_so_imm_not:$imm, 5350 pred:$p, cc_out:$s)>; 5351def : t2InstSubst<"orr${s}${p} $Rdn, $imm", 5352 (t2ORNri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_not:$imm, 5353 pred:$p, cc_out:$s)>; 5354// Likewise, "add Rd, t2_so_imm_neg" -> sub 5355def : t2InstSubst<"add${s}${p} $Rd, $Rn, $imm", 5356 (t2SUBri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm, 5357 pred:$p, cc_out:$s)>; 5358def : t2InstSubst<"add${s}${p} $Rd, $Rn, $imm", 5359 (t2SUBspImm GPRsp:$Rd, GPRsp:$Rn, t2_so_imm_neg:$imm, 5360 pred:$p, cc_out:$s)>; 5361def : t2InstSubst<"add${s}${p} $Rd, $imm", 5362 (t2SUBri rGPR:$Rd, rGPR:$Rd, t2_so_imm_neg:$imm, 5363 pred:$p, cc_out:$s)>; 5364def : t2InstSubst<"add${s}${p} $Rd, $imm", 5365 (t2SUBspImm GPRsp:$Rd, GPRsp:$Rd, t2_so_imm_neg:$imm, 5366 pred:$p, cc_out:$s)>; 5367// Same for CMP <--> CMN via t2_so_imm_neg 5368def : t2InstSubst<"cmp${p} $Rd, $imm", 5369 (t2CMNri rGPR:$Rd, t2_so_imm_neg:$imm, pred:$p)>; 5370def : t2InstSubst<"cmn${p} $Rd, $imm", 5371 (t2CMPri rGPR:$Rd, t2_so_imm_neg:$imm, pred:$p)>; 5372 5373 5374// Wide 'mul' encoding can be specified with only two operands. 5375def : t2InstAlias<"mul${p} $Rn, $Rm", 5376 (t2MUL rGPR:$Rn, rGPR:$Rm, rGPR:$Rn, pred:$p)>; 5377 5378// "neg" is and alias for "rsb rd, rn, #0" 5379def : t2InstAlias<"neg${s}${p} $Rd, $Rm", 5380 (t2RSBri rGPR:$Rd, rGPR:$Rm, 0, pred:$p, cc_out:$s)>; 5381 5382// MOV so_reg assembler pseudos. InstAlias isn't expressive enough for 5383// these, unfortunately. 5384// FIXME: LSL #0 in the shift should allow SP to be used as either the 5385// source or destination (but not both). 5386def t2MOVsi: t2AsmPseudo<"mov${p} $Rd, $shift", 5387 (ins rGPR:$Rd, t2_so_reg:$shift, pred:$p)>; 5388def t2MOVSsi: t2AsmPseudo<"movs${p} $Rd, $shift", 5389 (ins rGPR:$Rd, t2_so_reg:$shift, pred:$p)>; 5390 5391def t2MOVsr: t2AsmPseudo<"mov${p} $Rd, $shift", 5392 (ins rGPR:$Rd, so_reg_reg:$shift, pred:$p)>; 5393def t2MOVSsr: t2AsmPseudo<"movs${p} $Rd, $shift", 5394 (ins rGPR:$Rd, so_reg_reg:$shift, pred:$p)>; 5395 5396// Aliases for the above with the .w qualifier 5397def : t2InstAlias<"mov${p}.w $Rd, $shift", 5398 (t2MOVsi rGPR:$Rd, t2_so_reg:$shift, pred:$p)>; 5399def : t2InstAlias<"movs${p}.w $Rd, $shift", 5400 (t2MOVSsi rGPR:$Rd, t2_so_reg:$shift, pred:$p)>; 5401def : t2InstAlias<"mov${p}.w $Rd, $shift", 5402 (t2MOVsr rGPR:$Rd, so_reg_reg:$shift, pred:$p)>; 5403def : t2InstAlias<"movs${p}.w $Rd, $shift", 5404 (t2MOVSsr rGPR:$Rd, so_reg_reg:$shift, pred:$p)>; 5405 5406// ADR w/o the .w suffix 5407def : t2InstAlias<"adr${p} $Rd, $addr", 5408 (t2ADR rGPR:$Rd, t2adrlabel:$addr, pred:$p)>; 5409 5410// LDR(literal) w/ alternate [pc, #imm] syntax. 5411def t2LDRpcrel : t2AsmPseudo<"ldr${p} $Rt, $addr", 5412 (ins GPR:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>; 5413def t2LDRBpcrel : t2AsmPseudo<"ldrb${p} $Rt, $addr", 5414 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>; 5415def t2LDRHpcrel : t2AsmPseudo<"ldrh${p} $Rt, $addr", 5416 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>; 5417def t2LDRSBpcrel : t2AsmPseudo<"ldrsb${p} $Rt, $addr", 5418 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>; 5419def t2LDRSHpcrel : t2AsmPseudo<"ldrsh${p} $Rt, $addr", 5420 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>; 5421 // Version w/ the .w suffix. 5422def : t2InstAlias<"ldr${p}.w $Rt, $addr", 5423 (t2LDRpcrel GPR:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p), 0>; 5424def : t2InstAlias<"ldrb${p}.w $Rt, $addr", 5425 (t2LDRBpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>; 5426def : t2InstAlias<"ldrh${p}.w $Rt, $addr", 5427 (t2LDRHpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>; 5428def : t2InstAlias<"ldrsb${p}.w $Rt, $addr", 5429 (t2LDRSBpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>; 5430def : t2InstAlias<"ldrsh${p}.w $Rt, $addr", 5431 (t2LDRSHpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>; 5432 5433def : t2InstAlias<"add${p} $Rd, pc, $imm", 5434 (t2ADR rGPR:$Rd, imm0_4095:$imm, pred:$p)>; 5435 5436// Pseudo instruction ldr Rt, =immediate 5437def t2LDRConstPool 5438 : t2AsmPseudo<"ldr${p} $Rt, $immediate", 5439 (ins GPR:$Rt, const_pool_asm_imm:$immediate, pred:$p)>; 5440// Version w/ the .w suffix. 5441def : t2InstAlias<"ldr${p}.w $Rt, $immediate", 5442 (t2LDRConstPool GPRnopc:$Rt, 5443 const_pool_asm_imm:$immediate, pred:$p)>; 5444 5445//===----------------------------------------------------------------------===// 5446// ARMv8.1m instructions 5447// 5448 5449class V8_1MI<dag oops, dag iops, AddrMode am, InstrItinClass itin, string asm, 5450 string ops, string cstr, list<dag> pattern> 5451 : Thumb2XI<oops, iops, am, 4, itin, !strconcat(asm, "\t", ops), cstr, 5452 pattern>, 5453 Requires<[HasV8_1MMainline]>; 5454 5455def t2CLRM : V8_1MI<(outs), 5456 (ins pred:$p, reglist_with_apsr:$regs, variable_ops), 5457 AddrModeNone, NoItinerary, "clrm${p}", "$regs", "", []> { 5458 bits<16> regs; 5459 5460 let Inst{31-16} = 0b1110100010011111; 5461 let Inst{15-14} = regs{15-14}; 5462 let Inst{13} = 0b0; 5463 let Inst{12-0} = regs{12-0}; 5464} 5465 5466class t2BF<dag iops, string asm, string ops> 5467 : V8_1MI<(outs ), iops, AddrModeNone, NoItinerary, asm, ops, "", []> { 5468 5469 let Inst{31-27} = 0b11110; 5470 let Inst{15-14} = 0b11; 5471 let Inst{12} = 0b0; 5472 let Inst{0} = 0b1; 5473 5474 let Predicates = [IsThumb2, HasV8_1MMainline, HasLOB]; 5475} 5476 5477def t2BF_LabelPseudo 5478 : t2PseudoInst<(outs ), (ins pclabel:$cp), 0, NoItinerary, []> { 5479 let isTerminator = 1; 5480 let Predicates = [IsThumb2, HasV8_1MMainline, HasLOB]; 5481 let hasNoSchedulingInfo = 1; 5482} 5483 5484def t2BFi : t2BF<(ins bflabel_u4:$b_label, bflabel_s16:$label, pred:$p), 5485 !strconcat("bf", "${p}"), "$b_label, $label"> { 5486 bits<4> b_label; 5487 bits<16> label; 5488 5489 let Inst{26-23} = b_label{3-0}; 5490 let Inst{22-21} = 0b10; 5491 let Inst{20-16} = label{15-11}; 5492 let Inst{13} = 0b1; 5493 let Inst{11} = label{0}; 5494 let Inst{10-1} = label{10-1}; 5495} 5496 5497def t2BFic : t2BF<(ins bflabel_u4:$b_label, bflabel_s12:$label, 5498 bfafter_target:$ba_label, pred_noal:$bcond), "bfcsel", 5499 "$b_label, $label, $ba_label, $bcond"> { 5500 bits<4> bcond; 5501 bits<12> label; 5502 bits<1> ba_label; 5503 bits<4> b_label; 5504 5505 let Inst{26-23} = b_label{3-0}; 5506 let Inst{22} = 0b0; 5507 let Inst{21-18} = bcond{3-0}; 5508 let Inst{17} = ba_label{0}; 5509 let Inst{16} = label{11}; 5510 let Inst{13} = 0b1; 5511 let Inst{11} = label{0}; 5512 let Inst{10-1} = label{10-1}; 5513} 5514 5515def t2BFr : t2BF<(ins bflabel_u4:$b_label, rGPR:$Rn, pred:$p), 5516 !strconcat("bfx", "${p}"), "$b_label, $Rn"> { 5517 bits<4> b_label; 5518 bits<4> Rn; 5519 5520 let Inst{26-23} = b_label{3-0}; 5521 let Inst{22-20} = 0b110; 5522 let Inst{19-16} = Rn{3-0}; 5523 let Inst{13-1} = 0b1000000000000; 5524} 5525 5526def t2BFLi : t2BF<(ins bflabel_u4:$b_label, bflabel_s18:$label, pred:$p), 5527 !strconcat("bfl", "${p}"), "$b_label, $label"> { 5528 bits<4> b_label; 5529 bits<18> label; 5530 5531 let Inst{26-23} = b_label{3-0}; 5532 let Inst{22-16} = label{17-11}; 5533 let Inst{13} = 0b0; 5534 let Inst{11} = label{0}; 5535 let Inst{10-1} = label{10-1}; 5536} 5537 5538def t2BFLr : t2BF<(ins bflabel_u4:$b_label, rGPR:$Rn, pred:$p), 5539 !strconcat("bflx", "${p}"), "$b_label, $Rn"> { 5540 bits<4> b_label; 5541 bits<4> Rn; 5542 5543 let Inst{26-23} = b_label{3-0}; 5544 let Inst{22-20} = 0b111; 5545 let Inst{19-16} = Rn{3-0}; 5546 let Inst{13-1} = 0b1000000000000; 5547} 5548 5549class t2LOL<dag oops, dag iops, string asm, string ops> 5550 : V8_1MI<oops, iops, AddrModeNone, NoItinerary, asm, ops, "", [] > { 5551 let Inst{31-23} = 0b111100000; 5552 let Inst{15-14} = 0b11; 5553 let Inst{0} = 0b1; 5554 let DecoderMethod = "DecodeLOLoop"; 5555 let Predicates = [IsThumb2, HasV8_1MMainline, HasLOB]; 5556} 5557 5558let isNotDuplicable = 1 in { 5559def t2WLS : t2LOL<(outs GPRlr:$LR), 5560 (ins rGPR:$Rn, wlslabel_u11:$label), 5561 "wls", "$LR, $Rn, $label"> { 5562 bits<4> Rn; 5563 bits<11> label; 5564 let Inst{22-20} = 0b100; 5565 let Inst{19-16} = Rn{3-0}; 5566 let Inst{13-12} = 0b00; 5567 let Inst{11} = label{0}; 5568 let Inst{10-1} = label{10-1}; 5569 let usesCustomInserter = 1; 5570 let isBranch = 1; 5571 let isTerminator = 1; 5572} 5573 5574def t2DLS : t2LOL<(outs GPRlr:$LR), (ins rGPR:$Rn), 5575 "dls", "$LR, $Rn"> { 5576 bits<4> Rn; 5577 let Inst{22-20} = 0b100; 5578 let Inst{19-16} = Rn{3-0}; 5579 let Inst{13-1} = 0b1000000000000; 5580 let usesCustomInserter = 1; 5581} 5582 5583def t2LEUpdate : t2LOL<(outs GPRlr:$LRout), 5584 (ins GPRlr:$LRin, lelabel_u11:$label), 5585 "le", "$LRin, $label"> { 5586 bits<11> label; 5587 let Inst{22-16} = 0b0001111; 5588 let Inst{13-12} = 0b00; 5589 let Inst{11} = label{0}; 5590 let Inst{10-1} = label{10-1}; 5591 let usesCustomInserter = 1; 5592 let isBranch = 1; 5593 let isTerminator = 1; 5594} 5595 5596def t2LE : t2LOL<(outs ), (ins lelabel_u11:$label), "le", "$label"> { 5597 bits<11> label; 5598 let Inst{22-16} = 0b0101111; 5599 let Inst{13-12} = 0b00; 5600 let Inst{11} = label{0}; 5601 let Inst{10-1} = label{10-1}; 5602 let isBranch = 1; 5603 let isTerminator = 1; 5604} 5605 5606let Predicates = [IsThumb2, HasV8_1MMainline, HasLOB] in { 5607 5608// t2DoLoopStart a pseudo for DLS hardware loops. Lowered into a DLS in 5609// ARMLowOverheadLoops if possible, or reverted to a Mov if not. 5610def t2DoLoopStart : 5611 t2PseudoInst<(outs GPRlr:$X), (ins rGPR:$tc), 4, IIC_Br, 5612 [(set GPRlr:$X, (int_start_loop_iterations rGPR:$tc))]>; 5613 5614// A pseudo for a DLSTP, created in the MVETPAndVPTOptimizationPass from a 5615// t2DoLoopStart if the loops is tail predicated. Holds both the element 5616// count and trip count of the loop, picking the correct one during 5617// ARMLowOverheadLoops when it is converted to a DLSTP or DLS as required. 5618let isTerminator = 1, hasSideEffects = 1 in 5619def t2DoLoopStartTP : 5620 t2PseudoInst<(outs GPRlr:$X), (ins rGPR:$tc, rGPR:$elts), 4, IIC_Br, []>; 5621 5622// Setup for a t2WhileLoopStart. A pair of t2WhileLoopSetup and t2WhileLoopStart 5623// will be created post-ISel from a llvm.test.start.loop.iterations. This 5624// t2WhileLoopSetup to setup LR and t2WhileLoopStart to perform the branch. Not 5625// valid after reg alloc, as it should be lowered during MVETPAndVPTOptimisations 5626// into a t2WhileLoopStartLR (or expanded). 5627def t2WhileLoopSetup : 5628 t2PseudoInst<(outs GPRlr:$lr), (ins rGPR:$tc), 4, IIC_Br, []>; 5629 5630// A pseudo to represent the decrement in a low overhead loop. A t2LoopDec and 5631// t2LoopEnd together represent a LE instruction. Ideally these are converted 5632// to a t2LoopEndDec which is lowered as a single instruction. 5633let hasSideEffects = 0 in 5634def t2LoopDec : 5635 t2PseudoInst<(outs GPRlr:$Rm), (ins GPRlr:$Rn, imm0_7:$size), 5636 4, IIC_Br, []>, Sched<[WriteBr]>; 5637 5638let isBranch = 1, isTerminator = 1, hasSideEffects = 1, Defs = [CPSR] in { 5639// The branch in a t2WhileLoopSetup/t2WhileLoopStart pair, eventually turned 5640// into a t2WhileLoopStartLR that does both the LR setup and branch. 5641def t2WhileLoopStart : 5642 t2PseudoInst<(outs), 5643 (ins GPRlr:$tc, brtarget:$target), 5644 4, IIC_Br, []>, 5645 Sched<[WriteBr]>; 5646 5647// WhileLoopStartLR that sets up LR and branches on zero, equivalent to WLS. It 5648// is lowered in the ARMLowOverheadLoops pass providing the branches are within 5649// range. WhileLoopStartLR and LoopEnd to occupy 8 bytes because they may get 5650// converted into t2CMP and t2Bcc. 5651def t2WhileLoopStartLR : 5652 t2PseudoInst<(outs GPRlr:$lr), 5653 (ins rGPR:$tc, brtarget:$target), 5654 8, IIC_Br, []>, 5655 Sched<[WriteBr]>; 5656 5657// Similar to a t2DoLoopStartTP, a t2WhileLoopStartTP is a pseudo for a WLSTP 5658// holding both the element count and the tripcount of the loop. 5659def t2WhileLoopStartTP : 5660 t2PseudoInst<(outs GPRlr:$lr), 5661 (ins rGPR:$tc, rGPR:$elts, brtarget:$target), 5662 8, IIC_Br, []>, 5663 Sched<[WriteBr]>; 5664 5665// t2LoopEnd - the branch half of a t2LoopDec/t2LoopEnd pair. 5666def t2LoopEnd : 5667 t2PseudoInst<(outs), (ins GPRlr:$tc, brtarget:$target), 5668 8, IIC_Br, []>, Sched<[WriteBr]>; 5669 5670// The combination of a t2LoopDec and t2LoopEnd, performing both the LR 5671// decrement and branch as a single instruction. Is lowered to a LE or 5672// LETP in ARMLowOverheadLoops as appropriate, or converted to t2CMP/t2Bcc 5673// if the branches are out of range. 5674def t2LoopEndDec : 5675 t2PseudoInst<(outs GPRlr:$Rm), (ins GPRlr:$tc, brtarget:$target), 5676 8, IIC_Br, []>, Sched<[WriteBr]>; 5677 5678} // end isBranch, isTerminator, hasSideEffects 5679 5680} 5681 5682} // end isNotDuplicable 5683 5684class CS<string iname, bits<4> opcode, list<dag> pattern=[]> 5685 : V8_1MI<(outs rGPR:$Rd), (ins GPRwithZRnosp:$Rn, GPRwithZRnosp:$Rm, pred_noal:$fcond), 5686 AddrModeNone, NoItinerary, iname, "$Rd, $Rn, $Rm, $fcond", "", pattern> { 5687 bits<4> Rd; 5688 bits<4> Rm; 5689 bits<4> Rn; 5690 bits<4> fcond; 5691 5692 let Inst{31-20} = 0b111010100101; 5693 let Inst{19-16} = Rn{3-0}; 5694 let Inst{15-12} = opcode; 5695 let Inst{11-8} = Rd{3-0}; 5696 let Inst{7-4} = fcond{3-0}; 5697 let Inst{3-0} = Rm{3-0}; 5698 5699 let Uses = [CPSR]; 5700 let hasSideEffects = 0; 5701} 5702 5703def t2CSEL : CS<"csel", 0b1000>; 5704def t2CSINC : CS<"csinc", 0b1001>; 5705def t2CSINV : CS<"csinv", 0b1010>; 5706def t2CSNEG : CS<"csneg", 0b1011>; 5707 5708def ARMcsinc_su : PatFrag<(ops node:$lhs, node:$rhs, node:$cond), 5709 (ARMcsinc node:$lhs, node:$rhs, node:$cond), [{ 5710 return N->hasOneUse(); 5711}]>; 5712 5713let Predicates = [HasV8_1MMainline] in { 5714 multiclass CSPats<SDNode Node, Instruction Insn> { 5715 def : T2Pat<(Node GPRwithZR:$tval, GPRwithZR:$fval, imm0_31:$imm), 5716 (Insn GPRwithZR:$tval, GPRwithZR:$fval, imm0_31:$imm)>; 5717 def : T2Pat<(Node (i32 0), GPRwithZR:$fval, imm0_31:$imm), 5718 (Insn ZR, GPRwithZR:$fval, imm0_31:$imm)>; 5719 def : T2Pat<(Node GPRwithZR:$tval, (i32 0), imm0_31:$imm), 5720 (Insn GPRwithZR:$tval, ZR, imm0_31:$imm)>; 5721 def : T2Pat<(Node (i32 0), (i32 0), imm0_31:$imm), 5722 (Insn ZR, ZR, imm0_31:$imm)>; 5723 } 5724 5725 defm : CSPats<ARMcsinc, t2CSINC>; 5726 defm : CSPats<ARMcsinv, t2CSINV>; 5727 defm : CSPats<ARMcsneg, t2CSNEG>; 5728 5729 def : T2Pat<(ARMcmov (i32 1), (i32 0), cmovpred:$imm), 5730 (t2CSINC ZR, ZR, imm0_31:$imm)>; 5731 def : T2Pat<(ARMcmov (i32 -1), (i32 0), cmovpred:$imm), 5732 (t2CSINV ZR, ZR, imm0_31:$imm)>; 5733 def : T2Pat<(ARMcmov (i32 0), (i32 1), cmovpred:$imm), 5734 (t2CSINC ZR, ZR, (inv_cond_XFORM imm:$imm))>; 5735 def : T2Pat<(ARMcmov (i32 0), (i32 -1), cmovpred:$imm), 5736 (t2CSINV ZR, ZR, (inv_cond_XFORM imm:$imm))>; 5737 5738 multiclass ModifiedV8_1CSEL<Instruction Insn, dag modvalue> { 5739 def : T2Pat<(ARMcmov modvalue, GPRwithZR:$tval, cmovpred:$imm), 5740 (Insn GPRwithZR:$tval, GPRwithZR:$fval, imm0_31:$imm)>; 5741 def : T2Pat<(ARMcmov GPRwithZR:$tval, modvalue, cmovpred:$imm), 5742 (Insn GPRwithZR:$tval, GPRwithZR:$fval, 5743 (i32 (inv_cond_XFORM imm:$imm)))>; 5744 } 5745 defm : ModifiedV8_1CSEL<t2CSINC, (add rGPR:$fval, 1)>; 5746 defm : ModifiedV8_1CSEL<t2CSINV, (xor rGPR:$fval, -1)>; 5747 defm : ModifiedV8_1CSEL<t2CSNEG, (sub 0, rGPR:$fval)>; 5748 5749 def : T2Pat<(ARMcmov (topbitsallzero32:$Rn), (i32 1), cmovpred:$imm), 5750 (t2CSINC $Rn, ZR, (inv_cond_XFORM imm:$imm))>; 5751 def : T2Pat<(and (topbitsallzero32:$Rn), (ARMcsinc_su (i32 0), (i32 0), cmovpred:$imm)), 5752 (t2CSEL ZR, $Rn, $imm)>; 5753} 5754 5755// CS aliases. 5756let Predicates = [HasV8_1MMainline] in { 5757 def : InstAlias<"csetm\t$Rd, $fcond", 5758 (t2CSINV rGPR:$Rd, ZR, ZR, pred_noal_inv:$fcond)>; 5759 5760 def : InstAlias<"cset\t$Rd, $fcond", 5761 (t2CSINC rGPR:$Rd, ZR, ZR, pred_noal_inv:$fcond)>; 5762 5763 def : InstAlias<"cinc\t$Rd, $Rn, $fcond", 5764 (t2CSINC rGPR:$Rd, GPRwithZRnosp:$Rn, GPRwithZRnosp:$Rn, pred_noal_inv:$fcond)>; 5765 5766 def : InstAlias<"cinv\t$Rd, $Rn, $fcond", 5767 (t2CSINV rGPR:$Rd, GPRwithZRnosp:$Rn, GPRwithZRnosp:$Rn, pred_noal_inv:$fcond)>; 5768 5769 def : InstAlias<"cneg\t$Rd, $Rn, $fcond", 5770 (t2CSNEG rGPR:$Rd, GPRwithZRnosp:$Rn, GPRwithZRnosp:$Rn, pred_noal_inv:$fcond)>; 5771} 5772 5773 5774// PACBTI 5775let Predicates = [IsThumb2, HasV8_1MMainline, HasPACBTI] in { 5776def t2PACG : V8_1MI<(outs rGPR:$Rd), 5777 (ins pred:$p, GPRnopc:$Rn, GPRnopc:$Rm), 5778 AddrModeNone, NoItinerary, "pacg${p}", "$Rd, $Rn, $Rm", "", []> { 5779 bits<4> Rd; 5780 bits<4> Rn; 5781 bits<4> Rm; 5782 let Inst{31-20} = 0b111110110110; 5783 let Inst{19-16} = Rn; 5784 let Inst{15-12} = 0b1111; 5785 let Inst{11-8} = Rd; 5786 let Inst{7-4} = 0b0000; 5787 let Inst{3-0} = Rm; 5788} 5789 5790let hasSideEffects = 1 in { 5791class PACBTIAut<dag iops, string asm, bit b> 5792 : V8_1MI<(outs), iops, 5793 AddrModeNone, NoItinerary, asm, "$Ra, $Rn, $Rm", "", []> { 5794 bits<4> Ra; 5795 bits<4> Rn; 5796 bits<4> Rm; 5797 let Inst{31-20} = 0b111110110101; 5798 let Inst{19-16} = Rn; 5799 let Inst{15-12} = Ra; 5800 let Inst{11-5} = 0b1111000; 5801 let Inst{4} = b; 5802 let Inst{3-0} = Rm; 5803} 5804} 5805 5806def t2AUTG : PACBTIAut<(ins pred:$p, GPRnosp:$Ra, GPRnopc:$Rn, GPRnopc:$Rm), 5807 "autg${p}", 0>; 5808 5809let isBranch = 1, isTerminator = 1, isIndirectBranch = 1 in { 5810 def t2BXAUT : PACBTIAut<(ins pred:$p, GPRnosp:$Ra, rGPR:$Rn, GPRnopc:$Rm), 5811 "bxaut${p}", 1>; 5812} 5813} 5814 5815 5816class PACBTIHintSpaceInst<string asm, string ops, bits<8> imm> 5817 : Thumb2XI<(outs), (ins), AddrModeNone, 4, NoItinerary, !strconcat(asm, "\t", ops), "", []>, 5818 Requires<[HasV7, IsMClass]> { 5819 let Inst{31-8} = 0b111100111010111110000000; 5820 let Inst{7-0} = imm; 5821 5822 let Unpredictable{19-16} = 0b1111; 5823 let Unpredictable{13-11} = 0b101; 5824 5825 let DecoderMethod = "DecodeT2HintSpaceInstruction"; 5826} 5827 5828class PACBTIHintSpaceNoOpsInst<string asm, bits<8> imm> 5829 : PACBTIHintSpaceInst<asm, "", imm>; 5830 5831class PACBTIHintSpaceDefInst<string asm, bits<8> imm> 5832 : PACBTIHintSpaceInst<asm, "r12, lr, sp", imm> { 5833 let Defs = [R12]; 5834 let Uses = [LR, SP]; 5835} 5836 5837class PACBTIHintSpaceUseInst<string asm, bits<8> imm> 5838 : PACBTIHintSpaceInst<asm, "r12, lr, sp", imm> { 5839 let Uses = [R12, LR, SP]; 5840} 5841 5842def t2PAC : PACBTIHintSpaceDefInst<"pac", 0b00011101>; 5843def t2PACBTI : PACBTIHintSpaceDefInst<"pacbti", 0b00001101>; 5844def t2BTI : PACBTIHintSpaceNoOpsInst<"bti", 0b00001111>; 5845def t2AUT : PACBTIHintSpaceUseInst<"aut", 0b00101101> { 5846 let hasSideEffects = 1; 5847} 5848 5849def ARMt2CallBTI : SDNode<"ARMISD::t2CALL_BTI", SDT_ARMcall, 5850 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, SDNPVariadic]>; 5851 5852def t2CALL_BTI : PseudoInst<(outs), (ins pred:$p, thumb_bl_target:$func), 5853 IIC_Br, [(ARMt2CallBTI tglobaladdr:$func)]>, 5854 Requires<[IsThumb2]>, Sched<[WriteBrL]>; 5855