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