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