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 let isReturn=1; 770 } 771 772 def JrcRa16: FRR16_JALRC_RA_only_ins<1, 1, "jrc", IIM16Alu> { 773 let isBranch = 1; 774 let isIndirectBranch = 1; 775 let isTerminator=1; 776 let isBarrier=1; 777 let isReturn=1; 778 } 779 780 def JrcRx16: FRR16_JALRC_ins<1, 1, 0, "jrc", IIM16Alu> { 781 let isBranch = 1; 782 let isIndirectBranch = 1; 783 let isTerminator=1; 784 let isBarrier=1; 785 } 786 // 787 // Format: LB ry, offset(rx) MIPS16e 788 // Purpose: Load Byte (Extended) 789 // To load a byte from memory as a signed value. 790 // 791 def LbRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lb", mem16, II_LB>, MayLoad{ 792 let isCodeGenOnly = 1; 793 } 794 795 // 796 // Format: LBU ry, offset(rx) MIPS16e 797 // Purpose: Load Byte Unsigned (Extended) 798 // To load a byte from memory as a unsigned value. 799 // 800 def LbuRxRyOffMemX16: 801 FEXT_RRI16_mem_ins<0b10100, "lbu", mem16, II_LBU>, MayLoad { 802 let isCodeGenOnly = 1; 803 } 804 805 // 806 // Format: LH ry, offset(rx) MIPS16e 807 // Purpose: Load Halfword signed (Extended) 808 // To load a halfword from memory as a signed value. 809 // 810 def LhRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10100, "lh", mem16, II_LH>, MayLoad{ 811 let isCodeGenOnly = 1; 812 } 813 814 // 815 // Format: LHU ry, offset(rx) MIPS16e 816 // Purpose: Load Halfword unsigned (Extended) 817 // To load a halfword from memory as an unsigned value. 818 // 819 def LhuRxRyOffMemX16: 820 FEXT_RRI16_mem_ins<0b10100, "lhu", mem16, II_LHU>, MayLoad { 821 let isCodeGenOnly = 1; 822 } 823 824 // 825 // Format: LI rx, immediate MIPS16e 826 // Purpose: Load Immediate 827 // To load a constant into a GPR. 828 // 829 def LiRxImm16: FRI16_ins<0b01101, "li", IIM16Alu>; 830 831 // 832 // Format: LI rx, immediate MIPS16e 833 // Purpose: Load Immediate (Extended) 834 // To load a constant into a GPR. 835 // 836 def LiRxImmX16: FEXT_RI16_ins<0b01101, "li", IIM16Alu>; 837 838 def LiRxImmAlignX16: FEXT_RI16_ins<0b01101, ".align 2\n\tli", IIM16Alu> { 839 let isCodeGenOnly = 1; 840 } 841 842 // 843 // Format: LW ry, offset(rx) MIPS16e 844 // Purpose: Load Word (Extended) 845 // To load a word from memory as a signed value. 846 // 847 def LwRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lw", mem16, II_LW>, MayLoad{ 848 let isCodeGenOnly = 1; 849 } 850 851 // Format: LW rx, offset(sp) MIPS16e 852 // Purpose: Load Word (SP-Relative, Extended) 853 // To load an SP-relative word from memory as a signed value. 854 // 855 def LwRxSpImmX16: FEXT_RRI16_mem_ins<0b10010, "lw", mem16sp, II_LW>, MayLoad; 856 857 def LwRxPcTcp16: FRI16_TCP_ins<0b10110, "lw", II_LW>, MayLoad; 858 859 def LwRxPcTcpX16: FEXT_RI16_TCP_ins<0b10110, "lw", II_LW>, MayLoad; 860 // 861 // Format: MOVE r32, rz MIPS16e 862 // Purpose: Move 863 // To move the contents of a GPR to a GPR. 864 // 865 def Move32R16: FI8_MOV32R16_ins<"move", IIM16Alu>; 866 867 // 868 // Format: MOVE ry, r32 MIPS16e 869 //Purpose: Move 870 // To move the contents of a GPR to a GPR. 871 // 872 def MoveR3216: FI8_MOVR3216_ins<"move", IIM16Alu> { 873 let isMoveReg = 1; 874 } 875 876 // 877 // Format: MFHI rx MIPS16e 878 // Purpose: Move From HI Register 879 // To copy the special purpose HI register to a GPR. 880 // 881 def Mfhi16: FRR16_M_ins<0b10000, "mfhi", IIM16Alu> { 882 let Uses = [HI0]; 883 let hasSideEffects = 0; 884 let isMoveReg = 1; 885 } 886 887 // 888 // Format: MFLO rx MIPS16e 889 // Purpose: Move From LO Register 890 // To copy the special purpose LO register to a GPR. 891 // 892 def Mflo16: FRR16_M_ins<0b10010, "mflo", IIM16Alu> { 893 let Uses = [LO0]; 894 let hasSideEffects = 0; 895 let isMoveReg = 0; 896 } 897 898 // 899 // Pseudo Instruction for mult 900 // 901 def MultRxRy16: FMULT16_ins<"mult", IIM16Alu> { 902 let isCommutable = 1; 903 let hasSideEffects = 0; 904 let Defs = [HI0, LO0]; 905 } 906 907 def MultuRxRy16: FMULT16_ins<"multu", IIM16Alu> { 908 let isCommutable = 1; 909 let hasSideEffects = 0; 910 let Defs = [HI0, LO0]; 911 } 912 913 // 914 // Format: MULT rx, ry MIPS16e 915 // Purpose: Multiply Word 916 // To multiply 32-bit signed integers. 917 // 918 def MultRxRyRz16: FMULT16_LO_ins<"mult", IIM16Alu> { 919 let isCommutable = 1; 920 let hasSideEffects = 0; 921 let Defs = [HI0, LO0]; 922 } 923 924 // 925 // Format: MULTU rx, ry MIPS16e 926 // Purpose: Multiply Unsigned Word 927 // To multiply 32-bit unsigned integers. 928 // 929 def MultuRxRyRz16: FMULT16_LO_ins<"multu", IIM16Alu> { 930 let isCommutable = 1; 931 let hasSideEffects = 0; 932 let Defs = [HI0, LO0]; 933 } 934 935 // 936 // Format: NEG rx, ry MIPS16e 937 // Purpose: Negate 938 // To negate an integer value. 939 // 940 def NegRxRy16: FUnaryRR16_ins<0b11101, "neg", IIM16Alu>; 941 942 // 943 // Format: NOT rx, ry MIPS16e 944 // Purpose: Not 945 // To complement an integer value 946 // 947 def NotRxRy16: FUnaryRR16_ins<0b01111, "not", IIM16Alu>; 948 949 // 950 // Format: OR rx, ry MIPS16e 951 // Purpose: Or 952 // To do a bitwise logical OR. 953 // 954 def OrRxRxRy16: FRxRxRy16_ins<0b01101, "or", IIM16Alu>, ArithLogic16Defs<1>; 955 956 // 957 // Format: RESTORE {ra,}{s0/s1/s0-1,}{framesize} 958 // (All args are optional) MIPS16e 959 // Purpose: Restore Registers and Deallocate Stack Frame 960 // To deallocate a stack frame before exit from a subroutine, 961 // restoring return address and static registers, and adjusting 962 // stack 963 // 964 965 def Restore16: 966 FI8_SVRS16<0b1, (outs), (ins variable_ops), 967 "", [], II_RESTORE >, MayLoad { 968 let isCodeGenOnly = 1; 969 let Defs = [SP]; 970 let Uses = [SP]; 971 } 972 973 974 def RestoreX16: 975 FI8_SVRS16<0b1, (outs), (ins variable_ops), 976 "", [], II_RESTORE >, MayLoad { 977 let isCodeGenOnly = 1; 978 let Defs = [SP]; 979 let Uses = [SP]; 980 } 981 982 // 983 // Format: SAVE {ra,}{s0/s1/s0-1,}{framesize} (All arguments are optional) 984 // MIPS16e 985 // Purpose: Save Registers and Set Up Stack Frame 986 // To set up a stack frame on entry to a subroutine, 987 // saving return address and static registers, and adjusting stack 988 // 989 def Save16: 990 FI8_SVRS16<0b1, (outs), (ins variable_ops), 991 "", [], II_SAVE >, MayStore { 992 let isCodeGenOnly = 1; 993 let Uses = [SP]; 994 let Defs = [SP]; 995 } 996 997 def SaveX16: 998 FI8_SVRS16<0b1, (outs), (ins variable_ops), 999 "", [], II_SAVE >, MayStore { 1000 let isCodeGenOnly = 1; 1001 let Uses = [SP]; 1002 let Defs = [SP]; 1003 } 1004 // 1005 // Format: SB ry, offset(rx) MIPS16e 1006 // Purpose: Store Byte (Extended) 1007 // To store a byte to memory. 1008 // 1009 def SbRxRyOffMemX16: 1010 FEXT_RRI16_mem2_ins<0b11000, "sb", mem16, II_SB>, MayStore; 1011 1012 // 1013 // Format: SEB rx MIPS16e 1014 // Purpose: Sign-Extend Byte 1015 // Sign-extend least significant byte in register rx. 1016 // 1017 def SebRx16 1018 : FRR_SF16_ins<0b10001, 0b100, "seb", IIM16Alu>; 1019 1020 // 1021 // Format: SEH rx MIPS16e 1022 // Purpose: Sign-Extend Halfword 1023 // Sign-extend least significant word in register rx. 1024 // 1025 def SehRx16 1026 : FRR_SF16_ins<0b10001, 0b101, "seh", IIM16Alu>; 1027 1028 // 1029 // The Sel(T) instructions are pseudos 1030 // T means that they use T8 implicitly. 1031 // 1032 // 1033 // Format: SelBeqZ rd, rs, rt 1034 // Purpose: if rt==0, do nothing 1035 // else rs = rt 1036 // 1037 def SelBeqZ: Sel<"beqz">; 1038 1039 // 1040 // Format: SelTBteqZCmp rd, rs, rl, rr 1041 // Purpose: b = Cmp rl, rr. 1042 // If b==0 then do nothing. 1043 // if b!=0 then rd = rs 1044 // 1045 def SelTBteqZCmp: SelT<"bteqz", "cmp">; 1046 1047 // 1048 // Format: SelTBteqZCmpi rd, rs, rl, rr 1049 // Purpose: b = Cmpi rl, imm. 1050 // If b==0 then do nothing. 1051 // if b!=0 then rd = rs 1052 // 1053 def SelTBteqZCmpi: SeliT<"bteqz", "cmpi">; 1054 1055 // 1056 // Format: SelTBteqZSlt rd, rs, rl, rr 1057 // Purpose: b = Slt rl, rr. 1058 // If b==0 then do nothing. 1059 // if b!=0 then rd = rs 1060 // 1061 def SelTBteqZSlt: SelT<"bteqz", "slt">; 1062 1063 // 1064 // Format: SelTBteqZSlti rd, rs, rl, rr 1065 // Purpose: b = Slti rl, imm. 1066 // If b==0 then do nothing. 1067 // if b!=0 then rd = rs 1068 // 1069 def SelTBteqZSlti: SeliT<"bteqz", "slti">; 1070 1071 // 1072 // Format: SelTBteqZSltu rd, rs, rl, rr 1073 // Purpose: b = Sltu rl, rr. 1074 // If b==0 then do nothing. 1075 // if b!=0 then rd = rs 1076 // 1077 def SelTBteqZSltu: SelT<"bteqz", "sltu">; 1078 1079 // 1080 // Format: SelTBteqZSltiu rd, rs, rl, rr 1081 // Purpose: b = Sltiu rl, imm. 1082 // If b==0 then do nothing. 1083 // if b!=0 then rd = rs 1084 // 1085 def SelTBteqZSltiu: SeliT<"bteqz", "sltiu">; 1086 1087 // 1088 // Format: SelBnez rd, rs, rt 1089 // Purpose: if rt!=0, do nothing 1090 // else rs = rt 1091 // 1092 def SelBneZ: Sel<"bnez">; 1093 1094 // 1095 // Format: SelTBtneZCmp rd, rs, rl, rr 1096 // Purpose: b = Cmp rl, rr. 1097 // If b!=0 then do nothing. 1098 // if b0=0 then rd = rs 1099 // 1100 def SelTBtneZCmp: SelT<"btnez", "cmp">; 1101 1102 // 1103 // Format: SelTBtnezCmpi rd, rs, rl, rr 1104 // Purpose: b = Cmpi rl, imm. 1105 // If b!=0 then do nothing. 1106 // if b==0 then rd = rs 1107 // 1108 def SelTBtneZCmpi: SeliT<"btnez", "cmpi">; 1109 1110 // 1111 // Format: SelTBtneZSlt rd, rs, rl, rr 1112 // Purpose: b = Slt rl, rr. 1113 // If b!=0 then do nothing. 1114 // if b==0 then rd = rs 1115 // 1116 def SelTBtneZSlt: SelT<"btnez", "slt">; 1117 1118 // 1119 // Format: SelTBtneZSlti rd, rs, rl, rr 1120 // Purpose: b = Slti rl, imm. 1121 // If b!=0 then do nothing. 1122 // if b==0 then rd = rs 1123 // 1124 def SelTBtneZSlti: SeliT<"btnez", "slti">; 1125 1126 // 1127 // Format: SelTBtneZSltu rd, rs, rl, rr 1128 // Purpose: b = Sltu rl, rr. 1129 // If b!=0 then do nothing. 1130 // if b==0 then rd = rs 1131 // 1132 def SelTBtneZSltu: SelT<"btnez", "sltu">; 1133 1134 // 1135 // Format: SelTBtneZSltiu rd, rs, rl, rr 1136 // Purpose: b = Slti rl, imm. 1137 // If b!=0 then do nothing. 1138 // if b==0 then rd = rs 1139 // 1140 def SelTBtneZSltiu: SeliT<"btnez", "sltiu">; 1141 // 1142 // 1143 // Format: SH ry, offset(rx) MIPS16e 1144 // Purpose: Store Halfword (Extended) 1145 // To store a halfword to memory. 1146 // 1147 def ShRxRyOffMemX16: 1148 FEXT_RRI16_mem2_ins<0b11001, "sh", mem16, II_SH>, MayStore; 1149 1150 // 1151 // Format: SLL rx, ry, sa MIPS16e 1152 // Purpose: Shift Word Left Logical (Extended) 1153 // To execute a left-shift of a word by a fixed number of bits-0 to 31 bits. 1154 // 1155 def SllX16: FEXT_SHIFT16_ins<0b00, "sll", IIM16Alu>; 1156 1157 // 1158 // Format: SLLV ry, rx MIPS16e 1159 // Purpose: Shift Word Left Logical Variable 1160 // To execute a left-shift of a word by a variable number of bits. 1161 // 1162 def SllvRxRy16 : FRxRxRy16_ins<0b00100, "sllv", IIM16Alu>; 1163 1164 // Format: SLTI rx, immediate MIPS16e 1165 // Purpose: Set on Less Than Immediate 1166 // To record the result of a less-than comparison with a constant. 1167 // 1168 // 1169 def SltiRxImm16: FRI16R_ins<0b01010, "slti", IIM16Alu> { 1170 let Defs = [T8]; 1171 } 1172 1173 // 1174 // Format: SLTI rx, immediate MIPS16e 1175 // Purpose: Set on Less Than Immediate (Extended) 1176 // To record the result of a less-than comparison with a constant. 1177 // 1178 // 1179 def SltiRxImmX16: FEXT_RI16R_ins<0b01010, "slti", IIM16Alu> { 1180 let Defs = [T8]; 1181 } 1182 1183 def SltiCCRxImmX16: FEXT_CCRXI16_ins<"slti">; 1184 1185 // Format: SLTIU rx, immediate MIPS16e 1186 // Purpose: Set on Less Than Immediate Unsigned 1187 // To record the result of a less-than comparison with a constant. 1188 // 1189 // 1190 def SltiuRxImm16: FRI16R_ins<0b01011, "sltiu", IIM16Alu> { 1191 let Defs = [T8]; 1192 } 1193 1194 // 1195 // Format: SLTI rx, immediate MIPS16e 1196 // Purpose: Set on Less Than Immediate Unsigned (Extended) 1197 // To record the result of a less-than comparison with a constant. 1198 // 1199 // 1200 def SltiuRxImmX16: FEXT_RI16R_ins<0b01011, "sltiu", IIM16Alu> { 1201 let Defs = [T8]; 1202 } 1203 // 1204 // Format: SLTIU rx, immediate MIPS16e 1205 // Purpose: Set on Less Than Immediate Unsigned (Extended) 1206 // To record the result of a less-than comparison with a constant. 1207 // 1208 def SltiuCCRxImmX16: FEXT_CCRXI16_ins<"sltiu">; 1209 1210 // 1211 // Format: SLT rx, ry MIPS16e 1212 // Purpose: Set on Less Than 1213 // To record the result of a less-than comparison. 1214 // 1215 def SltRxRy16: FRR16R_ins<0b00010, "slt", IIM16Alu>{ 1216 let Defs = [T8]; 1217 } 1218 1219 def SltCCRxRy16: FCCRR16_ins<"slt">; 1220 1221 // Format: SLTU rx, ry MIPS16e 1222 // Purpose: Set on Less Than Unsigned 1223 // To record the result of an unsigned less-than comparison. 1224 // 1225 def SltuRxRy16: FRR16R_ins<0b00011, "sltu", IIM16Alu>{ 1226 let Defs = [T8]; 1227 } 1228 1229 def SltuRxRyRz16: FRRTR16_ins<"sltu"> { 1230 let isCodeGenOnly=1; 1231 let Defs = [T8]; 1232 } 1233 1234 1235 def SltuCCRxRy16: FCCRR16_ins<"sltu">; 1236 // 1237 // Format: SRAV ry, rx MIPS16e 1238 // Purpose: Shift Word Right Arithmetic Variable 1239 // To execute an arithmetic right-shift of a word by a variable 1240 // number of bits. 1241 // 1242 def SravRxRy16: FRxRxRy16_ins<0b00111, "srav", IIM16Alu>; 1243 1244 1245 // 1246 // Format: SRA rx, ry, sa MIPS16e 1247 // Purpose: Shift Word Right Arithmetic (Extended) 1248 // To execute an arithmetic right-shift of a word by a fixed 1249 // number of bits-1 to 8 bits. 1250 // 1251 def SraX16: FEXT_SHIFT16_ins<0b11, "sra", IIM16Alu>; 1252 1253 1254 // 1255 // Format: SRLV ry, rx MIPS16e 1256 // Purpose: Shift Word Right Logical Variable 1257 // To execute a logical right-shift of a word by a variable 1258 // number of bits. 1259 // 1260 def SrlvRxRy16: FRxRxRy16_ins<0b00110, "srlv", IIM16Alu>; 1261 1262 1263 // 1264 // Format: SRL rx, ry, sa MIPS16e 1265 // Purpose: Shift Word Right Logical (Extended) 1266 // To execute a logical right-shift of a word by a fixed 1267 // number of bits-1 to 31 bits. 1268 // 1269 def SrlX16: FEXT_SHIFT16_ins<0b10, "srl", IIM16Alu>; 1270 1271 // 1272 // Format: SUBU rz, rx, ry MIPS16e 1273 // Purpose: Subtract Unsigned Word 1274 // To subtract 32-bit integers 1275 // 1276 def SubuRxRyRz16: FRRR16_ins<0b11, "subu", IIM16Alu>, ArithLogic16Defs<0>; 1277 1278 // 1279 // Format: SW ry, offset(rx) MIPS16e 1280 // Purpose: Store Word (Extended) 1281 // To store a word to memory. 1282 // 1283 def SwRxRyOffMemX16: FEXT_RRI16_mem2_ins<0b11011, "sw", mem16, II_SW>, MayStore; 1284 1285 // 1286 // Format: SW rx, offset(sp) MIPS16e 1287 // Purpose: Store Word rx (SP-Relative) 1288 // To store an SP-relative word to memory. 1289 // 1290 def SwRxSpImmX16: FEXT_RRI16_mem2_ins<0b11010, "sw", mem16sp, II_SW>, MayStore; 1291 1292 // 1293 // 1294 // Format: XOR rx, ry MIPS16e 1295 // Purpose: Xor 1296 // To do a bitwise logical XOR. 1297 // 1298 def XorRxRxRy16: FRxRxRy16_ins<0b01110, "xor", IIM16Alu>, ArithLogic16Defs<1>; 1299 1300 class Mips16Pat<dag pattern, dag result> : Pat<pattern, result> { 1301 let Predicates = [InMips16Mode]; 1302 } 1303 1304 // Unary Arith/Logic 1305 // 1306 class ArithLogicU_pat<PatFrag OpNode, Instruction I> : 1307 Mips16Pat<(OpNode CPU16Regs:$r), 1308 (I CPU16Regs:$r)>; 1309 1310 def: ArithLogicU_pat<not, NotRxRy16>; 1311 def: ArithLogicU_pat<ineg, NegRxRy16>; 1312 1313 class ArithLogic16_pat<SDNode OpNode, Instruction I> : 1314 Mips16Pat<(OpNode CPU16Regs:$l, CPU16Regs:$r), 1315 (I CPU16Regs:$l, CPU16Regs:$r)>; 1316 1317 def: ArithLogic16_pat<add, AdduRxRyRz16>; 1318 def: ArithLogic16_pat<and, AndRxRxRy16>; 1319 def: ArithLogic16_pat<mul, MultRxRyRz16>; 1320 def: ArithLogic16_pat<or, OrRxRxRy16>; 1321 def: ArithLogic16_pat<sub, SubuRxRyRz16>; 1322 def: ArithLogic16_pat<xor, XorRxRxRy16>; 1323 1324 // Arithmetic and logical instructions with 2 register operands. 1325 1326 class ArithLogicI16_pat<SDNode OpNode, PatFrag imm_type, Instruction I> : 1327 Mips16Pat<(OpNode CPU16Regs:$in, imm_type:$imm), 1328 (I CPU16Regs:$in, imm_type:$imm)>; 1329 1330 def: ArithLogicI16_pat<add, immSExt8, AddiuRxRxImm16>; 1331 def: ArithLogicI16_pat<add, immSExt16, AddiuRxRxImmX16>; 1332 def: ArithLogicI16_pat<shl, immZExt5, SllX16>; 1333 def: ArithLogicI16_pat<srl, immZExt5, SrlX16>; 1334 def: ArithLogicI16_pat<sra, immZExt5, SraX16>; 1335 1336 class shift_rotate_reg16_pat<SDNode OpNode, Instruction I> : 1337 Mips16Pat<(OpNode CPU16Regs:$r, CPU16Regs:$ra), 1338 (I CPU16Regs:$r, CPU16Regs:$ra)>; 1339 1340 def: shift_rotate_reg16_pat<shl, SllvRxRy16>; 1341 def: shift_rotate_reg16_pat<sra, SravRxRy16>; 1342 def: shift_rotate_reg16_pat<srl, SrlvRxRy16>; 1343 1344 class LoadM16_pat<PatFrag OpNode, Instruction I, ComplexPattern Addr> : 1345 Mips16Pat<(OpNode Addr:$addr), (I Addr:$addr)>; 1346 1347 def: LoadM16_pat<sextloadi8, LbRxRyOffMemX16, addr16>; 1348 def: LoadM16_pat<zextloadi8, LbuRxRyOffMemX16, addr16>; 1349 def: LoadM16_pat<sextloadi16, LhRxRyOffMemX16, addr16>; 1350 def: LoadM16_pat<zextloadi16, LhuRxRyOffMemX16, addr16>; 1351 def: LoadM16_pat<load, LwRxSpImmX16, addr16sp>; 1352 1353 class StoreM16_pat<PatFrag OpNode, Instruction I, ComplexPattern Addr> : 1354 Mips16Pat<(OpNode CPU16Regs:$r, Addr:$addr), (I CPU16Regs:$r, Addr:$addr)>; 1355 1356 def: StoreM16_pat<truncstorei8, SbRxRyOffMemX16, addr16>; 1357 def: StoreM16_pat<truncstorei16, ShRxRyOffMemX16, addr16>; 1358 def: StoreM16_pat<store, SwRxSpImmX16, addr16sp>; 1359 1360 // Unconditional branch 1361 class UncondBranch16_pat<SDNode OpNode, Instruction I>: 1362 Mips16Pat<(OpNode bb:$imm16), (I bb:$imm16)> { 1363 let Predicates = [InMips16Mode]; 1364 } 1365 1366 def : Mips16Pat<(MipsJmpLink (i32 tglobaladdr:$dst)), 1367 (Jal16 tglobaladdr:$dst)>; 1368 1369 def : Mips16Pat<(MipsJmpLink (i32 texternalsym:$dst)), 1370 (Jal16 texternalsym:$dst)>; 1371 1372 // Indirect branch 1373 def: Mips16Pat<(brind CPU16Regs:$rs), (JrcRx16 CPU16Regs:$rs)> { 1374 // Ensure that the addition of MIPS32r6/MIPS64r6 support does not change 1375 // MIPS16's behaviour. 1376 let AddedComplexity = 1; 1377 } 1378 1379 // Jump and Link (Call) 1380 let isCall=1, hasDelaySlot=0 in 1381 def JumpLinkReg16: 1382 FRR16_JALRC<0, 0, 0, (outs), (ins CPU16Regs:$rs), 1383 "jalrc\t$rs", [(MipsJmpLink CPU16Regs:$rs)], II_JALRC> { 1384 let Defs = [RA]; 1385 } 1386 1387 // Mips16 pseudos 1388 let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1, hasCtrlDep=1, 1389 hasExtraSrcRegAllocReq = 1 in 1390 def RetRA16 : MipsPseudo16<(outs), (ins), "", [(MipsRet)]>; 1391 1392 1393 // setcc patterns 1394 1395 class SetCC_R16<PatFrag cond_op, Instruction I>: 1396 Mips16Pat<(cond_op CPU16Regs:$rx, CPU16Regs:$ry), 1397 (I CPU16Regs:$rx, CPU16Regs:$ry)>; 1398 1399 class SetCC_I16<PatFrag cond_op, PatLeaf imm_type, Instruction I>: 1400 Mips16Pat<(cond_op CPU16Regs:$rx, imm_type:$imm16), 1401 (I CPU16Regs:$rx, imm_type:$imm16)>; 1402 1403 1404 def: Mips16Pat<(i32 addr16sp:$addr), (AddiuRxRyOffMemX16 addr16sp:$addr)>; 1405 1406 1407 // Large (>16 bit) immediate loads 1408 def : Mips16Pat<(i32 imm:$imm), (LwConstant32 imm:$imm, -1)>; 1409 1410 // 1411 // Some branch conditional patterns are not generated by llvm at this time. 1412 // Some are for seemingly arbitrary reasons not used: i.e. with signed number 1413 // comparison they are used and for unsigned a different pattern is used. 1414 // I am pushing upstream from the full mips16 port and it seemed that I needed 1415 // these earlier and the mips32 port has these but now I cannot create test 1416 // cases that use these patterns. While I sort this all out I will leave these 1417 // extra patterns commented out and if I can be sure they are really not used, 1418 // I will delete the code. I don't want to check the code in uncommented without 1419 // a valid test case. In some cases, the compiler is generating patterns with 1420 // setcc instead and earlier I had implemented setcc first so may have masked 1421 // the problem. The setcc variants are suboptimal for mips16 so I may wantto 1422 // figure out how to enable the brcond patterns or else possibly new 1423 // combinations of brcond and setcc. 1424 // 1425 // 1426 // bcond-seteq 1427 // 1428 def: Mips16Pat 1429 <(brcond (i32 (seteq CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1430 (BteqzT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) 1431 >; 1432 1433 1434 def: Mips16Pat 1435 <(brcond (i32 (seteq CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16), 1436 (BteqzT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$targ16) 1437 >; 1438 1439 def: Mips16Pat 1440 <(brcond (i32 (seteq CPU16Regs:$rx, 0)), bb:$targ16), 1441 (BeqzRxImm16 CPU16Regs:$rx, bb:$targ16) 1442 >; 1443 1444 // 1445 // bcond-setgt (do we need to have this pair of setlt, setgt??) 1446 // 1447 def: Mips16Pat 1448 <(brcond (i32 (setgt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1449 (BtnezT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16) 1450 >; 1451 1452 // 1453 // bcond-setge 1454 // 1455 def: Mips16Pat 1456 <(brcond (i32 (setge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1457 (BteqzT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) 1458 >; 1459 1460 // 1461 // never called because compiler transforms a >= k to a > (k-1) 1462 def: Mips16Pat 1463 <(brcond (i32 (setge CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16), 1464 (BteqzT8SltiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$imm16) 1465 >; 1466 1467 // 1468 // bcond-setlt 1469 // 1470 def: Mips16Pat 1471 <(brcond (i32 (setlt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1472 (BtnezT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) 1473 >; 1474 1475 def: Mips16Pat 1476 <(brcond (i32 (setlt CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16), 1477 (BtnezT8SltiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$imm16) 1478 >; 1479 1480 // 1481 // bcond-setle 1482 // 1483 def: Mips16Pat 1484 <(brcond (i32 (setle CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1485 (BteqzT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16) 1486 >; 1487 1488 // 1489 // bcond-setne 1490 // 1491 def: Mips16Pat 1492 <(brcond (i32 (setne CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1493 (BtnezT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) 1494 >; 1495 1496 def: Mips16Pat 1497 <(brcond (i32 (setne CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16), 1498 (BtnezT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$targ16) 1499 >; 1500 1501 def: Mips16Pat 1502 <(brcond (i32 (setne CPU16Regs:$rx, 0)), bb:$targ16), 1503 (BnezRxImm16 CPU16Regs:$rx, bb:$targ16) 1504 >; 1505 1506 // 1507 // This needs to be there but I forget which code will generate it 1508 // 1509 def: Mips16Pat 1510 <(brcond CPU16Regs:$rx, bb:$targ16), 1511 (BnezRxImm16 CPU16Regs:$rx, bb:$targ16) 1512 >; 1513 1514 // 1515 1516 // 1517 // bcond-setugt 1518 // 1519 //def: Mips16Pat 1520 // <(brcond (i32 (setugt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1521 // (BtnezT8SltuX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16) 1522 // >; 1523 1524 // 1525 // bcond-setuge 1526 // 1527 //def: Mips16Pat 1528 // <(brcond (i32 (setuge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1529 // (BteqzT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) 1530 // >; 1531 1532 1533 // 1534 // bcond-setult 1535 // 1536 //def: Mips16Pat 1537 // <(brcond (i32 (setult CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), 1538 // (BtnezT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) 1539 // >; 1540 1541 def: UncondBranch16_pat<br, Bimm16>; 1542 1543 // Small immediates 1544 def: Mips16Pat<(i32 immSExt16:$in), 1545 (AddiuRxRxImmX16 (MoveR3216 ZERO), immSExt16:$in)>; 1546 1547 def: Mips16Pat<(i32 immZExt16:$in), (LiRxImmX16 immZExt16:$in)>; 1548 1549 // 1550 // MipsDivRem 1551 // 1552 def: Mips16Pat 1553 <(MipsDivRem16 CPU16Regs:$rx, CPU16Regs:$ry), 1554 (DivRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>; 1555 1556 // 1557 // MipsDivRemU 1558 // 1559 def: Mips16Pat 1560 <(MipsDivRemU16 CPU16Regs:$rx, CPU16Regs:$ry), 1561 (DivuRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>; 1562 1563 // signed a,b 1564 // x = (a>=b)?x:y 1565 // 1566 // if !(a < b) x = y 1567 // 1568 def : Mips16Pat<(select (i32 (setge CPU16Regs:$a, CPU16Regs:$b)), 1569 CPU16Regs:$x, CPU16Regs:$y), 1570 (SelTBteqZSlt CPU16Regs:$x, CPU16Regs:$y, 1571 CPU16Regs:$a, CPU16Regs:$b)>; 1572 1573 // signed a,b 1574 // x = (a>b)?x:y 1575 // 1576 // if (b < a) x = y 1577 // 1578 def : Mips16Pat<(select (i32 (setgt CPU16Regs:$a, CPU16Regs:$b)), 1579 CPU16Regs:$x, CPU16Regs:$y), 1580 (SelTBtneZSlt CPU16Regs:$x, CPU16Regs:$y, 1581 CPU16Regs:$b, CPU16Regs:$a)>; 1582 1583 // unsigned a,b 1584 // x = (a>=b)?x:y 1585 // 1586 // if !(a < b) x = y; 1587 // 1588 def : Mips16Pat< 1589 (select (i32 (setuge CPU16Regs:$a, CPU16Regs:$b)), 1590 CPU16Regs:$x, CPU16Regs:$y), 1591 (SelTBteqZSltu CPU16Regs:$x, CPU16Regs:$y, 1592 CPU16Regs:$a, CPU16Regs:$b)>; 1593 1594 // unsigned a,b 1595 // x = (a>b)?x:y 1596 // 1597 // if (b < a) x = y 1598 // 1599 def : Mips16Pat<(select (i32 (setugt CPU16Regs:$a, CPU16Regs:$b)), 1600 CPU16Regs:$x, CPU16Regs:$y), 1601 (SelTBtneZSltu CPU16Regs:$x, CPU16Regs:$y, 1602 CPU16Regs:$b, CPU16Regs:$a)>; 1603 1604 // signed 1605 // x = (a >= k)?x:y 1606 // due to an llvm optimization, i don't think that this will ever 1607 // be used. This is transformed into x = (a > k-1)?x:y 1608 // 1609 // 1610 1611 //def : Mips16Pat< 1612 // (select (i32 (setge CPU16Regs:$lhs, immSExt16:$rhs)), 1613 // CPU16Regs:$T, CPU16Regs:$F), 1614 // (SelTBteqZSlti CPU16Regs:$T, CPU16Regs:$F, 1615 // CPU16Regs:$lhs, immSExt16:$rhs)>; 1616 1617 //def : Mips16Pat< 1618 // (select (i32 (setuge CPU16Regs:$lhs, immSExt16:$rhs)), 1619 // CPU16Regs:$T, CPU16Regs:$F), 1620 // (SelTBteqZSltiu CPU16Regs:$T, CPU16Regs:$F, 1621 // CPU16Regs:$lhs, immSExt16:$rhs)>; 1622 1623 // signed 1624 // x = (a < k)?x:y 1625 // 1626 // if !(a < k) x = y; 1627 // 1628 def : Mips16Pat< 1629 (select (i32 (setlt CPU16Regs:$a, immSExt16:$b)), 1630 CPU16Regs:$x, CPU16Regs:$y), 1631 (SelTBtneZSlti CPU16Regs:$x, CPU16Regs:$y, 1632 CPU16Regs:$a, immSExt16:$b)>; 1633 1634 1635 // 1636 // 1637 // signed 1638 // x = (a <= b)? x : y 1639 // 1640 // if (b < a) x = y 1641 // 1642 def : Mips16Pat<(select (i32 (setle CPU16Regs:$a, CPU16Regs:$b)), 1643 CPU16Regs:$x, CPU16Regs:$y), 1644 (SelTBteqZSlt CPU16Regs:$x, CPU16Regs:$y, 1645 CPU16Regs:$b, CPU16Regs:$a)>; 1646 1647 // 1648 // unnsigned 1649 // x = (a <= b)? x : y 1650 // 1651 // if (b < a) x = y 1652 // 1653 def : Mips16Pat<(select (i32 (setule CPU16Regs:$a, CPU16Regs:$b)), 1654 CPU16Regs:$x, CPU16Regs:$y), 1655 (SelTBteqZSltu CPU16Regs:$x, CPU16Regs:$y, 1656 CPU16Regs:$b, CPU16Regs:$a)>; 1657 1658 // 1659 // signed/unsigned 1660 // x = (a == b)? x : y 1661 // 1662 // if (a != b) x = y 1663 // 1664 def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, CPU16Regs:$b)), 1665 CPU16Regs:$x, CPU16Regs:$y), 1666 (SelTBteqZCmp CPU16Regs:$x, CPU16Regs:$y, 1667 CPU16Regs:$b, CPU16Regs:$a)>; 1668 1669 // 1670 // signed/unsigned 1671 // x = (a == 0)? x : y 1672 // 1673 // if (a != 0) x = y 1674 // 1675 def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, 0)), 1676 CPU16Regs:$x, CPU16Regs:$y), 1677 (SelBeqZ CPU16Regs:$x, CPU16Regs:$y, 1678 CPU16Regs:$a)>; 1679 1680 1681 // 1682 // signed/unsigned 1683 // x = (a == k)? x : y 1684 // 1685 // if (a != k) x = y 1686 // 1687 def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, immZExt16:$k)), 1688 CPU16Regs:$x, CPU16Regs:$y), 1689 (SelTBteqZCmpi CPU16Regs:$x, CPU16Regs:$y, 1690 CPU16Regs:$a, immZExt16:$k)>; 1691 1692 1693 // 1694 // signed/unsigned 1695 // x = (a != b)? x : y 1696 // 1697 // if (a == b) x = y 1698 // 1699 // 1700 def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, CPU16Regs:$b)), 1701 CPU16Regs:$x, CPU16Regs:$y), 1702 (SelTBtneZCmp CPU16Regs:$x, CPU16Regs:$y, 1703 CPU16Regs:$b, CPU16Regs:$a)>; 1704 1705 // 1706 // signed/unsigned 1707 // x = (a != 0)? x : y 1708 // 1709 // if (a == 0) x = y 1710 // 1711 def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, 0)), 1712 CPU16Regs:$x, CPU16Regs:$y), 1713 (SelBneZ CPU16Regs:$x, CPU16Regs:$y, 1714 CPU16Regs:$a)>; 1715 1716 // signed/unsigned 1717 // x = (a)? x : y 1718 // 1719 // if (!a) x = y 1720 // 1721 def : Mips16Pat<(select CPU16Regs:$a, 1722 CPU16Regs:$x, CPU16Regs:$y), 1723 (SelBneZ CPU16Regs:$x, CPU16Regs:$y, 1724 CPU16Regs:$a)>; 1725 1726 1727 // 1728 // signed/unsigned 1729 // x = (a != k)? x : y 1730 // 1731 // if (a == k) x = y 1732 // 1733 def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, immZExt16:$k)), 1734 CPU16Regs:$x, CPU16Regs:$y), 1735 (SelTBtneZCmpi CPU16Regs:$x, CPU16Regs:$y, 1736 CPU16Regs:$a, immZExt16:$k)>; 1737 1738 // 1739 // When writing C code to test setxx these patterns, 1740 // some will be transformed into 1741 // other things. So we test using C code but using -O3 and -O0 1742 // 1743 // seteq 1744 // 1745 def : Mips16Pat 1746 <(seteq CPU16Regs:$lhs,CPU16Regs:$rhs), 1747 (SltiuCCRxImmX16 (XorRxRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs), 1)>; 1748 1749 def : Mips16Pat 1750 <(seteq CPU16Regs:$lhs, 0), 1751 (SltiuCCRxImmX16 CPU16Regs:$lhs, 1)>; 1752 1753 1754 // 1755 // setge 1756 // 1757 1758 def: Mips16Pat 1759 <(setge CPU16Regs:$lhs, CPU16Regs:$rhs), 1760 (XorRxRxRy16 (SltCCRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs), 1761 (LiRxImmX16 1))>; 1762 1763 // 1764 // For constants, llvm transforms this to: 1765 // x > (k - 1) and then reverses the operands to use setlt. So this pattern 1766 // is not used now by the compiler. (Presumably checking that k-1 does not 1767 // overflow). The compiler never uses this at the current time, due to 1768 // other optimizations. 1769 // 1770 //def: Mips16Pat 1771 // <(setge CPU16Regs:$lhs, immSExt16:$rhs), 1772 // (XorRxRxRy16 (SltiCCRxImmX16 CPU16Regs:$lhs, immSExt16:$rhs), 1773 // (LiRxImmX16 1))>; 1774 1775 // This catches the x >= -32768 case by transforming it to x > -32769 1776 // 1777 def: Mips16Pat 1778 <(setgt CPU16Regs:$lhs, -32769), 1779 (XorRxRxRy16 (SltiCCRxImmX16 CPU16Regs:$lhs, -32768), 1780 (LiRxImmX16 1))>; 1781 1782 // 1783 // setgt 1784 // 1785 // 1786 1787 def: Mips16Pat 1788 <(setgt CPU16Regs:$lhs, CPU16Regs:$rhs), 1789 (SltCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs)>; 1790 1791 // 1792 // setle 1793 // 1794 def: Mips16Pat 1795 <(setle CPU16Regs:$lhs, CPU16Regs:$rhs), 1796 (XorRxRxRy16 (SltCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs), (LiRxImm16 1))>; 1797 1798 // 1799 // setlt 1800 // 1801 def: SetCC_R16<setlt, SltCCRxRy16>; 1802 1803 def: SetCC_I16<setlt, immSExt16, SltiCCRxImmX16>; 1804 1805 // 1806 // setne 1807 // 1808 def : Mips16Pat 1809 <(setne CPU16Regs:$lhs,CPU16Regs:$rhs), 1810 (SltuCCRxRy16 (LiRxImmX16 0), 1811 (XorRxRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs))>; 1812 1813 1814 // 1815 // setuge 1816 // 1817 def: Mips16Pat 1818 <(setuge CPU16Regs:$lhs, CPU16Regs:$rhs), 1819 (XorRxRxRy16 (SltuCCRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs), 1820 (LiRxImmX16 1))>; 1821 1822 // this pattern will never be used because the compiler will transform 1823 // x >= k to x > (k - 1) and then use SLT 1824 // 1825 //def: Mips16Pat 1826 // <(setuge CPU16Regs:$lhs, immZExt16:$rhs), 1827 // (XorRxRxRy16 (SltiuCCRxImmX16 CPU16Regs:$lhs, immZExt16:$rhs), 1828 // (LiRxImmX16 1))>; 1829 1830 // 1831 // setugt 1832 // 1833 def: Mips16Pat 1834 <(setugt CPU16Regs:$lhs, CPU16Regs:$rhs), 1835 (SltuCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs)>; 1836 1837 // 1838 // setule 1839 // 1840 def: Mips16Pat 1841 <(setule CPU16Regs:$lhs, CPU16Regs:$rhs), 1842 (XorRxRxRy16 (SltuCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs), (LiRxImmX16 1))>; 1843 1844 // 1845 // setult 1846 // 1847 def: SetCC_R16<setult, SltuCCRxRy16>; 1848 1849 def: SetCC_I16<setult, immSExt16, SltiuCCRxImmX16>; 1850 1851 def: Mips16Pat<(add CPU16Regs:$hi, (MipsLo tglobaladdr:$lo)), 1852 (AddiuRxRxImmX16 CPU16Regs:$hi, tglobaladdr:$lo)>; 1853 1854 // hi/lo relocs 1855 def : Mips16Pat<(MipsHi tblockaddress:$in), 1856 (SllX16 (LiRxImmX16 tblockaddress:$in), 16)>; 1857 def : Mips16Pat<(MipsHi tglobaladdr:$in), 1858 (SllX16 (LiRxImmX16 tglobaladdr:$in), 16)>; 1859 def : Mips16Pat<(MipsHi tjumptable:$in), 1860 (SllX16 (LiRxImmX16 tjumptable:$in), 16)>; 1861 1862 def : Mips16Pat<(MipsLo tblockaddress:$in), (LiRxImmX16 tblockaddress:$in)>; 1863 1864 def : Mips16Pat<(MipsTlsHi tglobaltlsaddr:$in), 1865 (SllX16 (LiRxImmX16 tglobaltlsaddr:$in), 16)>; 1866 1867 // wrapper_pic 1868 class Wrapper16Pat<SDNode node, Instruction ADDiuOp, RegisterClass RC>: 1869 Mips16Pat<(MipsWrapper RC:$gp, node:$in), 1870 (ADDiuOp RC:$gp, node:$in)>; 1871 1872 1873 def : Wrapper16Pat<tglobaladdr, AddiuRxRxImmX16, CPU16Regs>; 1874 def : Wrapper16Pat<tglobaltlsaddr, AddiuRxRxImmX16, CPU16Regs>; 1875 1876 def : Mips16Pat<(i32 (extloadi8 addr16:$src)), 1877 (LbuRxRyOffMemX16 addr16:$src)>; 1878 def : Mips16Pat<(i32 (extloadi16 addr16:$src)), 1879 (LhuRxRyOffMemX16 addr16:$src)>; 1880 1881 def: Mips16Pat<(trap), (Break16)>; 1882 1883 def : Mips16Pat<(sext_inreg CPU16Regs:$val, i8), 1884 (SebRx16 CPU16Regs:$val)>; 1885 1886 def : Mips16Pat<(sext_inreg CPU16Regs:$val, i16), 1887 (SehRx16 CPU16Regs:$val)>; 1888 1889 def GotPrologue16: 1890 MipsPseudo16< 1891 (outs CPU16Regs:$rh, CPU16Regs:$rl), 1892 (ins simm16:$immHi, simm16:$immLo), 1893 "li\t$rh, $immHi\n\taddiu\t$rl, $$pc, $immLo\n ",[]> ; 1894 1895 // An operand for the CONSTPOOL_ENTRY pseudo-instruction. 1896 def cpinst_operand : Operand<i32> { 1897 // let PrintMethod = "printCPInstOperand"; 1898 } 1899 1900 // CONSTPOOL_ENTRY - This instruction represents a floating constant pool in 1901 // the function. The first operand is the ID# for this instruction, the second 1902 // is the index into the MachineConstantPool that this is, the third is the 1903 // size in bytes of this constant pool entry. 1904 // 1905 let hasSideEffects = 0, isNotDuplicable = 1 in 1906 def CONSTPOOL_ENTRY : 1907 MipsPseudo16<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx, 1908 i32imm:$size), "foo", []>; 1909 1910 // Instruction Aliases 1911 1912 let EncodingPredicates = [InMips16Mode] in 1913 def : MipsInstAlias<"nop", (Move32R16 ZERO, S0)>; 1914