OLD | NEW |
---|---|
1 //===- subzero/src/IceAssemblerMIPS32.cpp - MIPS32 Assembler --------------===// | 1 //===- subzero/src/IceAssemblerMIPS32.cpp - MIPS32 Assembler --------------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 const IValueT Rs = encodeGPRegister(OpRs, "Rs", InsnName); | 247 const IValueT Rs = encodeGPRegister(OpRs, "Rs", InsnName); |
248 const IValueT Rt = encodeGPRegister(OpRt, "Rt", InsnName); | 248 const IValueT Rt = encodeGPRegister(OpRt, "Rt", InsnName); |
249 | 249 |
250 Opcode |= Rs << 21; | 250 Opcode |= Rs << 21; |
251 Opcode |= Rt << 16; | 251 Opcode |= Rt << 16; |
252 Opcode |= Rd << 11; | 252 Opcode |= Rd << 11; |
253 | 253 |
254 emitInst(Opcode); | 254 emitInst(Opcode); |
255 } | 255 } |
256 | 256 |
257 void AssemblerMIPS32::emitCOP1Fcmp(IValueT Opcode, FPInstDataFormat Format, | |
258 const Operand *OpFs, const Operand *OpFt, | |
259 IValueT CC, const char *InsnName) { | |
260 const IValueT Fs = encodeFPRegister(OpFs, "Fs", InsnName); | |
261 const IValueT Ft = encodeFPRegister(OpFt, "Ft", InsnName); | |
262 | |
263 Opcode |= CC << 8; | |
264 Opcode |= Fs << 11; | |
265 Opcode |= Ft << 16; | |
266 Opcode |= Format << 21; | |
267 | |
268 emitInst(Opcode); | |
269 } | |
270 | |
257 void AssemblerMIPS32::emitCOP1FmtFsFd(IValueT Opcode, FPInstDataFormat Format, | 271 void AssemblerMIPS32::emitCOP1FmtFsFd(IValueT Opcode, FPInstDataFormat Format, |
258 const Operand *OpFd, const Operand *OpFs, | 272 const Operand *OpFd, const Operand *OpFs, |
259 const char *InsnName) { | 273 const char *InsnName) { |
260 const IValueT Fd = encodeFPRegister(OpFd, "Fd", InsnName); | 274 const IValueT Fd = encodeFPRegister(OpFd, "Fd", InsnName); |
261 const IValueT Fs = encodeFPRegister(OpFs, "Fs", InsnName); | 275 const IValueT Fs = encodeFPRegister(OpFs, "Fs", InsnName); |
262 | 276 |
263 Opcode |= Fd << 6; | 277 Opcode |= Fd << 6; |
264 Opcode |= Fs << 11; | 278 Opcode |= Fs << 11; |
265 Opcode |= Format << 21; | 279 Opcode |= Format << 21; |
266 | 280 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 if (TargetLabel->isBound()) { | 378 if (TargetLabel->isBound()) { |
365 const int32_t Dest = TargetLabel->getPosition() - Buffer.size(); | 379 const int32_t Dest = TargetLabel->getPosition() - Buffer.size(); |
366 emitBr(CondMIPS32::AL, OpRsNone, OpRtNone, Dest); | 380 emitBr(CondMIPS32::AL, OpRsNone, OpRtNone, Dest); |
367 return; | 381 return; |
368 } | 382 } |
369 const IOffsetT Position = Buffer.size(); | 383 const IOffsetT Position = Buffer.size(); |
370 emitBr(CondMIPS32::AL, OpRsNone, OpRtNone, TargetLabel->getEncodedPosition()); | 384 emitBr(CondMIPS32::AL, OpRsNone, OpRtNone, TargetLabel->getEncodedPosition()); |
371 TargetLabel->linkTo(*this, Position); | 385 TargetLabel->linkTo(*this, Position); |
372 } | 386 } |
373 | 387 |
388 void AssemblerMIPS32::c_eq_d(const Operand *OpFs, const Operand *OpFt) { | |
389 static constexpr IValueT Opcode = 0x44000032; | |
390 emitCOP1Fcmp(Opcode, DoublePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
391 "c.eq.d"); | |
392 } | |
393 | |
394 void AssemblerMIPS32::c_eq_s(const Operand *OpFs, const Operand *OpFt) { | |
395 static constexpr IValueT Opcode = 0x44000032; | |
396 emitCOP1Fcmp(Opcode, SinglePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
397 "c.eq.s"); | |
398 } | |
399 | |
400 void AssemblerMIPS32::c_ole_d(const Operand *OpFs, const Operand *OpFt) { | |
401 static constexpr IValueT Opcode = 0x44000036; | |
402 emitCOP1Fcmp(Opcode, DoublePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
403 "c.ole.d"); | |
404 } | |
405 | |
406 void AssemblerMIPS32::c_ole_s(const Operand *OpFs, const Operand *OpFt) { | |
407 static constexpr IValueT Opcode = 0x44000036; | |
408 emitCOP1Fcmp(Opcode, SinglePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
409 "c.ole.s"); | |
410 } | |
411 | |
412 void AssemblerMIPS32::c_olt_d(const Operand *OpFs, const Operand *OpFt) { | |
413 static constexpr IValueT Opcode = 0x44000034; | |
414 emitCOP1Fcmp(Opcode, DoublePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
415 "c.olt.d"); | |
416 } | |
417 | |
418 void AssemblerMIPS32::c_olt_s(const Operand *OpFs, const Operand *OpFt) { | |
419 static constexpr IValueT Opcode = 0x44000034; | |
420 emitCOP1Fcmp(Opcode, SinglePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
421 "c.olt.s"); | |
422 } | |
423 | |
424 void AssemblerMIPS32::c_ueq_d(const Operand *OpFs, const Operand *OpFt) { | |
425 static constexpr IValueT Opcode = 0x44000033; | |
426 emitCOP1Fcmp(Opcode, DoublePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
427 "c.ueq.d"); | |
428 } | |
429 | |
430 void AssemblerMIPS32::c_ueq_s(const Operand *OpFs, const Operand *OpFt) { | |
431 static constexpr IValueT Opcode = 0x44000033; | |
432 emitCOP1Fcmp(Opcode, SinglePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
433 "c.ueq.s"); | |
434 } | |
435 | |
436 void AssemblerMIPS32::c_ule_d(const Operand *OpFs, const Operand *OpFt) { | |
437 static constexpr IValueT Opcode = 0x44000037; | |
438 emitCOP1Fcmp(Opcode, DoublePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
439 "c.ule.d"); | |
440 } | |
441 | |
442 void AssemblerMIPS32::c_ule_s(const Operand *OpFs, const Operand *OpFt) { | |
443 static constexpr IValueT Opcode = 0x44000037; | |
444 emitCOP1Fcmp(Opcode, SinglePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
445 "c.ule.s"); | |
446 } | |
447 | |
448 void AssemblerMIPS32::c_ult_d(const Operand *OpFs, const Operand *OpFt) { | |
449 static constexpr IValueT Opcode = 0x44000035; | |
450 emitCOP1Fcmp(Opcode, DoublePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
451 "c.ult.d"); | |
452 } | |
453 | |
454 void AssemblerMIPS32::c_ult_s(const Operand *OpFs, const Operand *OpFt) { | |
455 static constexpr IValueT Opcode = 0x44000035; | |
456 emitCOP1Fcmp(Opcode, SinglePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
457 "c.ult.s"); | |
458 } | |
459 | |
460 void AssemblerMIPS32::c_un_d(const Operand *OpFs, const Operand *OpFt) { | |
461 static constexpr IValueT Opcode = 0x44000031; | |
462 emitCOP1Fcmp(Opcode, DoublePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
463 "c.un.d"); | |
464 } | |
465 | |
466 void AssemblerMIPS32::c_un_s(const Operand *OpFs, const Operand *OpFt) { | |
467 static constexpr IValueT Opcode = 0x44000031; | |
468 emitCOP1Fcmp(Opcode, SinglePrecision, OpFs, OpFt, OperandMIPS32FCC::FCC0, | |
469 "c.un.s"); | |
470 } | |
471 | |
374 void AssemblerMIPS32::cvt_d_l(const Operand *OpFd, const Operand *OpFs) { | 472 void AssemblerMIPS32::cvt_d_l(const Operand *OpFd, const Operand *OpFs) { |
375 static constexpr IValueT Opcode = 0x44000021; | 473 static constexpr IValueT Opcode = 0x44000021; |
376 emitCOP1FmtFsFd(Opcode, Long, OpFd, OpFs, "cvt.d.l"); | 474 emitCOP1FmtFsFd(Opcode, Long, OpFd, OpFs, "cvt.d.l"); |
377 } | 475 } |
378 | 476 |
379 void AssemblerMIPS32::cvt_d_s(const Operand *OpFd, const Operand *OpFs) { | 477 void AssemblerMIPS32::cvt_d_s(const Operand *OpFd, const Operand *OpFs) { |
380 static constexpr IValueT Opcode = 0x44000021; | 478 static constexpr IValueT Opcode = 0x44000021; |
381 emitCOP1FmtFsFd(Opcode, SinglePrecision, OpFd, OpFs, "cvt.d.s"); | 479 emitCOP1FmtFsFd(Opcode, SinglePrecision, OpFd, OpFs, "cvt.d.s"); |
382 } | 480 } |
383 | 481 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 Opcode |= Rt << 16; | 588 Opcode |= Rt << 16; |
491 Opcode |= Rd << 11; | 589 Opcode |= Rd << 11; |
492 emitInst(Opcode); | 590 emitInst(Opcode); |
493 break; | 591 break; |
494 } | 592 } |
495 default: { UnimplementedError(getFlags()); } | 593 default: { UnimplementedError(getFlags()); } |
496 } | 594 } |
497 } | 595 } |
498 } | 596 } |
499 | 597 |
598 void AssemblerMIPS32::movf(const Operand *OpRd, const Operand *OpRs, | |
599 const Operand *OpCc) { | |
600 IValueT Opcode = 0x00000001; | |
601 const IValueT Rd = encodeGPRegister(OpRd, "Rd", "movf"); | |
602 const IValueT Rs = encodeGPRegister(OpRs, "Rs", "movf"); | |
603 OperandMIPS32FCC::FCC Cc = OperandMIPS32FCC::FCC0; | |
604 if (const auto *OpFCC = llvm::dyn_cast<OperandMIPS32FCC>(OpCc)) { | |
605 Cc = OpFCC->getFCC(); | |
606 } | |
607 IValueT InstEncodingFalse = 0; | |
Jim Stichnoth
2016/09/20 00:09:23
const or constexpr
obucinac
2016/09/20 13:24:52
Done.
| |
608 Opcode |= Rd << 11; | |
609 Opcode |= InstEncodingFalse << 16; | |
610 Opcode |= Cc << 18; | |
611 Opcode |= Rs << 21; | |
612 emitInst(Opcode); | |
613 } | |
614 | |
500 void AssemblerMIPS32::movn_d(const Operand *OpFd, const Operand *OpFs, | 615 void AssemblerMIPS32::movn_d(const Operand *OpFd, const Operand *OpFs, |
501 const Operand *OpFt) { | 616 const Operand *OpFt) { |
502 static constexpr IValueT Opcode = 0x44000013; | 617 static constexpr IValueT Opcode = 0x44000013; |
503 emitCOP1FmtFtFsFd(Opcode, SinglePrecision, OpFd, OpFs, OpFt, "movn.d"); | 618 emitCOP1FmtFtFsFd(Opcode, SinglePrecision, OpFd, OpFs, OpFt, "movn.d"); |
504 } | 619 } |
505 | 620 |
506 void AssemblerMIPS32::movn_s(const Operand *OpFd, const Operand *OpFs, | 621 void AssemblerMIPS32::movn_s(const Operand *OpFd, const Operand *OpFs, |
507 const Operand *OpFt) { | 622 const Operand *OpFt) { |
508 static constexpr IValueT Opcode = 0x44000013; | 623 static constexpr IValueT Opcode = 0x44000013; |
509 emitCOP1FmtFtFsFd(Opcode, SinglePrecision, OpFd, OpFs, OpFt, "movn.s"); | 624 emitCOP1FmtFtFsFd(Opcode, SinglePrecision, OpFd, OpFs, OpFt, "movn.s"); |
510 } | 625 } |
511 | 626 |
627 void AssemblerMIPS32::movt(const Operand *OpRd, const Operand *OpRs, | |
628 const Operand *OpCc) { | |
629 IValueT Opcode = 0x00000001; | |
630 const IValueT Rd = encodeGPRegister(OpRd, "Rd", "movf"); | |
631 const IValueT Rs = encodeGPRegister(OpRs, "Rs", "movf"); | |
632 OperandMIPS32FCC::FCC Cc = OperandMIPS32FCC::FCC0; | |
633 if (const auto *OpFCC = llvm::dyn_cast<OperandMIPS32FCC>(OpCc)) { | |
634 Cc = OpFCC->getFCC(); | |
635 } | |
636 IValueT InstEncodingTrue = 1; | |
Jim Stichnoth
2016/09/20 00:09:23
const or constexpr
obucinac
2016/09/20 13:24:52
Done.
| |
637 Opcode |= Rd << 11; | |
638 Opcode |= InstEncodingTrue << 16; | |
639 Opcode |= Cc << 18; | |
640 Opcode |= Rs << 21; | |
641 emitInst(Opcode); | |
642 } | |
643 | |
512 void AssemblerMIPS32::movz_d(const Operand *OpFd, const Operand *OpFs, | 644 void AssemblerMIPS32::movz_d(const Operand *OpFd, const Operand *OpFs, |
513 const Operand *OpFt) { | 645 const Operand *OpFt) { |
514 static constexpr IValueT Opcode = 0x44000012; | 646 static constexpr IValueT Opcode = 0x44000012; |
515 emitCOP1FmtFtFsFd(Opcode, SinglePrecision, OpFd, OpFs, OpFt, "movz.d"); | 647 emitCOP1FmtFtFsFd(Opcode, SinglePrecision, OpFd, OpFs, OpFt, "movz.d"); |
516 } | 648 } |
517 | 649 |
518 void AssemblerMIPS32::movz_s(const Operand *OpFd, const Operand *OpFs, | 650 void AssemblerMIPS32::movz_s(const Operand *OpFd, const Operand *OpFs, |
519 const Operand *OpFt) { | 651 const Operand *OpFt) { |
520 static constexpr IValueT Opcode = 0x44000012; | 652 static constexpr IValueT Opcode = 0x44000012; |
521 emitCOP1FmtFtFsFd(Opcode, SinglePrecision, OpFd, OpFs, OpFt, "movz.s"); | 653 emitCOP1FmtFtFsFd(Opcode, SinglePrecision, OpFd, OpFs, OpFt, "movz.s"); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
754 emitBr(Cond, OpRs, OpRtNone, Dest); | 886 emitBr(Cond, OpRs, OpRtNone, Dest); |
755 return; | 887 return; |
756 } | 888 } |
757 const IOffsetT Position = Buffer.size(); | 889 const IOffsetT Position = Buffer.size(); |
758 emitBr(Cond, OpRs, OpRtNone, TargetLabel->getEncodedPosition()); | 890 emitBr(Cond, OpRs, OpRtNone, TargetLabel->getEncodedPosition()); |
759 TargetLabel->linkTo(*this, Position); | 891 TargetLabel->linkTo(*this, Position); |
760 } | 892 } |
761 | 893 |
762 } // end of namespace MIPS32 | 894 } // end of namespace MIPS32 |
763 } // end of namespace Ice | 895 } // end of namespace Ice |
OLD | NEW |