OLD | NEW |
---|---|
1 //===- subzero/src/IceInstMips32.cpp - Mips32 instruction implementation --===// | 1 //===- subzero/src/IceInstMips32.cpp - Mips32 instruction implementation --===// |
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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 Str << ", "; | 546 Str << ", "; |
547 SrcHi->emit(Func); | 547 SrcHi->emit(Func); |
548 } | 548 } |
549 | 549 |
550 void InstMIPS32Mov::emitSingleDestSingleSource(const Cfg *Func) const { | 550 void InstMIPS32Mov::emitSingleDestSingleSource(const Cfg *Func) const { |
551 if (!BuildDefs::dump()) | 551 if (!BuildDefs::dump()) |
552 return; | 552 return; |
553 Ostream &Str = Func->getContext()->getStrEmit(); | 553 Ostream &Str = Func->getContext()->getStrEmit(); |
554 Variable *Dest = getDest(); | 554 Variable *Dest = getDest(); |
555 Operand *Src = getSrc(0); | 555 Operand *Src = getSrc(0); |
556 auto *S = llvm::dyn_cast<Variable>(Src); | 556 auto *SrcV = llvm::dyn_cast<Variable>(Src); |
557 Str << "\t"; | 557 |
558 if (Dest->hasReg()) { | 558 const char *ActualOpcode = NULL; |
Jim Stichnoth
2016/07/06 11:18:57
nullptr
obucinac
2016/07/06 13:40:53
Done.
| |
559 if (S && S->hasReg()) | 559 bool DestIsReg = Dest->hasReg(); |
Jim Stichnoth
2016/07/06 11:18:57
const bool
for these 4 variables
obucinac
2016/07/06 13:40:53
Done.
| |
560 Str << "move"; | 560 bool DestIsMem = !Dest->hasReg(); |
561 else | 561 bool SrcIsReg = (SrcV && SrcV->hasReg()); |
562 Str << "lw"; | 562 bool SrcIsMem = !(SrcV && SrcV->hasReg()); |
Jim Stichnoth
2016/07/06 11:18:57
Just checking - what is Src is a Constant, e.g. "4
obucinac
2016/07/06 13:40:53
All constants are lowered to OperandMIPS32Mem. We
| |
563 } else { | 563 |
564 if (S && S->hasReg()) { | 564 // reg to reg |
565 Str << "sw" | 565 if (DestIsReg && SrcIsReg) { |
566 "\t"; | 566 switch (Dest->getType()) { |
567 default: | |
568 UnimplementedError(getFlags()); | |
569 case IceType_f32: | |
570 ActualOpcode = "mov.s"; | |
571 break; | |
572 case IceType_f64: | |
573 ActualOpcode = "mov.d"; | |
574 break; | |
575 case IceType_i32: | |
576 Str << "\t"; | |
Jim Stichnoth
2016/07/06 11:18:58
Str << "\t" "add" "\t";
to use compile-time string
obucinac
2016/07/06 13:40:53
Done.
| |
577 Str << "add"; | |
578 Str << "\t"; | |
579 getDest()->emit(Func); | |
580 Str << ", $zero, "; | |
567 getSrc(0)->emit(Func); | 581 getSrc(0)->emit(Func); |
568 Str << ", "; | |
569 getDest()->emit(Func); | |
570 return; | 582 return; |
571 } else | 583 case IceType_i64: { |
572 Str << "move"; | 584 UnimplementedError(getFlags()); |
585 break; | |
586 } | |
587 case IceType_v4i1: | |
588 case IceType_v8i1: | |
589 case IceType_v16i1: | |
590 case IceType_v16i8: | |
591 case IceType_v8i16: | |
592 case IceType_v4i32: | |
593 case IceType_v4f32: { | |
594 UnimplementedError(getFlags()); | |
595 break; | |
596 } | |
597 } | |
598 | |
599 Str << "\t"; | |
Jim Stichnoth
2016/07/06 11:18:57
Str << "\t" << ActualOpcode << "\t";
here and belo
obucinac
2016/07/06 13:40:53
Done.
| |
600 Str << ActualOpcode; | |
601 Str << "\t"; | |
602 getDest()->emit(Func); | |
603 Str << ", "; | |
604 getSrc(0)->emit(Func); | |
605 return; | |
573 } | 606 } |
574 | 607 |
575 Str << "\t"; | 608 // reg to stack |
576 getDest()->emit(Func); | 609 if (DestIsMem && SrcIsReg) { |
577 Str << ", "; | 610 switch (Dest->getType()) { |
578 getSrc(0)->emit(Func); | 611 default: |
612 UnimplementedError(getFlags()); | |
Jim Stichnoth
2016/07/06 11:18:58
add "break" after this?
obucinac
2016/07/06 13:40:53
Done.
| |
613 case IceType_f32: | |
614 ActualOpcode = "swc1"; | |
615 break; | |
616 case IceType_f64: | |
617 ActualOpcode = "sdc1"; | |
618 break; | |
619 case IceType_i32: | |
620 ActualOpcode = "sw"; | |
621 break; | |
622 case IceType_i64: { | |
623 UnimplementedError(getFlags()); | |
624 break; | |
625 } | |
626 case IceType_v4i1: | |
627 case IceType_v8i1: | |
628 case IceType_v16i1: | |
629 case IceType_v16i8: | |
630 case IceType_v8i16: | |
631 case IceType_v4i32: | |
632 case IceType_v4f32: { | |
633 UnimplementedError(getFlags()); | |
634 break; | |
635 } | |
636 } | |
637 | |
638 Str << "\t"; | |
639 Str << ActualOpcode; | |
640 Str << "\t"; | |
641 getSrc(0)->emit(Func); | |
642 Str << ", "; | |
643 getDest()->emit(Func); | |
644 return; | |
645 } | |
646 | |
647 // stack to reg | |
648 if (DestIsReg && SrcIsMem) { | |
649 switch (Dest->getType()) { | |
650 default: | |
651 UnimplementedError(getFlags()); | |
652 case IceType_f32: | |
653 ActualOpcode = "lwc1"; | |
654 break; | |
655 case IceType_f64: | |
656 ActualOpcode = "ldc1"; | |
657 break; | |
658 case IceType_i32: | |
659 ActualOpcode = "lw"; | |
660 break; | |
661 case IceType_i64: { | |
662 UnimplementedError(getFlags()); | |
663 break; | |
664 } | |
665 case IceType_v4i1: | |
666 case IceType_v8i1: | |
667 case IceType_v16i1: | |
668 case IceType_v16i8: | |
669 case IceType_v8i16: | |
670 case IceType_v4i32: | |
671 case IceType_v4f32: { | |
672 UnimplementedError(getFlags()); | |
673 break; | |
674 } | |
675 } | |
676 | |
677 Str << "\t"; | |
678 Str << ActualOpcode; | |
679 Str << "\t"; | |
680 getDest()->emit(Func); | |
681 Str << ", "; | |
682 getSrc(0)->emit(Func); | |
683 return; | |
684 } | |
685 | |
686 // stack to stack | |
687 UnimplementedError(getFlags()); | |
Jim Stichnoth
2016/07/06 11:18:57
Should this be a hard error? E.g. in x86 it would
obucinac
2016/07/06 13:40:53
This case will be covered in lowerAssign, by copyi
| |
579 } | 688 } |
580 | 689 |
581 } // end of namespace MIPS32 | 690 } // end of namespace MIPS32 |
582 } // end of namespace Ice | 691 } // end of namespace Ice |
OLD | NEW |