Chromium Code Reviews| 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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 auto *SrcV = llvm::dyn_cast<Variable>(Src); | 706 auto *SrcV = llvm::dyn_cast<Variable>(Src); |
| 707 | 707 |
| 708 assert(!llvm::isa<Constant>(Src)); | 708 assert(!llvm::isa<Constant>(Src)); |
| 709 | 709 |
| 710 const char *ActualOpcode = nullptr; | 710 const char *ActualOpcode = nullptr; |
| 711 const bool DestIsReg = Dest->hasReg(); | 711 const bool DestIsReg = Dest->hasReg(); |
| 712 const bool SrcIsReg = (SrcV && SrcV->hasReg()); | 712 const bool SrcIsReg = (SrcV && SrcV->hasReg()); |
| 713 | 713 |
| 714 // reg to reg | 714 // reg to reg |
| 715 if (DestIsReg && SrcIsReg) { | 715 if (DestIsReg && SrcIsReg) { |
| 716 switch (Dest->getType()) { | 716 const Type DstType = Dest->getType(); |
| 717 case IceType_f32: | 717 const Type SrcType = Src->getType(); |
| 718 ActualOpcode = "mov.s"; | 718 |
| 719 break; | 719 // move GP to/from FP |
| 720 case IceType_f64: | 720 if (DstType != SrcType) { |
| 721 ActualOpcode = "mov.d"; | 721 if (isScalarFloatingType(DstType) == true) { |
|
Jim Stichnoth
2016/09/07 15:39:31
remove the redundant "== true"
jaydeep.patil
2016/09/13 06:18:36
Done.
| |
| 722 break; | 722 Str << "\t" |
| 723 case IceType_i1: | 723 "mtc1" |
| 724 case IceType_i8: | 724 "\t"; |
| 725 case IceType_i16: | 725 getSrc(0)->emit(Func); |
| 726 case IceType_i32: | 726 Str << ", "; |
| 727 Str << "\t" | 727 getDest()->emit(Func); |
| 728 << "move" | 728 return; |
| 729 << "\t"; | 729 } else { |
|
Jim Stichnoth
2016/09/07 15:39:31
http://llvm.org/docs/CodingStandards.html#don-t-us
jaydeep.patil
2016/09/13 06:18:36
Done.
| |
| 730 getDest()->emit(Func); | 730 ActualOpcode = "mfc1"; |
| 731 Str << ", "; | 731 } |
| 732 getSrc(0)->emit(Func); | 732 } else { |
| 733 return; | 733 switch (Dest->getType()) { |
| 734 default: | 734 case IceType_f32: |
| 735 UnimplementedError(getFlags()); | 735 ActualOpcode = "mov.s"; |
| 736 return; | 736 break; |
| 737 case IceType_f64: | |
| 738 ActualOpcode = "mov.d"; | |
| 739 break; | |
| 740 case IceType_i1: | |
| 741 case IceType_i8: | |
| 742 case IceType_i16: | |
| 743 case IceType_i32: | |
| 744 ActualOpcode = "move"; | |
|
obucinac
2016/09/08 09:52:01
As adviced earlier by Simon Dardis, we should use
jaydeep.patil
2016/09/13 06:18:36
This change should be done in AssemblerMIPS32::mov
| |
| 745 break; | |
| 746 default: | |
| 747 UnimplementedError(getFlags()); | |
| 748 return; | |
| 749 } | |
| 737 } | 750 } |
| 738 | 751 |
| 739 assert(ActualOpcode); | 752 assert(ActualOpcode); |
| 740 Str << "\t" << ActualOpcode << "\t"; | 753 Str << "\t" << ActualOpcode << "\t"; |
| 741 getDest()->emit(Func); | 754 getDest()->emit(Func); |
| 742 Str << ", "; | 755 Str << ", "; |
| 743 getSrc(0)->emit(Func); | 756 getSrc(0)->emit(Func); |
| 744 return; | 757 return; |
| 745 } | 758 } |
| 746 | 759 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 833 template <> void InstMIPS32Lw::emitIAS(const Cfg *Func) const { | 846 template <> void InstMIPS32Lw::emitIAS(const Cfg *Func) const { |
| 834 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 847 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 835 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0)); | 848 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0)); |
| 836 ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset()); | 849 ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset()); |
| 837 uint32_t Imm = static_cast<uint32_t>(Offset->getValue()); | 850 uint32_t Imm = static_cast<uint32_t>(Offset->getValue()); |
| 838 Asm->lw(getDest(), Mem->getBase(), Imm); | 851 Asm->lw(getDest(), Mem->getBase(), Imm); |
| 839 } | 852 } |
| 840 | 853 |
| 841 } // end of namespace MIPS32 | 854 } // end of namespace MIPS32 |
| 842 } // end of namespace Ice | 855 } // end of namespace Ice |
| OLD | NEW |