Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(921)

Side by Side Diff: src/IceInstMIPS32.cpp

Issue 2301303003: [SubZero] Implement load and store for MIPS (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addressed review comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 return; 642 return;
643 assert(getSrcSize() == 1 || getSrcSize() == 2); 643 assert(getSrcSize() == 1 || getSrcSize() == 2);
644 Ostream &Str = Func->getContext()->getStrDump(); 644 Ostream &Str = Func->getContext()->getStrDump();
645 Variable *Dest = getDest(); 645 Variable *Dest = getDest();
646 Variable *DestHi = getDestHi(); 646 Variable *DestHi = getDestHi();
647 Dest->dump(Func); 647 Dest->dump(Func);
648 if (DestHi) { 648 if (DestHi) {
649 Str << ", "; 649 Str << ", ";
650 DestHi->dump(Func); 650 DestHi->dump(Func);
651 } 651 }
652
653 dumpOpcode(Str, " = mov", getDest()->getType()); 652 dumpOpcode(Str, " = mov", getDest()->getType());
654 Str << " "; 653 Str << " ";
655
656 dumpSources(Func); 654 dumpSources(Func);
657 } 655 }
658 656
659 void InstMIPS32Mov::emitMultiDestSingleSource(const Cfg *Func) const { 657 void InstMIPS32Mov::emitMultiDestSingleSource(const Cfg *Func) const {
660 if (!BuildDefs::dump()) 658 if (!BuildDefs::dump())
661 return; 659 return;
662 Ostream &Str = Func->getContext()->getStrEmit(); 660 Ostream &Str = Func->getContext()->getStrEmit();
663 Variable *DestLo = getDest(); 661 Variable *DestLo = getDest();
664 Variable *DestHi = getDestHi(); 662 Variable *DestHi = getDestHi();
665 auto *Src = llvm::cast<Variable>(getSrc(0)); 663 auto *Src = llvm::cast<Variable>(getSrc(0));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 return; 702 return;
705 Ostream &Str = Func->getContext()->getStrEmit(); 703 Ostream &Str = Func->getContext()->getStrEmit();
706 Variable *Dest = getDest(); 704 Variable *Dest = getDest();
707 Operand *Src = getSrc(0); 705 Operand *Src = getSrc(0);
708 auto *SrcV = llvm::dyn_cast<Variable>(Src); 706 auto *SrcV = llvm::dyn_cast<Variable>(Src);
709 707
710 assert(!llvm::isa<Constant>(Src)); 708 assert(!llvm::isa<Constant>(Src));
711 709
712 const char *ActualOpcode = nullptr; 710 const char *ActualOpcode = nullptr;
713 const bool DestIsReg = Dest->hasReg(); 711 const bool DestIsReg = Dest->hasReg();
714 const bool DestIsMem = !Dest->hasReg();
715 const bool SrcIsReg = (SrcV && SrcV->hasReg()); 712 const bool SrcIsReg = (SrcV && SrcV->hasReg());
716 const bool SrcIsMem = !(SrcV && SrcV->hasReg());
717 713
718 // reg to reg 714 // reg to reg
719 if (DestIsReg && SrcIsReg) { 715 if (DestIsReg && SrcIsReg) {
720 switch (Dest->getType()) { 716 switch (Dest->getType()) {
721 case IceType_f32: 717 case IceType_f32:
722 ActualOpcode = "mov.s"; 718 ActualOpcode = "mov.s";
723 break; 719 break;
724 case IceType_f64: 720 case IceType_f64:
725 ActualOpcode = "mov.d"; 721 ActualOpcode = "mov.d";
726 break; 722 break;
727 case IceType_i1: 723 case IceType_i1:
728 case IceType_i8: 724 case IceType_i8:
729 case IceType_i16: 725 case IceType_i16:
730 case IceType_i32: 726 case IceType_i32:
731 Str << "\t" 727 Str << "\t"
732 "move" 728 << "move"
733 "\t"; 729 << "\t";
734 getDest()->emit(Func); 730 getDest()->emit(Func);
735 Str << ", "; 731 Str << ", ";
736 getSrc(0)->emit(Func); 732 getSrc(0)->emit(Func);
737 return; 733 return;
738 default: 734 default:
739 UnimplementedError(getFlags()); 735 UnimplementedError(getFlags());
740 return; 736 return;
741 } 737 }
742 738
743 assert(ActualOpcode); 739 assert(ActualOpcode);
744 Str << "\t" << ActualOpcode << "\t"; 740 Str << "\t" << ActualOpcode << "\t";
745 getDest()->emit(Func); 741 getDest()->emit(Func);
746 Str << ", "; 742 Str << ", ";
747 getSrc(0)->emit(Func); 743 getSrc(0)->emit(Func);
748 return; 744 return;
749 } 745 }
750 746
751 // reg to stack 747 llvm::report_fatal_error("Invalid mov instruction. Dest or Src is memory.");
752 if (DestIsMem && SrcIsReg) {
753 switch (Dest->getType()) {
754 case IceType_f32:
755 ActualOpcode = "swc1";
756 break;
757 case IceType_f64:
758 ActualOpcode = "sdc1";
759 break;
760 case IceType_i1:
761 case IceType_i8:
762 case IceType_i16:
763 case IceType_i32:
764 ActualOpcode = "sw";
765 break;
766 default:
767 UnimplementedError(getFlags());
768 return;
769 }
770
771 assert(ActualOpcode);
772 Str << "\t" << ActualOpcode << "\t";
773 getSrc(0)->emit(Func);
774 Str << ", ";
775 getDest()->emit(Func);
776 return;
777 }
778
779 // stack to reg
780 if (DestIsReg && SrcIsMem) {
781 switch (Dest->getType()) {
782 case IceType_f32:
783 ActualOpcode = "lwc1";
784 break;
785 case IceType_f64:
786 ActualOpcode = "ldc1";
787 break;
788 case IceType_i1:
789 case IceType_i8:
790 case IceType_i16:
791 case IceType_i32:
792 ActualOpcode = "lw";
793 break;
794 default:
795 UnimplementedError(getFlags());
796 return;
797 }
798
799 assert(ActualOpcode);
800 Str << "\t" << ActualOpcode << "\t";
801 getDest()->emit(Func);
802 Str << ", ";
803 getSrc(0)->emit(Func);
804 return;
805 }
806
807 // stack to stack
808 llvm::report_fatal_error("mov cant copy stack to stack.");
809 } 748 }
810 749
811 template <> void InstMIPS32Addiu::emitIAS(const Cfg *Func) const { 750 template <> void InstMIPS32Addiu::emitIAS(const Cfg *Func) const {
812 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 751 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
813 Asm->addiu(getDest(), getSrc(0), Imm); 752 Asm->addiu(getDest(), getSrc(0), Imm);
814 } 753 }
815 754
816 template <> void InstMIPS32Slti::emitIAS(const Cfg *Func) const { 755 template <> void InstMIPS32Slti::emitIAS(const Cfg *Func) const {
817 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 756 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
818 Asm->slti(getDest(), getSrc(0), Imm); 757 Asm->slti(getDest(), getSrc(0), Imm);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 template <> void InstMIPS32Lw::emitIAS(const Cfg *Func) const { 833 template <> void InstMIPS32Lw::emitIAS(const Cfg *Func) const {
895 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 834 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
896 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0)); 835 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0));
897 ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset()); 836 ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset());
898 uint32_t Imm = static_cast<uint32_t>(Offset->getValue()); 837 uint32_t Imm = static_cast<uint32_t>(Offset->getValue());
899 Asm->lw(getDest(), Mem->getBase(), Imm); 838 Asm->lw(getDest(), Mem->getBase(), Imm);
900 } 839 }
901 840
902 } // end of namespace MIPS32 841 } // end of namespace MIPS32
903 } // end of namespace Ice 842 } // end of namespace Ice
OLDNEW
« src/IceInstMIPS32.h ('K') | « src/IceInstMIPS32.h ('k') | src/IceTargetLoweringMIPS32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698