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