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