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