1 //===- Mips16InstrInfo.td - Target Description for Mips16 -*- tablegen -*-=// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file describes Mips16 instructions. 11 // 12 //===----------------------------------------------------------------------===// 13 // 14 // 15 // Mips Address 16 // 17 def addr16 : ComplexPattern<iPTR, 2, "selectAddr16", [frameindex]>; 18 def addr16sp : ComplexPattern<iPTR, 2, "selectAddr16SP", [frameindex]>; 19 20 // 21 // Address operand 22 def mem16 : Operand<i32> { 23 let PrintMethod = "printMemOperand"; 24 let MIOperandInfo = (ops CPU16Regs, simm16); 25 let EncoderMethod = "getMemEncoding"; 26 } 27 28 def mem16sp : Operand<i32> { 29 let PrintMethod = "printMemOperand"; 30 // This should be CPUSPReg but the MIPS16 subtarget isn't good enough at 31 // keeping the sp-relative load and the other varieties separate at the 32 // moment. This lie fixes the problem sufficiently well to fix the errors 33 // emitted by -verify-machineinstrs and the output ends up correct as long 34 // as we use an external assembler (which is already a requirement for MIPS16 35 // for several other reasons). 36 let MIOperandInfo = (ops CPU16RegsPlusSP, simm16); 37 let EncoderMethod = "getMemEncoding"; 38 } 39 40 def mem16_ea : Operand<i32> { 41 let PrintMethod = "printMemOperandEA"; 42 let MIOperandInfo = (ops CPU16RegsPlusSP, simm16); 43 let EncoderMethod = "getMemEncoding"; 44 } 45 46 def pcrel16 : Operand<i32>; 47 48 // 49 // I-type instruction format 50 // 51 // this is only used by bimm. the actual assembly value is a 12 bit signed 52 // number 53 // 54 class FI16_ins<bits<5> op, string asmstr, InstrItinClass itin>: 55 FI16<op, (outs), (ins brtarget:$imm16), 56 !strconcat(asmstr, "\t$imm16 # 16 bit inst"), [], itin>; 57 58 // 59 // 60 // I8 instruction format 61 // 62 63 class FI816_ins_base<bits<3> _func, string asmstr, 64 string asmstr2, InstrItinClass itin>: 65 FI816<_func, (outs), (ins simm16:$imm), !strconcat(asmstr, asmstr2), 66 [], itin>; 67 68 class FI816_ins<bits<3> _func, string asmstr, 69 InstrItinClass itin>: 70 FI816_ins_base<_func, asmstr, "\t$imm # 16 bit inst", itin>; 71 72 class FI816_SP_ins<bits<3> _func, string asmstr, 73 InstrItinClass itin>: 74 FI816_ins_base<_func, asmstr, "\t$$sp, $imm # 16 bit inst", itin>; 75 76 // 77 // RI instruction format 78 // 79 80 81 class FRI16_ins_base<bits<5> op, string asmstr, string asmstr2, 82 InstrItinClass itin>: 83 FRI16<op, (outs CPU16Regs:$rx), (ins simm16:$imm), 84 !strconcat(asmstr, asmstr2), [], itin>; 85 86 class FRI16_ins<bits<5> op, string asmstr, 87 InstrItinClass itin>: 88 FRI16_ins_base<op, asmstr, "\t$rx, $imm \t# 16 bit inst", itin>; 89 90 class FRI16_TCP_ins<bits<5> _op, string asmstr, 91 InstrItinClass itin>: 92 FRI16<_op, (outs CPU16Regs:$rx), (ins pcrel16:$imm, i32imm:$size), 93 !strconcat(asmstr, "\t$rx, $imm\t# 16 bit inst"), [], itin>; 94 95 class FRI16R_ins_base<bits<5> op, string asmstr, string asmstr2, 96 InstrItinClass itin>: 97 FRI16<op, (outs), (ins CPU16Regs:$rx, simm16:$imm), 98 !strconcat(asmstr, asmstr2), [], itin>; 99 100 class FRI16R_ins<bits<5> op, string asmstr, 101 InstrItinClass itin>: 102 FRI16R_ins_base<op, asmstr, "\t$rx, $imm \t# 16 bit inst", itin>; 103 104 class F2RI16_ins<bits<5> _op, string asmstr, 105 InstrItinClass itin>: 106 FRI16<_op, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_, simm16:$imm), 107 !strconcat(asmstr, "\t$rx, $imm\t# 16 bit inst"), [], itin> { 108 let Constraints = "$rx_ = $rx"; 109 } 110 111 class FRI16_B_ins<bits<5> _op, string asmstr, 112 InstrItinClass itin>: 113 FRI16<_op, (outs), (ins CPU16Regs:$rx, brtarget:$imm), 114 !strconcat(asmstr, "\t$rx, $imm # 16 bit inst"), [], itin>; 115 // 116 // Compare a register and immediate and place result in CC 117 // Implicit use of T8 118 // 119 // EXT-CCRR Instruction format 120 // 121 class FEXT_CCRXI16_ins<string asmstr>: 122 MipsPseudo16<(outs CPU16Regs:$cc), (ins CPU16Regs:$rx, simm16:$imm), 123 !strconcat(asmstr, "\t$rx, $imm\n\tmove\t$cc, $$t8"), []> { 124 let isCodeGenOnly=1; 125 let usesCustomInserter = 1; 126 } 127 128 // JAL and JALX instruction format 129 // 130 class FJAL16_ins<bits<1> _X, string asmstr, 131 InstrItinClass itin>: 132 FJAL16<_X, (outs), (ins uimm26:$imm), 133 !strconcat(asmstr, "\t$imm\n\tnop"),[], 134 itin> { 135 let isCodeGenOnly=1; 136 let Size=6; 137 } 138 139 class FJALB16_ins<bits<1> _X, string asmstr, 140 InstrItinClass itin>: 141 FJAL16<_X, (outs), (ins uimm26:$imm), 142 !strconcat(asmstr, "\t$imm\t# branch\n\tnop"),[], 143 itin> { 144 let isCodeGenOnly=1; 145 let Size=6; 146 } 147 148 // 149 // EXT-I instruction format 150 // 151 class FEXT_I16_ins<bits<5> eop, string asmstr, InstrItinClass itin> : 152 FEXT_I16<eop, (outs), (ins brtarget:$imm16), 153 !strconcat(asmstr, "\t$imm16"),[], itin>; 154 155 // 156 // EXT-I8 instruction format 157 // 158 159 class FEXT_I816_ins_base<bits<3> _func, string asmstr, 160 string asmstr2, InstrItinClass itin>: 161 FEXT_I816<_func, (outs), (ins simm16:$imm), !strconcat(asmstr, asmstr2), 162 [], itin>; 163 164 class FEXT_I816_ins<bits<3> _func, string asmstr, 165 InstrItinClass itin>: 166 FEXT_I816_ins_base<_func, asmstr, "\t$imm", itin>; 167 168 class FEXT_I816_SP_ins<bits<3> _func, string asmstr, 169 InstrItinClass itin>: 170 FEXT_I816_ins_base<_func, asmstr, "\t$$sp, $imm", itin>; 171 172 // 173 // Assembler formats in alphabetical order. 174 // Natural and pseudos are mixed together. 175 // 176 // Compare two registers and place result in CC 177 // Implicit use of T8 178 // 179 // CC-RR Instruction format 180 // 181 class FCCRR16_ins<string asmstr> : 182 MipsPseudo16<(outs CPU16Regs:$cc), (ins CPU16Regs:$rx, CPU16Regs:$ry), 183 !strconcat(asmstr, "\t$rx, $ry\n\tmove\t$cc, $$t8"), []> { 184 let isCodeGenOnly=1; 185 let usesCustomInserter = 1; 186 } 187 188 // 189 // EXT-RI instruction format 190 // 191 192 class FEXT_RI16_ins_base<bits<5> _op, string asmstr, string asmstr2, 193 InstrItinClass itin>: 194 FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins simm16:$imm), 195 !strconcat(asmstr, asmstr2), [], itin>; 196 197 class FEXT_RI16_ins<bits<5> _op, string asmstr, 198 InstrItinClass itin>: 199 FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $imm", itin>; 200 201 class FEXT_RI16R_ins_base<bits<5> _op, string asmstr, string asmstr2, 202 InstrItinClass itin>: 203 FEXT_RI16<_op, (outs ), (ins CPU16Regs:$rx, simm16:$imm), 204 !strconcat(asmstr, asmstr2), [], itin>; 205 206 class FEXT_RI16R_ins<bits<5> _op, string asmstr, 207 InstrItinClass itin>: 208 FEXT_RI16R_ins_base<_op, asmstr, "\t$rx, $imm", itin>; 209 210 class FEXT_RI16_PC_ins<bits<5> _op, string asmstr, InstrItinClass itin>: 211 FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $$pc, $imm", itin>; 212 213 class FEXT_RI16_B_ins<bits<5> _op, string asmstr, 214 InstrItinClass itin>: 215 FEXT_RI16<_op, (outs), (ins CPU16Regs:$rx, brtarget:$imm), 216 !strconcat(asmstr, "\t$rx, $imm"), [], itin>; 217 218 class FEXT_RI16_TCP_ins<bits<5> _op, string asmstr, 219 InstrItinClass itin>: 220 FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins pcrel16:$imm, i32imm:$size), 221 !strconcat(asmstr, "\t$rx, $imm"), [], itin>; 222 223 class FEXT_2RI16_ins<bits<5> _op, string asmstr, 224 InstrItinClass itin>: 225 FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_, simm16:$imm), 226 !strconcat(asmstr, "\t$rx, $imm"), [], itin> { 227 let Constraints = "$rx_ = $rx"; 228 } 229 230 // 231 // EXT-RRI instruction format 232 // 233 234 class FEXT_RRI16_mem_ins<bits<5> op, string asmstr, Operand MemOpnd, 235 InstrItinClass itin>: 236 FEXT_RRI16<op, (outs CPU16Regs:$ry), (ins MemOpnd:$addr), 237 !strconcat(asmstr, "\t$ry, $addr"), [], itin>; 238 239 class FEXT_RRI16_mem2_ins<bits<5> op, string asmstr, Operand MemOpnd, 240 InstrItinClass itin>: 241 FEXT_RRI16<op, (outs ), (ins CPU16Regs:$ry, MemOpnd:$addr), 242 !strconcat(asmstr, "\t$ry, $addr"), [], itin>; 243 244 // 245 // 246 // EXT-RRI-A instruction format 247 // 248 249 class FEXT_RRI_A16_mem_ins<bits<1> op, string asmstr, Operand MemOpnd, 250 InstrItinClass itin>: 251 FEXT_RRI_A16<op, (outs CPU16Regs:$ry), (ins MemOpnd:$addr), 252 !strconcat(asmstr, "\t$ry, $addr"), [], itin>; 253 254 // 255 // EXT-SHIFT instruction format 256 // 257 class FEXT_SHIFT16_ins<bits<2> _f, string asmstr, InstrItinClass itin>: 258 FEXT_SHIFT16<_f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry, uimm5:$sa), 259 !strconcat(asmstr, "\t$rx, $ry, $sa"), [], itin>; 260 261 // 262 // EXT-T8I8 263 // 264 class FEXT_T8I816_ins<string asmstr, string asmstr2>: 265 MipsPseudo16<(outs), 266 (ins CPU16Regs:$rx, CPU16Regs:$ry, brtarget:$imm), 267 !strconcat(asmstr2, !strconcat("\t$rx, $ry\n\t", 268 !strconcat(asmstr, "\t$imm"))),[]> { 269 let isCodeGenOnly=1; 270 let usesCustomInserter = 1; 271 } 272 273 // 274 // EXT-T8I8I 275 // 276 class FEXT_T8I8I16_ins<string asmstr, string asmstr2>: 277 MipsPseudo16<(outs), 278 (ins CPU16Regs:$rx, simm16:$imm, brtarget:$targ), 279 !strconcat(asmstr2, !strconcat("\t$rx, $imm\n\t", 280 !strconcat(asmstr, "\t$targ"))), []> { 281 let isCodeGenOnly=1; 282 let usesCustomInserter = 1; 283 } 284 // 285 286 287 // 288 // I8_MOVR32 instruction format (used only by the MOVR32 instructio 289 // 290 class FI8_MOVR3216_ins<string asmstr, InstrItinClass itin>: 291 FI8_MOVR3216<(outs CPU16Regs:$rz), (ins GPR32:$r32), 292 !strconcat(asmstr, "\t$rz, $r32"), [], itin>; 293 294 // 295 // I8_MOV32R instruction format (used only by MOV32R instruction) 296 // 297 298 class FI8_MOV32R16_ins<string asmstr, InstrItinClass itin>: 299 FI8_MOV32R16<(outs GPR32:$r32), (ins CPU16Regs:$rz), 300 !strconcat(asmstr, "\t$r32, $rz"), [], itin>; 301 302 // 303 // This are pseudo formats for multiply 304 // This first one can be changed to non-pseudo now. 305 // 306 // MULT 307 // 308 class FMULT16_ins<string asmstr, InstrItinClass itin> : 309 MipsPseudo16<(outs), (ins CPU16Regs:$rx, CPU16Regs:$ry), 310 !strconcat(asmstr, "\t$rx, $ry"), []>; 311 312 // 313 // MULT-LO 314 // 315 class FMULT16_LO_ins<string asmstr, InstrItinClass itin> : 316 MipsPseudo16<(outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry), 317 !strconcat(asmstr, "\t$rx, $ry\n\tmflo\t$rz"), []> { 318 let isCodeGenOnly=1; 319 } 320 321 // 322 // RR-type instruction format 323 // 324 325 class FRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> : 326 FRR16<f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry), 327 !strconcat(asmstr, "\t$rx, $ry"), [], itin> { 328 } 329 330 class FRRBreakNull16_ins<string asmstr, InstrItinClass itin> : 331 FRRBreak16<(outs), (ins), asmstr, [], itin> { 332 let Code=0; 333 } 334 335 class FRR16R_ins<bits<5> f, string asmstr, InstrItinClass itin> : 336 FRR16<f, (outs), (ins CPU16Regs:$rx, CPU16Regs:$ry), 337 !strconcat(asmstr, "\t$rx, $ry"), [], itin> { 338 } 339 340 class FRRTR16_ins<string asmstr> : 341 MipsPseudo16<(outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry), 342 !strconcat(asmstr, "\t$rx, $ry\n\tmove\t$rz, $$t8"), []> ; 343 344 // 345 // maybe refactor but need a $zero as a dummy first parameter 346 // 347 class FRR16_div_ins<bits<5> f, string asmstr, InstrItinClass itin> : 348 FRR16<f, (outs ), (ins CPU16Regs:$rx, CPU16Regs:$ry), 349 !strconcat(asmstr, "\t$$zero, $rx, $ry"), [], itin> ; 350 351 class FUnaryRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> : 352 FRR16<f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry), 353 !strconcat(asmstr, "\t$rx, $ry"), [], itin> ; 354 355 356 class FRR16_M_ins<bits<5> f, string asmstr, 357 InstrItinClass itin> : 358 FRR16<f, (outs CPU16Regs:$rx), (ins), 359 !strconcat(asmstr, "\t$rx"), [], itin>; 360 361 class FRxRxRy16_ins<bits<5> f, string asmstr, 362 InstrItinClass itin> : 363 FRR16<f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry), 364 !strconcat(asmstr, "\t$rz, $ry"), 365 [], itin> { 366 let Constraints = "$rx = $rz"; 367 } 368 369 let rx=0 in 370 class FRR16_JALRC_RA_only_ins<bits<1> nd_, bits<1> l_, 371 string asmstr, InstrItinClass itin>: 372 FRR16_JALRC<nd_, l_, 1, (outs), (ins), !strconcat(asmstr, "\t $$ra"), 373 [], itin> ; 374 375 376 class FRR16_JALRC_ins<bits<1> nd, bits<1> l, bits<1> ra, 377 string asmstr, InstrItinClass itin>: 378 FRR16_JALRC<nd, l, ra, (outs), (ins CPU16Regs:$rx), 379 !strconcat(asmstr, "\t $rx"), [], itin> ; 380 381 class FRR_SF16_ins 382 <bits<5> _funct, bits<3> _subfunc, 383 string asmstr, InstrItinClass itin>: 384 FRR_SF16<_funct, _subfunc, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_), 385 !strconcat(asmstr, "\t $rx"), 386 [], itin> { 387 let Constraints = "$rx_ = $rx"; 388 } 389 // 390 // RRR-type instruction format 391 // 392 393 class FRRR16_ins<bits<2> _f, string asmstr, InstrItinClass itin> : 394 FRRR16<_f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry), 395 !strconcat(asmstr, "\t$rz, $rx, $ry"), [], itin>; 396 397 // 398 // These Sel patterns support the generation of conditional move 399 // pseudo instructions. 400 // 401 // The nomenclature uses the components making up the pseudo and may 402 // be a bit counter intuitive when compared with the end result we seek. 403 // For example using a bqez in the example directly below results in the 404 // conditional move being done if the tested register is not zero. 405 // I considered in easier to check by keeping the pseudo consistent with 406 // it's components but it could have been done differently. 407 // 408 // The simplest case is when can test and operand directly and do the 409 // conditional move based on a simple mips16 conditional 410 // branch instruction. 411 // for example: 412 // if $op == beqz or bnez: 413 // 414 // $op1 $rt, .+4 415 // move $rd, $rs 416 // 417 // if $op == beqz, then if $rt != 0, then the conditional assignment 418 // $rd = $rs is done. 419 420 // if $op == bnez, then if $rt == 0, then the conditional assignment 421 // $rd = $rs is done. 422 // 423 // So this pseudo class only has one operand, i.e. op 424 // 425 class Sel<string op>: 426 MipsPseudo16<(outs CPU16Regs:$rd_), (ins CPU16Regs:$rd, CPU16Regs:$rs, 427 CPU16Regs:$rt), 428 !strconcat(op, "\t$rt, .+4\n\t\n\tmove $rd, $rs"), []> { 429 //let isCodeGenOnly=1; 430 let Constraints = "$rd = $rd_"; 431 let usesCustomInserter = 1; 432 } 433 434 // 435 // The next two instruction classes allow for an operand which tests 436 // two operands and returns a value in register T8 and 437 //then does a conditional branch based on the value of T8 438 // 439 440 // op2 can be cmpi or slti/sltiu 441 // op1 can bteqz or btnez 442 // the operands for op2 are a register and a signed constant 443 // 444 // $op2 $t, $imm ;test register t and branch conditionally 445 // $op1 .+4 ;op1 is a conditional branch 446 // move $rd, $rs 447 // 448 // 449 class SeliT<string op1, string op2>: 450 MipsPseudo16<(outs CPU16Regs:$rd_), (ins CPU16Regs:$rd, CPU16Regs:$rs, 451 CPU16Regs:$rl, simm16:$imm), 452 !strconcat(op2, 453 !strconcat("\t$rl, $imm\n\t", 454 !strconcat(op1, "\t.+4\n\tmove $rd, $rs"))), []> { 455 let isCodeGenOnly=1; 456 let Constraints = "$rd = $rd_"; 457 let usesCustomInserter = 1; 458 } 459 460 // 461 // op2 can be cmp or slt/sltu 462 // op1 can be bteqz or btnez 463 // the operands for op2 are two registers 464 // op1 is a conditional branch 465 // 466 // 467 // $op2 $rl, $rr ;test registers rl,rr 468 // $op1 .+4 ;op2 is a conditional branch 469 // move $rd, $rs 470 // 471 // 472 class SelT<string op1, string op2>: 473 MipsPseudo16<(outs CPU16Regs:$rd_), 474 (ins CPU16Regs:$rd, CPU16Regs:$rs, 475 CPU16Regs:$rl, CPU16Regs:$rr), 476 !strconcat(op2, 477 !strconcat("\t$rl, $rr\n\t", 478 !strconcat(op1, "\t.+4\n\tmove $rd, $rs"))), []> { 479 let isCodeGenOnly=1; 480 let Constraints = "$rd = $rd_"; 481 let usesCustomInserter = 1; 482 } 483 484 // 485 // 32 bit constant 486 // 487 def Constant32: 488 MipsPseudo16<(outs), (ins simm32:$imm), "\t.word $imm", []>; 489 490 def LwConstant32: 491 MipsPseudo16<(outs CPU16Regs:$rx), (ins simm32:$imm, simm32:$constid), 492 "lw\t$rx, 1f\n\tb\t2f\n\t.align\t2\n1: \t.word\t$imm\n2:", []>; 493 494 495 // 496 // Some general instruction class info 497 // 498 // 499 500 class ArithLogic16Defs<bit isCom=0> { 501 bits<5> shamt = 0; 502 bit isCommutable = isCom; 503 bit isReMaterializable = 1; 504 bit hasSideEffects = 0; 505 } 506 507 class branch16 { 508 bit isBranch = 1; 509 bit isTerminator = 1; 510 bit isBarrier = 1; 511 } 512 513 class cbranch16 { 514 bit isBranch = 1; 515 bit isTerminator = 1; 516 } 517 518 class MayLoad { 519 bit mayLoad = 1; 520 } 521 522 class MayStore { 523 bit mayStore = 1; 524 } 525 // 526 527 528 // Format: ADDIU rx, immediate MIPS16e 529 // Purpose: Add Immediate Unsigned Word (2-Operand, Extended) 530 // To add a constant to a 32-bit integer. 531 // 532 def AddiuRxImmX16: FEXT_RI16_ins<0b01001, "addiu", IIM16Alu>; 533 534 def AddiuRxRxImm16: F2RI16_ins<0b01001, "addiu", IIM16Alu>, 535 ArithLogic16Defs<0> { 536 let AddedComplexity = 5; 537 } 538 def AddiuRxRxImmX16: FEXT_2RI16_ins<0b01001, "addiu", IIM16Alu>, 539 ArithLogic16Defs<0> { 540 let isCodeGenOnly = 1; 541 } 542 543 def AddiuRxRyOffMemX16: 544 FEXT_RRI_A16_mem_ins<0, "addiu", mem16_ea, IIM16Alu>; 545 546 // 547 548 // Format: ADDIU rx, pc, immediate MIPS16e 549 // Purpose: Add Immediate Unsigned Word (3-Operand, PC-Relative, Extended) 550 // To add a constant to the program counter. 551 // 552 def AddiuRxPcImmX16: FEXT_RI16_PC_ins<0b00001, "addiu", IIM16Alu>; 553 554 // 555 // Format: ADDIU sp, immediate MIPS16e 556 // Purpose: Add Immediate Unsigned Word (2-Operand, SP-Relative, Extended) 557 // To add a constant to the stack pointer. 558 // 559 def AddiuSpImm16 560 : FI816_SP_ins<0b011, "addiu", IIM16Alu> { 561 let Defs = [SP]; 562 let Uses = [SP]; 563 let AddedComplexity = 5; 564 } 565 566 def AddiuSpImmX16 567 : FEXT_I816_SP_ins<0b011, "addiu", IIM16Alu> { 568 let Defs = [SP]; 569 let Uses = [SP]; 570 } 571 572 // 573 // Format: ADDU rz, rx, ry MIPS16e 574 // Purpose: Add Unsigned Word (3-Operand) 575 // To add 32-bit integers. 576 // 577 578 def AdduRxRyRz16: FRRR16_ins<01, "addu", IIM16Alu>, ArithLogic16Defs<1>; 579 580 // 581 // Format: AND rx, ry MIPS16e 582 // Purpose: AND 583 // To do a bitwise logical AND. 584 585 def AndRxRxRy16: FRxRxRy16_ins<0b01100, "and", IIM16Alu>, ArithLogic16Defs<1>; 586 587 588 // 589 // Format: BEQZ rx, offset MIPS16e 590 // Purpose: Branch on Equal to Zero 591 // To test a GPR then do a PC-relative conditional branch. 592 // 593 def BeqzRxImm16: FRI16_B_ins<0b00100, "beqz", IIM16Alu>, cbranch16; 594 595 596 // 597 // Format: BEQZ rx, offset MIPS16e 598 // Purpose: Branch on Equal to Zero (Extended) 599 // To test a GPR then do a PC-relative conditional branch. 600 // 601 def BeqzRxImmX16: FEXT_RI16_B_ins<0b00100, "beqz", IIM16Alu>, cbranch16; 602 603 // 604 // Format: B offset MIPS16e 605 // Purpose: Unconditional Branch (Extended) 606 // To do an unconditional PC-relative branch. 607 // 608 609 def Bimm16: FI16_ins<0b00010, "b", IIM16Alu>, branch16; 610 611 // Format: B offset MIPS16e 612 // Purpose: Unconditional Branch 613 // To do an unconditional PC-relative branch. 614 // 615 def BimmX16: FEXT_I16_ins<0b00010, "b", IIM16Alu>, branch16; 616 617 // 618 // Format: BNEZ rx, offset MIPS16e 619 // Purpose: Branch on Not Equal to Zero 620 // To test a GPR then do a PC-relative conditional branch. 621 // 622 def BnezRxImm16: FRI16_B_ins<0b00101, "bnez", IIM16Alu>, cbranch16; 623 624 // 625 // Format: BNEZ rx, offset MIPS16e 626 // Purpose: Branch on Not Equal to Zero (Extended) 627 // To test a GPR then do a PC-relative conditional branch. 628 // 629 def BnezRxImmX16: FEXT_RI16_B_ins<0b00101, "bnez", IIM16Alu>, cbranch16; 630 631 632 // 633 //Format: BREAK immediate 634 // Purpose: Breakpoint 635 // To cause a Breakpoint exception. 636 637 def Break16: FRRBreakNull16_ins<"break 0", IIM16Alu>; 638 // 639 // Format: BTEQZ offset MIPS16e 640 // Purpose: Branch on T Equal to Zero (Extended) 641 // To test special register T then do a PC-relative conditional branch. 642 // 643 def Bteqz16: FI816_ins<0b000, "bteqz", IIM16Alu>, cbranch16 { 644 let Uses = [T8]; 645 } 646 647 def BteqzX16: FEXT_I816_ins<0b000, "bteqz", IIM16Alu>, cbranch16 { 648 let Uses = [T8]; 649 } 650 651 def BteqzT8CmpX16: FEXT_T8I816_ins<"bteqz", "cmp">, cbranch16; 652 653 def BteqzT8CmpiX16: FEXT_T8I8I16_ins<"bteqz", "cmpi">, 654 cbranch16; 655 656 def BteqzT8SltX16: FEXT_T8I816_ins<"bteqz", "slt">, cbranch16; 657 658 def BteqzT8SltuX16: FEXT_T8I816_ins<"bteqz", "sltu">, cbranch16; 659 660 def BteqzT8SltiX16: FEXT_T8I8I16_ins<"bteqz", "slti">, cbranch16; 661 662 def BteqzT8SltiuX16: FEXT_T8I8I16_ins<"bteqz", "sltiu">, 663 cbranch16; 664 665 // 666 // Format: BTNEZ offset MIPS16e 667 // Purpose: Branch on T Not Equal to Zero (Extended) 668 // To test special register T then do a PC-relative conditional branch. 669 // 670 671 def Btnez16: FI816_ins<0b001, "btnez", IIM16Alu>, cbranch16 { 672 let Uses = [T8]; 673 } 674 675 def BtnezX16: FEXT_I816_ins<0b001, "btnez", IIM16Alu> ,cbranch16 { 676 let Uses = [T8]; 677 } 678 679 def BtnezT8CmpX16: FEXT_T8I816_ins<"btnez", "cmp">, cbranch16; 680 681 def BtnezT8CmpiX16: FEXT_T8I8I16_ins<"btnez", "cmpi">, cbranch16; 682 683 def BtnezT8SltX16: FEXT_T8I816_ins<"btnez", "slt">, cbranch16; 684 685 def BtnezT8SltuX16: FEXT_T8I816_ins<"btnez", "sltu">, cbranch16; 686 687 def BtnezT8SltiX16: FEXT_T8I8I16_ins<"btnez", "slti">, cbranch16; 688 689 def BtnezT8SltiuX16: FEXT_T8I8I16_ins<"btnez", "sltiu">, 690 cbranch16; 691 692 // 693 // Format: CMP rx, ry MIPS16e 694 // Purpose: Compare 695 // To compare the contents of two GPRs. 696 // 697 def CmpRxRy16: FRR16R_ins<0b01010, "cmp", IIM16Alu> { 698 let Defs = [T8]; 699 } 700 701 // 702 // Format: CMPI rx, immediate MIPS16e 703 // Purpose: Compare Immediate 704 // To compare a constant with the contents of a GPR. 705 // 706 def CmpiRxImm16: FRI16R_ins<0b01110, "cmpi", IIM16Alu> { 707 let Defs = [T8]; 708 } 709 710 // 711 // Format: CMPI rx, immediate MIPS16e 712 // Purpose: Compare Immediate (Extended) 713 // To compare a constant with the contents of a GPR. 714 // 715 def CmpiRxImmX16: FEXT_RI16R_ins<0b01110, "cmpi", IIM16Alu> { 716 let Defs = [T8]; 717 } 718 719 720 // 721 // Format: DIV rx, ry MIPS16e 722 // Purpose: Divide Word 723 // To divide 32-bit signed integers. 724 // 725 def DivRxRy16: FRR16_div_ins<0b11010, "div", IIM16Alu> { 726 let Defs = [HI0, LO0]; 727 } 728 729 // 730 // Format: DIVU rx, ry MIPS16e 731 // Purpose: Divide Unsigned Word 732 // To divide 32-bit unsigned integers. 733 // 734 def DivuRxRy16: FRR16_div_ins<0b11011, "divu", IIM16Alu> { 735 let Defs = [HI0, LO0]; 736 } 737 // 738 // Format: JAL target MIPS16e 739 // Purpose: Jump and Link 740 // To execute a procedure call within the current 256 MB-aligned 741 // region and preserve the current ISA. 742 // 743 744 def Jal16 : FJAL16_ins<0b0, "jal", IIM16Alu> { 745 let hasDelaySlot = 0; // not true, but we add the nop for now 746 let isCall=1; 747 let Defs = [RA]; 748 } 749 750 def JalB16 : FJALB16_ins<0b0, "jal", IIM16Alu>, branch16 { 751 let hasDelaySlot = 0; // not true, but we add the nop for now 752 let isBranch=1; 753 let Defs = [RA]; 754 } 755 756 // 757 // Format: JR ra MIPS16e 758 // Purpose: Jump Register Through Register ra 759 // To execute a branch to the instruction address in the return 760 // address register. 761 // 762 763 def JrRa16: FRR16_JALRC_RA_only_ins<0, 0, "jr", IIM16Alu> { 764 let isBranch = 1; 765 let isIndirectBranch = 1; 766 let hasDelaySlot = 1; 767 let isTerminator=1; 768 let isBarrier=1; 769 } 770 771 def JrcRa16: FRR16_JALRC_RA_only_ins<1, 1, "jrc", IIM16Alu> { 772 let isBranch = 1; 773 let isIndirectBranch = 1; 774 let isTerminator=1; 775 let isBarrier=1; 776 } 777 778 def JrcRx16: FRR16_JALRC_ins<1, 1, 0, "jrc", IIM16Alu> { 779 let isBranch = 1; 780 let isIndirectBranch = 1; 781 let isTerminator=1; 782 let isBarrier=1; 783 } 784 // 785 // Format: LB ry, offset(rx) MIPS16e 786 // Purpose: Load Byte (Extended) 787 // To load a byte from memory as a signed value. 788 // 789 def LbRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lb", mem16, II_LB>, MayLoad{ 790 let isCodeGenOnly = 1; 791 } 792 793 // 794 // Format: LBU ry, offset(rx) MIPS16e 795 // Purpose: Load Byte Unsigned (Extended) 796 // To load a byte from memory as a unsigned value. 797 // 798 def LbuRxRyOffMemX16: 799 FEXT_RRI16_mem_ins<0b10100, "lbu", mem16, II_LBU>, MayLoad { 800 let isCodeGenOnly = 1; 801 } 802 803 // 804 // Format: LH ry, offset(rx) MIPS16e 805 // Purpose: Load Halfword signed (Extended) 806 // To load a halfword from memory as a signed value. 807 // 808 def LhRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10100, "lh", mem16, II_LH>, MayLoad{ 809 let isCodeGenOnly = 1; 810 } 811 812 // 813 // Format: LHU ry, offset(rx) MIPS16e 814 // Purpose: Load Halfword unsigned (Extended) 815 // To load a halfword from memory as an unsigned value. 816 // 817 def LhuRxRyOffMemX16: 818 FEXT_RRI16_mem_ins<0b10100, "lhu", mem16, II_LHU>, MayLoad { 819 let isCodeGenOnly = 1; 820 } 821 822 // 823 // Format: LI rx, immediate MIPS16e 824 // Purpose: Load Immediate 825 // To load a constant into a GPR. 826 // 827 def LiRxImm16: FRI16_ins<0b01101, "li", IIM16Alu>; 828 829 // 830 // Format: LI rx, immediate MIPS16e 831 // Purpose: Load Immediate (Extended) 832 // To load a constant into a GPR. 833 // 834 def LiRxImmX16: FEXT_RI16_ins<0b01101, "li", IIM16Alu>; 835 836 def LiRxImmAlignX16: FEXT_RI16_ins<0b01101, ".align 2\n\tli", IIM16Alu> { 837 let isCodeGenOnly = 1; 838 } 839 840 // 841 // Format: LW ry, offset(rx) MIPS16e 842 // Purpose: Load Word (Extended) 843 // To load a word from memory as a signed value. 844 // 845 def LwRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lw", mem16, II_LW>, MayLoad{ 846 let isCodeGenOnly = 1; 847 } 848 849 // Format: LW rx, offset(sp) MIPS16e 850 // Purpose: Load Word (SP-Relative, Extended) 851 // To load an SP-relative word from memory as a signed value. 852 // 853 def LwRxSpImmX16: FEXT_RRI16_mem_ins<0b10010, "lw", mem16sp, II_LW>, MayLoad; 854 855 def LwRxPcTcp16: FRI16_TCP_ins<0b10110, "lw", II_LW>, MayLoad; 856 857 def LwRxPcTcpX16: FEXT_RI16_TCP_ins<0b10110, "lw", II_LW>, MayLoad; 858 // 859 // Format: MOVE r32, rz MIPS16e 860 // Purpose: Move 861 // To move the contents of a GPR to a GPR. 862 // 863 def Move32R16: FI8_MOV32R16_ins<"move", IIM16Alu>; 864 865 // 866 // Format: MOVE ry, r32 MIPS16e 867 //Purpose: Move 868 // To move the contents of a GPR to a GPR. 869 // 870 def MoveR3216: FI8_MOVR3216_ins<"move", IIM16Alu>; 871 872 // 873 // Format: MFHI rx MIPS16e 874 // Purpose: Move From HI Register 875 // To copy the special purpose HI register to a GPR. 876 // 877 def Mfhi16: FRR16_M_ins<0b10000, "mfhi", IIM16Alu> { 878 let Uses = [HI0]; 879 let hasSideEffects = 0; 880 } 881 882 // 883 // Format: MFLO rx MIPS16e 884 // Purpose: Move From LO Register 885 // To copy the special purpose LO register to a GPR. 886 // 887 def Mflo16: FRR16_M_ins<0b10010, "mflo", IIM16Alu> { 888 let Uses = [LO0]; 889 let hasSideEffects = 0; 890 } 891 892 // 893 // Pseudo Instruction for mult 894 // 895 def MultRxRy16: FMULT16_ins<"mult", IIM16Alu> { 896 let isCommutable = 1; 897 let hasSideEffects = 0; 898 let Defs = [HI0, LO0]; 899 } 900 901 def MultuRxRy16: FMULT16_ins<"multu", IIM16Alu> { 902 let isCommutable = 1; 903 let hasSideEffects = 0; 904 let Defs = [HI0, LO0]; 905 } 906 907 // 908 // Format: MULT rx, ry MIPS16e 909 // Purpose: Multiply Word 910 // To multiply 32-bit signed integers. 911 // 912 def MultRxRyRz16: FMULT16_LO_ins<"mult", IIM16Alu> { 913 let isCommutable = 1; 914 let hasSideEffects = 0; 915 let Defs = [HI0, LO0]; 916 } 917 918 // 919 // Format: MULTU rx, ry MIPS16e 920 // Purpose: Multiply Unsigned Word 921 // To multiply 32-bit unsigned integers. 922 // 923 def MultuRxRyRz16: FMULT16_LO_ins<"multu", IIM16Alu> { 924 let isCommutable = 1; 925 let hasSideEffects = 0; 926 let Defs = [HI0, LO0]; 927 } 928 929 // 930 // Format: NEG rx, ry MIPS16e 931 // Purpose: Negate 932 // To negate an integer value. 933 // 934 def NegRxRy16: FUnaryRR16_ins<0b11101, "neg", IIM16Alu>; 935 936 // 937 // Format: NOT rx, ry MIPS16e 938 // Purpose: Not 939 // To complement an integer value 940 // 941 def NotRxRy16: FUnaryRR16_ins<0b01111, "not", IIM16Alu>; 942 943 // 944 // Format: OR rx, ry MIPS16e 945 // Purpose: Or 946 // To do a bitwise logical OR. 947 // 948 def OrRxRxRy16: FRxRxRy16_ins<0b01101, "or", IIM16Alu>, ArithLogic16Defs<1>; 949 950 // 951 // Format: RESTORE {ra,}{s0/s1/s0-1,}{framesize} 952 // (All args are optional) MIPS16e 953 // Purpose: Restore Registers and Deallocate Stack Frame 954 // To deallocate a stack frame before exit from a subroutine, 955 // restoring return address and static registers, and adjusting 956 // stack 957 // 958 959 def Restore16: 960 FI8_SVRS16<0b1, (outs), (ins variable_ops), 961 "", [], II_RESTORE >, MayLoad { 962 let isCodeGenOnly = 1; 963 let Defs = [SP]; 964 let Uses = [SP]; 965 } 966 967 968 def RestoreX16: 969 FI8_SVRS16<0b1, (outs), (ins variable_ops), 970 "", [], II_RESTORE >, MayLoad { 971 let isCodeGenOnly = 1; 972 let Defs = [SP]; 973 let Uses = [SP]; 974 } 975 976 // 977 // Format: SAVE {ra,}{s0/s1/s0-1,}{framesize} (All arguments are optional) 978 // MIPS16e 979 // Purpose: Save Registers and Set Up Stack Frame 980 // To set up a stack frame on entry to a subroutine, 981 // saving return address and static registers, and adjusting stack 982 // 983 def Save16: 984 FI8_SVRS16<0b1, (outs), (ins variable_ops), 985 "", [], II_SAVE >, MayStore { 986 let isCodeGenOnly = 1; 987 let Uses = [SP]; 988 let Defs = [SP]; 989 } 990 991 def SaveX16: 992 FI8_SVRS16<0b1, (outs), (ins variable_ops), 993 "", [], II_SAVE >, MayStore { 994 let isCodeGenOnly = 1; 995 let Uses = [SP]; 996 let Defs = [SP]; 997 } 998 // 999 // Format: SB ry, offset(rx) MIPS16e 1000 // Purpose: Store Byte (Extended) 1001 // To store a byte to memory. 1002 // 1003 def SbRxRyOffMemX16: 1004 FEXT_RRI16_mem2_ins<0b11000, "sb", mem16, II_SB>, MayStore; 1005 1006 // 1007 // Format: SEB rx MIPS16e 1008 // Purpose: Sign-Extend Byte 1009 // Sign-extend least significant byte in register rx. 1010 // 1011 def SebRx16 1012 : FRR_SF16_ins<0b10001, 0b100, "seb", IIM16Alu>; 1013 1014 // 1015 // Format: SEH rx MIPS16e 1016 // Purpose: Sign-Extend Halfword 1017 // Sign-extend least significant word in register rx. 1018 // 1019 def SehRx16 1020 : FRR_SF16_ins<0b10001, 0b101, "seh", IIM16Alu>; 1021 1022 // 1023 // The Sel(T) instructions are pseudos 1024 // T means that they use T8 implicitly. 1025 // 1026 // 1027 // Format: SelBeqZ rd, rs, rt 1028 // Purpose: if rt==0, do nothing 1029 // else rs = rt 1030 // 1031 def SelBeqZ: Sel<"beqz">; 1032 1033 // 1034 // Format: SelTBteqZCmp rd, rs, rl, rr 1035 // Purpose: b = Cmp rl, rr. 1036 // If b==0 then do nothing. 1037 // if b!=0 then rd = rs 1038 // 1039 def SelTBteqZCmp: SelT<"bteqz", "cmp">; 1040 1041 // 1042 // Format: SelTBteqZCmpi rd, rs, rl, rr 1043 // Purpose: b = Cmpi rl, imm. 1044 // If b==0 then do nothing. 1045 // if b!=0 then rd = rs 1046 // 1047 def SelTBteqZCmpi: SeliT<"bteqz", "cmpi">; 1048 1049 // 1050 // Format: SelTBteqZSlt rd, rs, rl, rr 1051 // Purpose: b = Slt rl, rr. 1052 // If b==0 then do nothing. 1053 // if b!=0 then rd = rs 1054 // 1055 def SelTBteqZSlt: SelT<"bteqz", "slt">; 1056 1057 // 1058 // Format: SelTBteqZSlti rd, rs, rl, rr 1059 // Purpose: b = Slti rl, imm. 1060 // If b==0 then do nothing. 1061 // if b!=0 then rd = rs 1062 // 1063 def SelTBteqZSlti: SeliT<"bteqz", "slti">; 1064 1065 // 1066 // Format: SelTBteqZSltu rd, rs, rl, rr 1067 // Purpose: b = Sltu rl, rr. 1068 // If b==0 then do nothing. 1069 // if b!=0 then rd = rs 1070 // 1071 def SelTBteqZSltu: SelT<"bteqz", "sltu">; 1072 1073 // 1074 // Format: SelTBteqZSltiu rd, rs, rl, rr 1075 // Purpose: b = Sltiu rl, imm. 1076 // If b==0 then do nothing. 1077 // if b!=0 then rd = rs 1078 // 1079 def SelTBteqZSltiu: SeliT<"bteqz", "sltiu">; 1080 1081 // 1082 // Format: SelBnez rd, rs, rt 1083 // Purpose: if rt!=0, do nothing 1084 // else rs = rt 1085 // 1086 def SelBneZ: Sel<"bnez">; 1087 1088 // 1089 // Format: SelTBtneZCmp rd, rs, rl, rr 1090 // Purpose: b = Cmp rl, rr. 1091 // If b!=0 then do nothing. 1092 // if b0=0 then rd = rs 1093 // 1094 def SelTBtneZCmp: SelT<"btnez", "cmp">; 1095 1096 // 1097 // Format: SelTBtnezCmpi rd, rs, rl, rr 1098 // Purpose: b = Cmpi rl, imm. 1099 // If b!=0 then do nothing. 1100 // if b==0 then rd = rs 1101 // 1102 def SelTBtneZCmpi: SeliT<"btnez", "cmpi">; 1103 1104 // 1105 // Format: SelTBtneZSlt rd, rs, rl, rr 1106 // Purpose: b = Slt rl, rr. 1107 // If b!=0 then do nothing. 1108 // if b==0 then rd = rs 1109 // 1110 def SelTBtneZSlt: SelT<"btnez", "slt">; 1111 1112 // 1113 // Format: SelTBtneZSlti rd, rs, rl, rr 1114 // Purpose: b = Slti rl, imm. 1115 // If b!=0 then do nothing. 1116 // if b==0 then rd = rs 1117 // 1118 def SelTBtneZSlti: SeliT<"btnez", "slti">; 1119 1120 // 1121 // Format: SelTBtneZSltu rd, rs, rl, rr 1122 // Purpose: b = Sltu rl, rr. 1123 // If b!=0 then do nothing. 1124 // if b==0 then rd = rs 1125 // 1126 def SelTBtneZSltu: SelT<"btnez", "sltu">; 1127 1128 // 1129 // Format: SelTBtneZSltiu rd, rs, rl, rr 1130 // Purpose: b = Slti rl, imm. 1131 // If b!=0 then do nothing. 1132 // if b==0 then rd = rs 1133 // 1134 def SelTBtneZSltiu: SeliT<"btnez", "sltiu">; 1135 // 1136 // 1137 // Format: SH ry, offset(rx) MIPS16e 1138 // Purpose: Store Halfword (Extended) 1139 // To store a halfword to memory. 1140 // 1141 def ShRxRyOffMemX16: 1142 FEXT_RRI16_mem2_ins<0b11001, "sh", mem16, II_SH>, MayStore; 1143 1144 // 1145 // Format: SLL rx, ry, sa MIPS16e 1146 // Purpose: Shift Word Left Logical (Extended) 1147 // To execute a left-shift of a word by a fixed number of bits-0 to 31 bits. 1148 // 1149 def SllX16: FEXT_SHIFT16_ins<0b00, "sll", IIM16Alu>; 1150 1151 // 1152 // Format: SLLV ry, rx MIPS16e 1153 // Purpose: Shift Word Left Logical Variable 1154 // To execute a left-shift of a word by a variable number of bits. 1155 // 1156 def SllvRxRy16 : FRxRxRy16_ins<0b00100, "sllv", IIM16Alu>; 1157 1158 // Format: SLTI rx, immediate MIPS16e 1159 // Purpose: Set on Less Than Immediate 1160 // To record the result of a less-than comparison with a constant. 1161 // 1162 // 1163 def SltiRxImm16: FRI16R_ins<0b01010, "slti", IIM16Alu> { 1164 let Defs = [T8]; 1165 } 1166 1167 // 1168 // Format: SLTI rx, immediate MIPS16e 1169 // Purpose: Set on Less Than Immediate (Extended) 1170 // To record the result of a less-than comparison with a constant. 1171 // 1172 // 1173 def SltiRxImmX16: FEXT_RI16R_ins<0b01010, "slti", IIM16Alu> { 1174 let Defs = [T8]; 1175 } 1176 1177 def SltiCCRxImmX16: FEXT_CCRXI16_ins<"slti">; 1178 1179 // Format: SLTIU rx, immediate MIPS16e 1180 // Purpose: Set on Less Than Immediate Unsigned 1181 // To record the result of a less-than comparison with a constant. 1182 // 1183 // 1184 def SltiuRxImm16: FRI16R_ins<0b01011, "sltiu", IIM16Alu> { 1185 let Defs = [T8]; 1186 } 1187 1188 // 1189 // Format: SLTI rx, immediate MIPS16e 1190 // Purpose: Set on Less Than Immediate Unsigned (Extended) 1191 // To record the result of a less-than comparison with a constant. 1192 // 1193 // 1194 def SltiuRxImmX16: FEXT_RI16R_ins<0b01011, "sltiu", IIM16Alu> { 1195 let Defs = [T8]; 1196 } 1197 // 1198 // Format: SLTIU rx, immediate MIPS16e 1199 // Purpose: Set on Less Than Immediate Unsigned (Extended) 1200 // To record the result of a less-than comparison with a constant. 1201 // 1202 def SltiuCCRxImmX16: FEXT_CCRXI16_ins<"sltiu">; 1203 1204 // 1205 // Format: SLT rx, ry MIPS16e 1206 // Purpose: Set on Less Than 1207 // To record the result of a less-than comparison. 1208 // 1209 def SltRxRy16: FRR16R_ins<0b00010, "slt", IIM16Alu>{ 1210 let Defs = [T8]; 1211 } 1212 1213 def SltCCRxRy16: FCCRR16_ins<"slt">; 1214 1215 // Format: SLTU rx, ry MIPS16e 1216 // Purpose: Set on Less Than Unsigned 1217 // To record the result of an unsigned less-than comparison. 1218 // 1219 def SltuRxRy16: FRR16R_ins<0b00011, "sltu", IIM16Alu>{ 1220 let Defs = [T8]; 1221 } 1222 1223 def SltuRxRyRz16: FRRTR16_ins<"sltu"> { 1224 let isCodeGenOnly=1; 1225 let Defs = [T8]; 1226 } 1227 1228 1229 def SltuCCRxRy16: FCCRR16_ins<"sltu">; 1230 // 1231 // Format: SRAV ry, rx MIPS16e 1232 // Purpose: Shift Word Right Arithmetic Variable 1233 // To execute an arithmetic right-shift of a word by a variable 1234 // number of bits. 1235 // 1236 def SravRxRy16: FRxRxRy16_ins<0b00111, "srav", IIM16Alu>; 1237 1238 1239 // 1240 // Format: SRA rx, ry, sa MIPS16e 1241 // Purpose: Shift Word Right Arithmetic (Extended) 1242 // To execute an arithmetic right-shift of a word by a fixed 1243 // number of bits-1 to 8 bits. 1244 // 1245 def SraX16: FEXT_SHIFT16_ins<0b11, "sra", IIM16Alu>; 1246 1247 1248 // 1249 // Format: SRLV ry, rx MIPS16e 1250 // Purpose: Shift Word Right Logical Variable 1251 // To execute a logical right-shift of a word by a variable 1252 // number of bits. 1253 // 1254 def SrlvRxRy16: FRxRxRy16_ins<0b00110, "srlv", IIM16Alu>; 1255 1256 1257 // 1258 // Format: SRL rx, ry, sa MIPS16e 1259 // Purpose: Shift Word Right Logical (Extended) 1260 // To execute a logical right-shift of a word by a fixed 1261 // number of bits-1 to 31 bits. 1262 // 1263 def SrlX16: FEXT_SHIFT16_ins<0b10, "srl", IIM16Alu>; 1264 1265 // 1266 // Format: SUBU rz, rx, ry MIPS16e 1267 // Purpose: Subtract Unsigned Word 1268 // To subtract 32-bit integers 1269 // 1270 def SubuRxRyRz16: FRRR16_ins<0b11, "subu", IIM16Alu>, ArithLogic16Defs<0>; 1271 1272 // 1273 // Format: SW ry, offset(rx) MIPS16e 1274 // Purpose: Store Word (Extended) 1275 // To store a word to memory. 1276 // 1277 def SwRxRyOffMemX16: FEXT_RRI16_mem2_ins<0b11011, "sw", mem16, II_SW>, MayStore; 1278 1279 // 1280 // Format: SW rx, offset(sp) MIPS16e 1281 // Purpose: Store Word rx (SP-Relative) 1282 // To store an SP-relative word to memory. 1283 // 1284 def SwRxSpImmX16: FEXT_RRI16_mem2_ins<0b11010, "sw", mem16sp, II_SW>, MayStore; 1285 1286 // 1287 // 1288 // Format: XOR rx, ry MIPS16e 1289 // Purpose: Xor 1290 // To do a bitwise logical XOR. 1291 // 1292 def XorRxRxRy16: FRxRxRy16_ins<0b01110, "xor", IIM16Alu>, ArithLogic16Defs<1>; 1293 1294 class Mips16Pat<dag pattern, dag result> : Pat<pattern, result> { 1295 let Predicates = [InMips16Mode]; 1296 } 1297 1298 // Unary Arith/Logic 1299 // 1300 class ArithLogicU_pat<PatFrag OpNode, Instruction I> : 1301 Mips16Pat<(OpNode CPU16Regs:$r), 1302 (I CPU16Regs:$r)>; 1303 1304 def: ArithLogicU_pat<not, NotRxRy16>; 1305 def: ArithLogicU_pat<ineg, NegRxRy16>; 1306 1307 class ArithLogic16_pat<SDNode OpNode, Instruction I> : 1308 Mips16Pat<(OpNode CPU16Regs:$l, CPU16Regs:$r), 1309 (I CPU16Regs:$l, CPU16Regs:$r)>; 1310 1311 def: ArithLogic16_pat<add, AdduRxRyRz16>; 1312 def: ArithLogic16_pat<and, AndRxRxRy16>; 1313 def: ArithLogic16_pat<mul, MultRxRyRz16>; 1314 def: ArithLogic16_pat<or, OrRxRxRy16>; 1315 def: ArithLogic16_pat<sub, SubuRxRyRz16>; 1316 def: ArithLogic16_pat<xor, XorRxRxRy16>; 1317 1318 // Arithmetic and logical instructions with 2 register operands. 1319 1320 class ArithLogicI16_pat<SDNode OpNode, PatFrag imm_type, Instruction I> : 1321 Mips16Pat<(OpNode CPU16Regs:$in, imm_type:$imm), 1322 (I CPU16Regs:$in, imm_type:$imm)>; 1323 1324 def: ArithLogicI16_pat<add, immSExt8, AddiuRxRxImm16>; 1325 def: ArithLogicI16_pat<add, immSExt16, AddiuRxRxImmX16>; 1326 def: ArithLogicI16_pat<shl, immZExt5, SllX16>; 1327 def: ArithLogicI16_pat<srl, immZExt5, SrlX16>; 1328 def: ArithLogicI16_pat<sra, immZExt5, SraX16>; 1329 1330 class shift_rotate_reg16_pat<SDNode OpNode, Instruction I> : 1331 Mips16Pat<(OpNode CPU16Regs:$r, CPU16Regs:$ra), 1332 (I CPU16Regs:$r, CPU16Regs:$ra)>; 1333 1334 def: shift_rotate_reg16_pat<shl, SllvRxRy16>; 1335 def: shift_rotate_reg16_pat<sra, SravRxRy16>; 1336 def: shift_rotate_reg16_pat<srl, SrlvRxRy16>; 1337 1338 class LoadM16_pat<PatFrag OpNode, Instruction I, ComplexPattern Addr> : 1339 Mips16Pat<(OpNode Addr:$addr), (I Addr:$addr)>; 1340 1341 def: LoadM16_pat<sextloadi8, LbRxRyOffMemX16, addr16>; 1342 def: LoadM16_pat<zextloadi8, LbuRxRyOffMemX16, addr16>; 1343 def: LoadM16_pat<sextloadi16, LhRxRyOffMemX16, addr16>; 1344 def: LoadM16_pat<zextloadi16, LhuRxRyOffMemX16, addr16>; 1345 def: LoadM16_pat<load, LwRxSpImmX16, addr16sp>; 1346 1347 class StoreM16_pat<PatFrag OpNode, Instruction I, ComplexPattern Addr> : 1348 Mips16Pat<(OpNode CPU16Regs:$r, Addr:$addr), (I CPU16Regs:$r, Addr:$addr)>; 1349 1350 def: StoreM16_pat<truncstorei8, SbRxRyOffMemX16, addr16>; 1351 def: StoreM16_pat<truncstorei16, ShRxRyOffMemX16, addr16>; 1352 def: StoreM16_pat<store, SwRxSpImmX16, addr16sp>; 1353 1354 // Unconditional branch 1355 class UncondBranch16_pat<SDNode OpNode, Instruction I>: 1356 Mips16Pat<(OpNode bb:$imm16), (I bb:$imm16)> { 1357 let Predicates = [InMips16Mode]; 1358 } 1359 1360 def : Mips16Pat<(MipsJmpLink (i32 tglobaladdr:$dst)), 1361 (Jal16 tglobaladdr:$dst)>; 1362 1363 def : Mips16Pat<(MipsJmpLink (i32 texternalsym:$dst)), 1364 (Jal16 texternalsym:$dst)>; 1365 1366 // Indirect branch 1367 def: Mips16Pat<(brind CPU16Regs:$rs), (JrcRx16 CPU16Regs:$rs)> { 1368 // Ensure that the addition of MIPS32r6/MIPS64r6 support does not change 1369 // MIPS16's behaviour. 1370 let AddedComplexity = 1; 1371 } 1372 1373 // Jump and Link (Call) 1374 let isCall=1, hasDelaySlot=0 in 1375 def JumpLinkReg16: 1376 FRR16_JALRC<0, 0, 0, (outs), (ins CPU16Regs:$rs), 1377 "jalrc \t$rs", [(MipsJmpLink CPU16Regs:$rs)], II_JALRC> { 1378 let Defs = [RA]; 1379 } 1380 1381 // Mips16 pseudos 1382 let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1, hasCtrlDep=1, 1383 hasExtraSrcRegAllocReq = 1 in 1384 def RetRA16 : MipsPseudo16<(outs), (ins), "", [(MipsRet)]>; 1385 1386 1387 // setcc patterns 1388 1389 class SetCC_R16<PatFrag cond_op, Instruction I>: 1390 Mips16Pat<(cond_op CPU16Regs:$rx, CPU16Regs:$ry), 1391 (I CPU16Regs:$rx, CPU16Regs:$ry)>; 1392 1393 class SetCC_I16<PatFrag cond_op, PatLeaf imm_type, Instruction I>: 1394 Mips16Pat<(cond_op CPU16Regs:$rx, imm_type:$imm16), 1395 (I CPU16Regs:$rx, imm_type:$imm16)>; 1396 1397 1398 def: Mips16Pat<(i32 addr16sp:$addr), (AddiuRxRyOffMemX16 addr16sp:$addr)>; 1399 1400 1401 // Large (>16 bit) immediate loads 1402 def : Mips16Pat<(i32 imm:$imm), (LwConstant32 imm:$imm, -1)>; 1403 1404 // Carry MipsPatterns 1405 def : Mips16Pat<(subc CPU16Regs:$lhs, CPU16Regs:$rhs), 1406 (SubuRxRyRz16 CPU16Regs:$lhs, CPU16Regs:$rhs)>; 1407 def : Mips16Pat<(addc CPU16Regs:$lhs, CPU16Regs:$rhs), 1408 (AdduRxRyRz16 CPU16Regs:$lhs, CPU16Regs:$rhs)>; 1409 def : Mips16Pat<(addc CPU16Regs:$src, immSExt16:$imm), 1410 (AddiuRxRxImmX16 CPU16Regs:$src, imm:$imm)>; 1411 1412 // 1413 // Some branch conditional patterns are not generated by llvm at this time. 1414 // Some are for seemingly arbitrary reasons not used: i.e. with signed number 1415 // comparison they are used and for unsigned a different pattern is used. 1416 // I am pushing upstream from the full mips16 port and it seemed that I needed 1417 // these earlier and the mips32 port has these but now I cannot create test 1418 // cases that use these patterns. While I sort this all out I will leave these 1419 // extra patterns commented out and if I can be sure they are really not used, 1420 // I will delete the code. I don't want to check the code in uncommented without 1421 // a valid test case. In some cases, the compiler is generating patterns with 1422 // setcc instead and earlier I had implemented setcc first so may have masked 1423 // the problem. The setcc variants are suboptimal for mips16 so I may wantto 1424 // figure out how to enable the brcond patterns or else possibly new 1425 // combinations of of brcond and setcc. 1426 // 1427 // 1428 // bcond-seteq 1429 // 1430 def: Mips16Pat 1431 <(brcond (i32 (seteq CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1432 (BteqzT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) 1433 >; 1434 1435 1436 def: Mips16Pat 1437 <(brcond (i32 (seteq CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16), 1438 (BteqzT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$targ16) 1439 >; 1440 1441 def: Mips16Pat 1442 <(brcond (i32 (seteq CPU16Regs:$rx, 0)), bb:$targ16), 1443 (BeqzRxImm16 CPU16Regs:$rx, bb:$targ16) 1444 >; 1445 1446 // 1447 // bcond-setgt (do we need to have this pair of setlt, setgt??) 1448 // 1449 def: Mips16Pat 1450 <(brcond (i32 (setgt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1451 (BtnezT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16) 1452 >; 1453 1454 // 1455 // bcond-setge 1456 // 1457 def: Mips16Pat 1458 <(brcond (i32 (setge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1459 (BteqzT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) 1460 >; 1461 1462 // 1463 // never called because compiler transforms a >= k to a > (k-1) 1464 def: Mips16Pat 1465 <(brcond (i32 (setge CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16), 1466 (BteqzT8SltiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$imm16) 1467 >; 1468 1469 // 1470 // bcond-setlt 1471 // 1472 def: Mips16Pat 1473 <(brcond (i32 (setlt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1474 (BtnezT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) 1475 >; 1476 1477 def: Mips16Pat 1478 <(brcond (i32 (setlt CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16), 1479 (BtnezT8SltiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$imm16) 1480 >; 1481 1482 // 1483 // bcond-setle 1484 // 1485 def: Mips16Pat 1486 <(brcond (i32 (setle CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1487 (BteqzT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16) 1488 >; 1489 1490 // 1491 // bcond-setne 1492 // 1493 def: Mips16Pat 1494 <(brcond (i32 (setne CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1495 (BtnezT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) 1496 >; 1497 1498 def: Mips16Pat 1499 <(brcond (i32 (setne CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16), 1500 (BtnezT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$targ16) 1501 >; 1502 1503 def: Mips16Pat 1504 <(brcond (i32 (setne CPU16Regs:$rx, 0)), bb:$targ16), 1505 (BnezRxImm16 CPU16Regs:$rx, bb:$targ16) 1506 >; 1507 1508 // 1509 // This needs to be there but I forget which code will generate it 1510 // 1511 def: Mips16Pat 1512 <(brcond CPU16Regs:$rx, bb:$targ16), 1513 (BnezRxImm16 CPU16Regs:$rx, bb:$targ16) 1514 >; 1515 1516 // 1517 1518 // 1519 // bcond-setugt 1520 // 1521 //def: Mips16Pat 1522 // <(brcond (i32 (setugt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1523 // (BtnezT8SltuX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16) 1524 // >; 1525 1526 // 1527 // bcond-setuge 1528 // 1529 //def: Mips16Pat 1530 // <(brcond (i32 (setuge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1531 // (BteqzT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) 1532 // >; 1533 1534 1535 // 1536 // bcond-setult 1537 // 1538 //def: Mips16Pat 1539 // <(brcond (i32 (setult CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1540 // (BtnezT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) 1541 // >; 1542 1543 def: UncondBranch16_pat<br, Bimm16>; 1544 1545 // Small immediates 1546 def: Mips16Pat<(i32 immSExt16:$in), 1547 (AddiuRxRxImmX16 (MoveR3216 ZERO), immSExt16:$in)>; 1548 1549 def: Mips16Pat<(i32 immZExt16:$in), (LiRxImmX16 immZExt16:$in)>; 1550 1551 // 1552 // MipsDivRem 1553 // 1554 def: Mips16Pat 1555 <(MipsDivRem16 CPU16Regs:$rx, CPU16Regs:$ry), 1556 (DivRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>; 1557 1558 // 1559 // MipsDivRemU 1560 // 1561 def: Mips16Pat 1562 <(MipsDivRemU16 CPU16Regs:$rx, CPU16Regs:$ry), 1563 (DivuRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>; 1564 1565 // signed a,b 1566 // x = (a>=b)?x:y 1567 // 1568 // if !(a < b) x = y 1569 // 1570 def : Mips16Pat<(select (i32 (setge CPU16Regs:$a, CPU16Regs:$b)), 1571 CPU16Regs:$x, CPU16Regs:$y), 1572 (SelTBteqZSlt CPU16Regs:$x, CPU16Regs:$y, 1573 CPU16Regs:$a, CPU16Regs:$b)>; 1574 1575 // signed a,b 1576 // x = (a>b)?x:y 1577 // 1578 // if (b < a) x = y 1579 // 1580 def : Mips16Pat<(select (i32 (setgt CPU16Regs:$a, CPU16Regs:$b)), 1581 CPU16Regs:$x, CPU16Regs:$y), 1582 (SelTBtneZSlt CPU16Regs:$x, CPU16Regs:$y, 1583 CPU16Regs:$b, CPU16Regs:$a)>; 1584 1585 // unsigned a,b 1586 // x = (a>=b)?x:y 1587 // 1588 // if !(a < b) x = y; 1589 // 1590 def : Mips16Pat< 1591 (select (i32 (setuge CPU16Regs:$a, CPU16Regs:$b)), 1592 CPU16Regs:$x, CPU16Regs:$y), 1593 (SelTBteqZSltu CPU16Regs:$x, CPU16Regs:$y, 1594 CPU16Regs:$a, CPU16Regs:$b)>; 1595 1596 // unsigned a,b 1597 // x = (a>b)?x:y 1598 // 1599 // if (b < a) x = y 1600 // 1601 def : Mips16Pat<(select (i32 (setugt CPU16Regs:$a, CPU16Regs:$b)), 1602 CPU16Regs:$x, CPU16Regs:$y), 1603 (SelTBtneZSltu CPU16Regs:$x, CPU16Regs:$y, 1604 CPU16Regs:$b, CPU16Regs:$a)>; 1605 1606 // signed 1607 // x = (a >= k)?x:y 1608 // due to an llvm optimization, i don't think that this will ever 1609 // be used. This is transformed into x = (a > k-1)?x:y 1610 // 1611 // 1612 1613 //def : Mips16Pat< 1614 // (select (i32 (setge CPU16Regs:$lhs, immSExt16:$rhs)), 1615 // CPU16Regs:$T, CPU16Regs:$F), 1616 // (SelTBteqZSlti CPU16Regs:$T, CPU16Regs:$F, 1617 // CPU16Regs:$lhs, immSExt16:$rhs)>; 1618 1619 //def : Mips16Pat< 1620 // (select (i32 (setuge CPU16Regs:$lhs, immSExt16:$rhs)), 1621 // CPU16Regs:$T, CPU16Regs:$F), 1622 // (SelTBteqZSltiu CPU16Regs:$T, CPU16Regs:$F, 1623 // CPU16Regs:$lhs, immSExt16:$rhs)>; 1624 1625 // signed 1626 // x = (a < k)?x:y 1627 // 1628 // if !(a < k) x = y; 1629 // 1630 def : Mips16Pat< 1631 (select (i32 (setlt CPU16Regs:$a, immSExt16:$b)), 1632 CPU16Regs:$x, CPU16Regs:$y), 1633 (SelTBtneZSlti CPU16Regs:$x, CPU16Regs:$y, 1634 CPU16Regs:$a, immSExt16:$b)>; 1635 1636 1637 // 1638 // 1639 // signed 1640 // x = (a <= b)? x : y 1641 // 1642 // if (b < a) x = y 1643 // 1644 def : Mips16Pat<(select (i32 (setle CPU16Regs:$a, CPU16Regs:$b)), 1645 CPU16Regs:$x, CPU16Regs:$y), 1646 (SelTBteqZSlt CPU16Regs:$x, CPU16Regs:$y, 1647 CPU16Regs:$b, CPU16Regs:$a)>; 1648 1649 // 1650 // unnsigned 1651 // x = (a <= b)? x : y 1652 // 1653 // if (b < a) x = y 1654 // 1655 def : Mips16Pat<(select (i32 (setule CPU16Regs:$a, CPU16Regs:$b)), 1656 CPU16Regs:$x, CPU16Regs:$y), 1657 (SelTBteqZSltu CPU16Regs:$x, CPU16Regs:$y, 1658 CPU16Regs:$b, CPU16Regs:$a)>; 1659 1660 // 1661 // signed/unsigned 1662 // x = (a == b)? x : y 1663 // 1664 // if (a != b) x = y 1665 // 1666 def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, CPU16Regs:$b)), 1667 CPU16Regs:$x, CPU16Regs:$y), 1668 (SelTBteqZCmp CPU16Regs:$x, CPU16Regs:$y, 1669 CPU16Regs:$b, CPU16Regs:$a)>; 1670 1671 // 1672 // signed/unsigned 1673 // x = (a == 0)? x : y 1674 // 1675 // if (a != 0) x = y 1676 // 1677 def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, 0)), 1678 CPU16Regs:$x, CPU16Regs:$y), 1679 (SelBeqZ CPU16Regs:$x, CPU16Regs:$y, 1680 CPU16Regs:$a)>; 1681 1682 1683 // 1684 // signed/unsigned 1685 // x = (a == k)? x : y 1686 // 1687 // if (a != k) x = y 1688 // 1689 def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, immZExt16:$k)), 1690 CPU16Regs:$x, CPU16Regs:$y), 1691 (SelTBteqZCmpi CPU16Regs:$x, CPU16Regs:$y, 1692 CPU16Regs:$a, immZExt16:$k)>; 1693 1694 1695 // 1696 // signed/unsigned 1697 // x = (a != b)? x : y 1698 // 1699 // if (a == b) x = y 1700 // 1701 // 1702 def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, CPU16Regs:$b)), 1703 CPU16Regs:$x, CPU16Regs:$y), 1704 (SelTBtneZCmp CPU16Regs:$x, CPU16Regs:$y, 1705 CPU16Regs:$b, CPU16Regs:$a)>; 1706 1707 // 1708 // signed/unsigned 1709 // x = (a != 0)? x : y 1710 // 1711 // if (a == 0) x = y 1712 // 1713 def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, 0)), 1714 CPU16Regs:$x, CPU16Regs:$y), 1715 (SelBneZ CPU16Regs:$x, CPU16Regs:$y, 1716 CPU16Regs:$a)>; 1717 1718 // signed/unsigned 1719 // x = (a)? x : y 1720 // 1721 // if (!a) x = y 1722 // 1723 def : Mips16Pat<(select CPU16Regs:$a, 1724 CPU16Regs:$x, CPU16Regs:$y), 1725 (SelBneZ CPU16Regs:$x, CPU16Regs:$y, 1726 CPU16Regs:$a)>; 1727 1728 1729 // 1730 // signed/unsigned 1731 // x = (a != k)? x : y 1732 // 1733 // if (a == k) x = y 1734 // 1735 def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, immZExt16:$k)), 1736 CPU16Regs:$x, CPU16Regs:$y), 1737 (SelTBtneZCmpi CPU16Regs:$x, CPU16Regs:$y, 1738 CPU16Regs:$a, immZExt16:$k)>; 1739 1740 // 1741 // When writing C code to test setxx these patterns, 1742 // some will be transformed into 1743 // other things. So we test using C code but using -O3 and -O0 1744 // 1745 // seteq 1746 // 1747 def : Mips16Pat 1748 <(seteq CPU16Regs:$lhs,CPU16Regs:$rhs), 1749 (SltiuCCRxImmX16 (XorRxRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs), 1)>; 1750 1751 def : Mips16Pat 1752 <(seteq CPU16Regs:$lhs, 0), 1753 (SltiuCCRxImmX16 CPU16Regs:$lhs, 1)>; 1754 1755 1756 // 1757 // setge 1758 // 1759 1760 def: Mips16Pat 1761 <(setge CPU16Regs:$lhs, CPU16Regs:$rhs), 1762 (XorRxRxRy16 (SltCCRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs), 1763 (LiRxImmX16 1))>; 1764 1765 // 1766 // For constants, llvm transforms this to: 1767 // x > (k - 1) and then reverses the operands to use setlt. So this pattern 1768 // is not used now by the compiler. (Presumably checking that k-1 does not 1769 // overflow). The compiler never uses this at the current time, due to 1770 // other optimizations. 1771 // 1772 //def: Mips16Pat 1773 // <(setge CPU16Regs:$lhs, immSExt16:$rhs), 1774 // (XorRxRxRy16 (SltiCCRxImmX16 CPU16Regs:$lhs, immSExt16:$rhs), 1775 // (LiRxImmX16 1))>; 1776 1777 // This catches the x >= -32768 case by transforming it to x > -32769 1778 // 1779 def: Mips16Pat 1780 <(setgt CPU16Regs:$lhs, -32769), 1781 (XorRxRxRy16 (SltiCCRxImmX16 CPU16Regs:$lhs, -32768), 1782 (LiRxImmX16 1))>; 1783 1784 // 1785 // setgt 1786 // 1787 // 1788 1789 def: Mips16Pat 1790 <(setgt CPU16Regs:$lhs, CPU16Regs:$rhs), 1791 (SltCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs)>; 1792 1793 // 1794 // setle 1795 // 1796 def: Mips16Pat 1797 <(setle CPU16Regs:$lhs, CPU16Regs:$rhs), 1798 (XorRxRxRy16 (SltCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs), (LiRxImm16 1))>; 1799 1800 // 1801 // setlt 1802 // 1803 def: SetCC_R16<setlt, SltCCRxRy16>; 1804 1805 def: SetCC_I16<setlt, immSExt16, SltiCCRxImmX16>; 1806 1807 // 1808 // setne 1809 // 1810 def : Mips16Pat 1811 <(setne CPU16Regs:$lhs,CPU16Regs:$rhs), 1812 (SltuCCRxRy16 (LiRxImmX16 0), 1813 (XorRxRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs))>; 1814 1815 1816 // 1817 // setuge 1818 // 1819 def: Mips16Pat 1820 <(setuge CPU16Regs:$lhs, CPU16Regs:$rhs), 1821 (XorRxRxRy16 (SltuCCRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs), 1822 (LiRxImmX16 1))>; 1823 1824 // this pattern will never be used because the compiler will transform 1825 // x >= k to x > (k - 1) and then use SLT 1826 // 1827 //def: Mips16Pat 1828 // <(setuge CPU16Regs:$lhs, immZExt16:$rhs), 1829 // (XorRxRxRy16 (SltiuCCRxImmX16 CPU16Regs:$lhs, immZExt16:$rhs), 1830 // (LiRxImmX16 1))>; 1831 1832 // 1833 // setugt 1834 // 1835 def: Mips16Pat 1836 <(setugt CPU16Regs:$lhs, CPU16Regs:$rhs), 1837 (SltuCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs)>; 1838 1839 // 1840 // setule 1841 // 1842 def: Mips16Pat 1843 <(setule CPU16Regs:$lhs, CPU16Regs:$rhs), 1844 (XorRxRxRy16 (SltuCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs), (LiRxImmX16 1))>; 1845 1846 // 1847 // setult 1848 // 1849 def: SetCC_R16<setult, SltuCCRxRy16>; 1850 1851 def: SetCC_I16<setult, immSExt16, SltiuCCRxImmX16>; 1852 1853 def: Mips16Pat<(add CPU16Regs:$hi, (MipsLo tglobaladdr:$lo)), 1854 (AddiuRxRxImmX16 CPU16Regs:$hi, tglobaladdr:$lo)>; 1855 1856 // hi/lo relocs 1857 def : Mips16Pat<(MipsHi tblockaddress:$in), 1858 (SllX16 (LiRxImmX16 tblockaddress:$in), 16)>; 1859 def : Mips16Pat<(MipsHi tglobaladdr:$in), 1860 (SllX16 (LiRxImmX16 tglobaladdr:$in), 16)>; 1861 def : Mips16Pat<(MipsHi tjumptable:$in), 1862 (SllX16 (LiRxImmX16 tjumptable:$in), 16)>; 1863 def : Mips16Pat<(MipsHi tglobaltlsaddr:$in), 1864 (SllX16 (LiRxImmX16 tglobaltlsaddr:$in), 16)>; 1865 1866 def : Mips16Pat<(MipsLo tblockaddress:$in), (LiRxImmX16 tblockaddress:$in)>; 1867 1868 // wrapper_pic 1869 class Wrapper16Pat<SDNode node, Instruction ADDiuOp, RegisterClass RC>: 1870 Mips16Pat<(MipsWrapper RC:$gp, node:$in), 1871 (ADDiuOp RC:$gp, node:$in)>; 1872 1873 1874 def : Wrapper16Pat<tglobaladdr, AddiuRxRxImmX16, CPU16Regs>; 1875 def : Wrapper16Pat<tglobaltlsaddr, AddiuRxRxImmX16, CPU16Regs>; 1876 1877 def : Mips16Pat<(i32 (extloadi8 addr16:$src)), 1878 (LbuRxRyOffMemX16 addr16:$src)>; 1879 def : Mips16Pat<(i32 (extloadi16 addr16:$src)), 1880 (LhuRxRyOffMemX16 addr16:$src)>; 1881 1882 def: Mips16Pat<(trap), (Break16)>; 1883 1884 def : Mips16Pat<(sext_inreg CPU16Regs:$val, i8), 1885 (SebRx16 CPU16Regs:$val)>; 1886 1887 def : Mips16Pat<(sext_inreg CPU16Regs:$val, i16), 1888 (SehRx16 CPU16Regs:$val)>; 1889 1890 def GotPrologue16: 1891 MipsPseudo16< 1892 (outs CPU16Regs:$rh, CPU16Regs:$rl), 1893 (ins simm16:$immHi, simm16:$immLo), 1894 "li\t$rh, $immHi\n\taddiu\t$rl, $$pc, $immLo\n ",[]> ; 1895 1896 // An operand for the CONSTPOOL_ENTRY pseudo-instruction. 1897 def cpinst_operand : Operand<i32> { 1898 // let PrintMethod = "printCPInstOperand"; 1899 } 1900 1901 // CONSTPOOL_ENTRY - This instruction represents a floating constant pool in 1902 // the function. The first operand is the ID# for this instruction, the second 1903 // is the index into the MachineConstantPool that this is, the third is the 1904 // size in bytes of this constant pool entry. 1905 // 1906 let hasSideEffects = 0, isNotDuplicable = 1 in 1907 def CONSTPOOL_ENTRY : 1908 MipsPseudo16<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx, 1909 i32imm:$size), "foo", []>; 1910 1911