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