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