1 //===----------------------------------------------------------------------===// 2 // MicroMIPS Base Classes 3 //===----------------------------------------------------------------------===// 4 5 // 6 // Base class for MicroMips instructions. 7 // This class does not depend on the instruction size. 8 // 9 class MicroMipsInstBase<dag outs, dag ins, string asmstr, list<dag> pattern, 10 InstrItinClass itin, Format f> : Instruction 11 { 12 let Namespace = "Mips"; 13 let DecoderNamespace = "MicroMips"; 14 15 let OutOperandList = outs; 16 let InOperandList = ins; 17 18 let AsmString = asmstr; 19 let Pattern = pattern; 20 let Itinerary = itin; 21 22 let Predicates = [InMicroMips]; 23 24 Format Form = f; 25 } 26 27 // 28 // Base class for MicroMIPS 16-bit instructions. 29 // 30 class MicroMipsInst16<dag outs, dag ins, string asmstr, list<dag> pattern, 31 InstrItinClass itin, Format f> : 32 MicroMipsInstBase<outs, ins, asmstr, pattern, itin, f> 33 { 34 let Size = 2; 35 field bits<16> Inst; 36 field bits<16> SoftFail = 0; 37 bits<6> Opcode = 0x0; 38 } 39 40 //===----------------------------------------------------------------------===// 41 // MicroMIPS 16-bit Instruction Formats 42 //===----------------------------------------------------------------------===// 43 44 class MOVE_FM_MM16<bits<6> funct> { 45 bits<5> rs; 46 bits<5> rd; 47 48 bits<16> Inst; 49 50 let Inst{15-10} = funct; 51 let Inst{9-5} = rd; 52 let Inst{4-0} = rs; 53 } 54 55 class JALR_FM_MM16<bits<5> op> { 56 bits<5> rs; 57 58 bits<16> Inst; 59 60 let Inst{15-10} = 0x11; 61 let Inst{9-5} = op; 62 let Inst{4-0} = rs; 63 } 64 65 class MFHILO_FM_MM16<bits<5> funct> { 66 bits<5> rd; 67 68 bits<16> Inst; 69 70 let Inst{15-10} = 0x11; 71 let Inst{9-5} = funct; 72 let Inst{4-0} = rd; 73 } 74 75 //===----------------------------------------------------------------------===// 76 // MicroMIPS 32-bit Instruction Formats 77 //===----------------------------------------------------------------------===// 78 79 class MMArch { 80 string Arch = "micromips"; 81 list<dag> Pattern = []; 82 } 83 84 class ADD_FM_MM<bits<6> op, bits<10> funct> : MMArch { 85 bits<5> rt; 86 bits<5> rs; 87 bits<5> rd; 88 89 bits<32> Inst; 90 91 let Inst{31-26} = op; 92 let Inst{25-21} = rt; 93 let Inst{20-16} = rs; 94 let Inst{15-11} = rd; 95 let Inst{10} = 0; 96 let Inst{9-0} = funct; 97 } 98 99 class ADDI_FM_MM<bits<6> op> : MMArch { 100 bits<5> rs; 101 bits<5> rt; 102 bits<16> imm16; 103 104 bits<32> Inst; 105 106 let Inst{31-26} = op; 107 let Inst{25-21} = rt; 108 let Inst{20-16} = rs; 109 let Inst{15-0} = imm16; 110 } 111 112 class SLTI_FM_MM<bits<6> op> : MMArch { 113 bits<5> rt; 114 bits<5> rs; 115 bits<16> imm16; 116 117 bits<32> Inst; 118 119 let Inst{31-26} = op; 120 let Inst{25-21} = rt; 121 let Inst{20-16} = rs; 122 let Inst{15-0} = imm16; 123 } 124 125 class LUI_FM_MM : MMArch { 126 bits<5> rt; 127 bits<16> imm16; 128 129 bits<32> Inst; 130 131 let Inst{31-26} = 0x10; 132 let Inst{25-21} = 0xd; 133 let Inst{20-16} = rt; 134 let Inst{15-0} = imm16; 135 } 136 137 class MULT_FM_MM<bits<10> funct> : MMArch { 138 bits<5> rs; 139 bits<5> rt; 140 141 bits<32> Inst; 142 143 let Inst{31-26} = 0x00; 144 let Inst{25-21} = rt; 145 let Inst{20-16} = rs; 146 let Inst{15-6} = funct; 147 let Inst{5-0} = 0x3c; 148 } 149 150 class SRA_FM_MM<bits<10> funct, bit rotate> : MMArch { 151 bits<5> rd; 152 bits<5> rt; 153 bits<5> shamt; 154 155 bits<32> Inst; 156 157 let Inst{31-26} = 0; 158 let Inst{25-21} = rd; 159 let Inst{20-16} = rt; 160 let Inst{15-11} = shamt; 161 let Inst{10} = rotate; 162 let Inst{9-0} = funct; 163 } 164 165 class SRLV_FM_MM<bits<10> funct, bit rotate> : MMArch { 166 bits<5> rd; 167 bits<5> rt; 168 bits<5> rs; 169 170 bits<32> Inst; 171 172 let Inst{31-26} = 0; 173 let Inst{25-21} = rt; 174 let Inst{20-16} = rs; 175 let Inst{15-11} = rd; 176 let Inst{10} = rotate; 177 let Inst{9-0} = funct; 178 } 179 180 class LW_FM_MM<bits<6> op> : MMArch { 181 bits<5> rt; 182 bits<21> addr; 183 184 bits<32> Inst; 185 186 let Inst{31-26} = op; 187 let Inst{25-21} = rt; 188 let Inst{20-16} = addr{20-16}; 189 let Inst{15-0} = addr{15-0}; 190 } 191 192 class LWL_FM_MM<bits<4> funct> { 193 bits<5> rt; 194 bits<21> addr; 195 196 bits<32> Inst; 197 198 let Inst{31-26} = 0x18; 199 let Inst{25-21} = rt; 200 let Inst{20-16} = addr{20-16}; 201 let Inst{15-12} = funct; 202 let Inst{11-0} = addr{11-0}; 203 } 204 205 class CMov_F_I_FM_MM<bits<7> func> : MMArch { 206 bits<5> rd; 207 bits<5> rs; 208 bits<3> fcc; 209 210 bits<32> Inst; 211 212 let Inst{31-26} = 0x15; 213 let Inst{25-21} = rd; 214 let Inst{20-16} = rs; 215 let Inst{15-13} = fcc; 216 let Inst{12-6} = func; 217 let Inst{5-0} = 0x3b; 218 } 219 220 class MTLO_FM_MM<bits<10> funct> : MMArch { 221 bits<5> rs; 222 223 bits<32> Inst; 224 225 let Inst{31-26} = 0x00; 226 let Inst{25-21} = 0x00; 227 let Inst{20-16} = rs; 228 let Inst{15-6} = funct; 229 let Inst{5-0} = 0x3c; 230 } 231 232 class MFLO_FM_MM<bits<10> funct> : MMArch { 233 bits<5> rd; 234 235 bits<32> Inst; 236 237 let Inst{31-26} = 0x00; 238 let Inst{25-21} = 0x00; 239 let Inst{20-16} = rd; 240 let Inst{15-6} = funct; 241 let Inst{5-0} = 0x3c; 242 } 243 244 class CLO_FM_MM<bits<10> funct> : MMArch { 245 bits<5> rd; 246 bits<5> rs; 247 248 bits<32> Inst; 249 250 let Inst{31-26} = 0x00; 251 let Inst{25-21} = rd; 252 let Inst{20-16} = rs; 253 let Inst{15-6} = funct; 254 let Inst{5-0} = 0x3c; 255 } 256 257 class SEB_FM_MM<bits<10> funct> : MMArch { 258 bits<5> rd; 259 bits<5> rt; 260 261 bits<32> Inst; 262 263 let Inst{31-26} = 0x00; 264 let Inst{25-21} = rd; 265 let Inst{20-16} = rt; 266 let Inst{15-6} = funct; 267 let Inst{5-0} = 0x3c; 268 } 269 270 class EXT_FM_MM<bits<6> funct> : MMArch { 271 bits<5> rt; 272 bits<5> rs; 273 bits<5> pos; 274 bits<5> size; 275 276 bits<32> Inst; 277 278 let Inst{31-26} = 0x00; 279 let Inst{25-21} = rt; 280 let Inst{20-16} = rs; 281 let Inst{15-11} = size; 282 let Inst{10-6} = pos; 283 let Inst{5-0} = funct; 284 } 285 286 class J_FM_MM<bits<6> op> : MMArch { 287 bits<26> target; 288 289 bits<32> Inst; 290 291 let Inst{31-26} = op; 292 let Inst{25-0} = target; 293 } 294 295 class JR_FM_MM<bits<8> funct> : MMArch { 296 bits<5> rs; 297 298 bits<32> Inst; 299 300 let Inst{31-21} = 0x00; 301 let Inst{20-16} = rs; 302 let Inst{15-14} = 0x0; 303 let Inst{13-6} = funct; 304 let Inst{5-0} = 0x3c; 305 } 306 307 class JALR_FM_MM<bits<10> funct> { 308 bits<5> rs; 309 bits<5> rd; 310 311 bits<32> Inst; 312 313 let Inst{31-26} = 0x00; 314 let Inst{25-21} = rd; 315 let Inst{20-16} = rs; 316 let Inst{15-6} = funct; 317 let Inst{5-0} = 0x3c; 318 } 319 320 class BEQ_FM_MM<bits<6> op> : MMArch { 321 bits<5> rs; 322 bits<5> rt; 323 bits<16> offset; 324 325 bits<32> Inst; 326 327 let Inst{31-26} = op; 328 let Inst{25-21} = rt; 329 let Inst{20-16} = rs; 330 let Inst{15-0} = offset; 331 } 332 333 class BGEZ_FM_MM<bits<5> funct> : MMArch { 334 bits<5> rs; 335 bits<16> offset; 336 337 bits<32> Inst; 338 339 let Inst{31-26} = 0x10; 340 let Inst{25-21} = funct; 341 let Inst{20-16} = rs; 342 let Inst{15-0} = offset; 343 } 344 345 class BGEZAL_FM_MM<bits<5> funct> : MMArch { 346 bits<5> rs; 347 bits<16> offset; 348 349 bits<32> Inst; 350 351 let Inst{31-26} = 0x10; 352 let Inst{25-21} = funct; 353 let Inst{20-16} = rs; 354 let Inst{15-0} = offset; 355 } 356 357 class SYNC_FM_MM : MMArch { 358 bits<5> stype; 359 360 bits<32> Inst; 361 362 let Inst{31-26} = 0x00; 363 let Inst{25-21} = 0x0; 364 let Inst{20-16} = stype; 365 let Inst{15-6} = 0x1ad; 366 let Inst{5-0} = 0x3c; 367 } 368 369 class BRK_FM_MM : MMArch { 370 bits<10> code_1; 371 bits<10> code_2; 372 bits<32> Inst; 373 let Inst{31-26} = 0x0; 374 let Inst{25-16} = code_1; 375 let Inst{15-6} = code_2; 376 let Inst{5-0} = 0x07; 377 } 378 379 class SYS_FM_MM : MMArch { 380 bits<10> code_; 381 bits<32> Inst; 382 let Inst{31-26} = 0x0; 383 let Inst{25-16} = code_; 384 let Inst{15-6} = 0x22d; 385 let Inst{5-0} = 0x3c; 386 } 387 388 class WAIT_FM_MM { 389 bits<10> code_; 390 bits<32> Inst; 391 392 let Inst{31-26} = 0x00; 393 let Inst{25-16} = code_; 394 let Inst{15-6} = 0x24d; 395 let Inst{5-0} = 0x3c; 396 } 397 398 class ER_FM_MM<bits<10> funct> : MMArch { 399 bits<32> Inst; 400 401 let Inst{31-26} = 0x00; 402 let Inst{25-16} = 0x00; 403 let Inst{15-6} = funct; 404 let Inst{5-0} = 0x3c; 405 } 406 407 class EI_FM_MM<bits<10> funct> : MMArch { 408 bits<32> Inst; 409 bits<5> rt; 410 411 let Inst{31-26} = 0x00; 412 let Inst{25-21} = 0x00; 413 let Inst{20-16} = rt; 414 let Inst{15-6} = funct; 415 let Inst{5-0} = 0x3c; 416 } 417 418 class TEQ_FM_MM<bits<6> funct> : MMArch { 419 bits<5> rs; 420 bits<5> rt; 421 bits<4> code_; 422 423 bits<32> Inst; 424 425 let Inst{31-26} = 0x00; 426 let Inst{25-21} = rt; 427 let Inst{20-16} = rs; 428 let Inst{15-12} = code_; 429 let Inst{11-6} = funct; 430 let Inst{5-0} = 0x3c; 431 } 432 433 class TEQI_FM_MM<bits<5> funct> : MMArch { 434 bits<5> rs; 435 bits<16> imm16; 436 437 bits<32> Inst; 438 439 let Inst{31-26} = 0x10; 440 let Inst{25-21} = funct; 441 let Inst{20-16} = rs; 442 let Inst{15-0} = imm16; 443 } 444 445 class LL_FM_MM<bits<4> funct> { 446 bits<5> rt; 447 bits<21> addr; 448 449 bits<32> Inst; 450 451 let Inst{31-26} = 0x18; 452 let Inst{25-21} = rt; 453 let Inst{20-16} = addr{20-16}; 454 let Inst{15-12} = funct; 455 let Inst{11-0} = addr{11-0}; 456 } 457 458 class ADDS_FM_MM<bits<2> fmt, bits<8> funct> : MMArch { 459 bits<5> ft; 460 bits<5> fs; 461 bits<5> fd; 462 463 bits<32> Inst; 464 465 let Inst{31-26} = 0x15; 466 let Inst{25-21} = ft; 467 let Inst{20-16} = fs; 468 let Inst{15-11} = fd; 469 let Inst{10} = 0; 470 let Inst{9-8} = fmt; 471 let Inst{7-0} = funct; 472 473 list<dag> Pattern = []; 474 } 475 476 class LWXC1_FM_MM<bits<9> funct> : MMArch { 477 bits<5> fd; 478 bits<5> base; 479 bits<5> index; 480 481 bits<32> Inst; 482 483 let Inst{31-26} = 0x15; 484 let Inst{25-21} = index; 485 let Inst{20-16} = base; 486 let Inst{15-11} = fd; 487 let Inst{10-9} = 0x0; 488 let Inst{8-0} = funct; 489 } 490 491 class SWXC1_FM_MM<bits<9> funct> : MMArch { 492 bits<5> fs; 493 bits<5> base; 494 bits<5> index; 495 496 bits<32> Inst; 497 498 let Inst{31-26} = 0x15; 499 let Inst{25-21} = index; 500 let Inst{20-16} = base; 501 let Inst{15-11} = fs; 502 let Inst{10-9} = 0x0; 503 let Inst{8-0} = funct; 504 } 505 506 class CEQS_FM_MM<bits<2> fmt> : MMArch { 507 bits<5> fs; 508 bits<5> ft; 509 bits<4> cond; 510 511 bits<32> Inst; 512 513 let Inst{31-26} = 0x15; 514 let Inst{25-21} = ft; 515 let Inst{20-16} = fs; 516 let Inst{15-13} = 0x0; // cc 517 let Inst{12} = 0; 518 let Inst{11-10} = fmt; 519 let Inst{9-6} = cond; 520 let Inst{5-0} = 0x3c; 521 } 522 523 class BC1F_FM_MM<bits<5> tf> : MMArch { 524 bits<16> offset; 525 526 bits<32> Inst; 527 528 let Inst{31-26} = 0x10; 529 let Inst{25-21} = tf; 530 let Inst{20-18} = 0x0; // cc 531 let Inst{17-16} = 0x0; 532 let Inst{15-0} = offset; 533 } 534 535 class ROUND_W_FM_MM<bits<1> fmt, bits<8> funct> : MMArch { 536 bits<5> fd; 537 bits<5> fs; 538 539 bits<32> Inst; 540 541 let Inst{31-26} = 0x15; 542 let Inst{25-21} = fd; 543 let Inst{20-16} = fs; 544 let Inst{15} = 0; 545 let Inst{14} = fmt; 546 let Inst{13-6} = funct; 547 let Inst{5-0} = 0x3b; 548 } 549 550 class ABS_FM_MM<bits<2> fmt, bits<7> funct> : MMArch { 551 bits<5> fd; 552 bits<5> fs; 553 554 bits<32> Inst; 555 556 let Inst{31-26} = 0x15; 557 let Inst{25-21} = fd; 558 let Inst{20-16} = fs; 559 let Inst{15} = 0; 560 let Inst{14-13} = fmt; 561 let Inst{12-6} = funct; 562 let Inst{5-0} = 0x3b; 563 } 564 565 class CMov_F_F_FM_MM<bits<9> func, bits<2> fmt> : MMArch { 566 bits<5> fd; 567 bits<5> fs; 568 569 bits<32> Inst; 570 571 let Inst{31-26} = 0x15; 572 let Inst{25-21} = fd; 573 let Inst{20-16} = fs; 574 let Inst{15-13} = 0x0; //cc 575 let Inst{12-11} = 0x0; 576 let Inst{10-9} = fmt; 577 let Inst{8-0} = func; 578 } 579 580 class CMov_I_F_FM_MM<bits<8> funct, bits<2> fmt> : MMArch { 581 bits<5> fd; 582 bits<5> fs; 583 bits<5> rt; 584 585 bits<32> Inst; 586 587 let Inst{31-26} = 0x15; 588 let Inst{25-21} = rt; 589 let Inst{20-16} = fs; 590 let Inst{15-11} = fd; 591 let Inst{9-8} = fmt; 592 let Inst{7-0} = funct; 593 } 594 595 class MFC1_FM_MM<bits<8> funct> : MMArch { 596 bits<5> rt; 597 bits<5> fs; 598 599 bits<32> Inst; 600 601 let Inst{31-26} = 0x15; 602 let Inst{25-21} = rt; 603 let Inst{20-16} = fs; 604 let Inst{15-14} = 0x0; 605 let Inst{13-6} = funct; 606 let Inst{5-0} = 0x3b; 607 } 608 609 class MADDS_FM_MM<bits<6> funct>: MMArch { 610 bits<5> ft; 611 bits<5> fs; 612 bits<5> fd; 613 bits<5> fr; 614 615 bits<32> Inst; 616 617 let Inst{31-26} = 0x15; 618 let Inst{25-21} = ft; 619 let Inst{20-16} = fs; 620 let Inst{15-11} = fd; 621 let Inst{10-6} = fr; 622 let Inst{5-0} = funct; 623 } 624