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