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