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

Side by Side Diff: src/IceTargetLoweringMIPS32.cpp

Issue 1948093002: [Subzero][MIPS32] Implement sext, zext and trunc (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « src/IceTargetLoweringMIPS32.h ('k') | tests_lit/llvm2ice_tests/64bit.pnacl.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLoweringMIPS32.cpp - MIPS32 lowering ----------===// 1 //===- subzero/src/IceTargetLoweringMIPS32.cpp - MIPS32 lowering ----------===//
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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 return; 898 return;
899 } else { 899 } else {
900 _mov(Dest, ReturnReg); 900 _mov(Dest, ReturnReg);
901 } 901 }
902 } 902 }
903 } 903 }
904 } 904 }
905 905
906 void TargetMIPS32::lowerCast(const InstCast *Instr) { 906 void TargetMIPS32::lowerCast(const InstCast *Instr) {
907 InstCast::OpKind CastKind = Instr->getCastKind(); 907 InstCast::OpKind CastKind = Instr->getCastKind();
908 Variable *Dest = Instr->getDest();
909 const Type DestTy = Dest->getType();
910 Operand *Src0 = legalizeUndef(Instr->getSrc(0));
Jim Stichnoth 2016/05/05 15:32:37 Add this: const Type Src0Ty = Src0->getType(); a
sagar.thakur 2016/05/06 13:04:06 Done.
911 if (isVectorType(DestTy) || Src0->getType() == IceType_i1) {
912 UnimplementedLoweringError(this, Instr);
913 return;
914 }
908 switch (CastKind) { 915 switch (CastKind) {
909 default: 916 default:
910 Func->setError("Cast type not supported"); 917 Func->setError("Cast type not supported");
911 return; 918 return;
912 case InstCast::Sext: { 919 case InstCast::Sext: {
913 UnimplementedLoweringError(this, Instr); 920 if (DestTy == IceType_i64) {
921 auto *DestLo = llvm::cast<Variable>(loOperand(Dest));
922 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest));
923 Variable *Src0R = legalizeToReg(Src0);
924 Variable *T_Lo = I32Reg();
925 if (Src0->getType() == IceType_i32) {
926 _mov(DestLo, Src0R);
927 } else if (Src0->getType() == IceType_i8) {
928 _sll(T_Lo, Src0R, 24);
Jim Stichnoth 2016/05/05 15:32:37 I strongly prefer to avoid magic constants like 24
sagar.thakur 2016/05/06 13:04:06 Done.
929 _sra(DestLo, T_Lo, 24);
930 } else if (Src0->getType() == IceType_i16) {
931 _sll(T_Lo, Src0R, 16);
932 _sra(DestLo, T_Lo, 16);
933 }
934 _sra(DestHi, DestLo, 31);
935 } else {
936 Variable *Src0R = legalizeToReg(Src0);
937 Variable *T = makeReg(DestTy);
938 if (Src0->getType() == IceType_i8) {
939 _sll(T, Src0R, 24);
940 _sra(Dest, T, 24);
941 } else if (Src0->getType() == IceType_i16) {
942 _sll(T, Src0R, 16);
943 _sra(Dest, T, 16);
944 }
945 }
914 break; 946 break;
915 } 947 }
916 case InstCast::Zext: { 948 case InstCast::Zext: {
917 UnimplementedLoweringError(this, Instr); 949 if (DestTy == IceType_i64) {
950 auto *DestLo = llvm::cast<Variable>(loOperand(Dest));
951 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest));
952 Variable *Src0R = legalizeToReg(Src0);
953
954 switch (Src0->getType()) {
955 default: { assert(Src0->getType() != IceType_i64); } break;
956 case IceType_i32: {
957 _mov(DestLo, Src0R);
958 } break;
959 case IceType_i16: {
960 _andi(DestLo, Src0R, 0xff);
Jim Stichnoth 2016/05/05 15:32:37 Shouldn't the mask be 0xffff for i16 and 0xff for
sagar.thakur 2016/05/06 13:04:06 Done.
961 } break;
962 case IceType_i8: {
963 _andi(DestLo, Src0R, 0xffff);
964 } break;
965 }
966
967 auto *Zero = getZero();
968 _addiu(DestHi, Zero, 0);
969 } else {
970 Variable *Src0R = legalizeToReg(Src0);
971 Variable *T = makeReg(DestTy);
972 if (Src0->getType() == IceType_i8)
973 _andi(T, Src0R, 0xff);
974 else if (Src0->getType() == IceType_i16)
975 _andi(T, Src0R, 0xffff);
976 _mov(Dest, T);
977 }
918 break; 978 break;
919 } 979 }
920 case InstCast::Trunc: { 980 case InstCast::Trunc: {
921 UnimplementedLoweringError(this, Instr); 981 if (Src0->getType() == IceType_i64)
982 Src0 = loOperand(Src0);
983 Variable *Src0R = legalizeToReg(Src0);
984 Variable *T = makeReg(DestTy);
985 _mov(T, Src0R);
986 _mov(Dest, T);
922 break; 987 break;
923 } 988 }
924 case InstCast::Fptrunc: 989 case InstCast::Fptrunc:
925 UnimplementedLoweringError(this, Instr); 990 UnimplementedLoweringError(this, Instr);
926 break; 991 break;
927 case InstCast::Fpext: { 992 case InstCast::Fpext: {
928 UnimplementedLoweringError(this, Instr); 993 UnimplementedLoweringError(this, Instr);
929 break; 994 break;
930 } 995 }
931 case InstCast::Fptosi: 996 case InstCast::Fptosi:
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 Str << "\t.set\t" 1486 Str << "\t.set\t"
1422 << "nomips16\n"; 1487 << "nomips16\n";
1423 } 1488 }
1424 1489
1425 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM]; 1490 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM];
1426 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM]; 1491 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM];
1427 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM]; 1492 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM];
1428 1493
1429 } // end of namespace MIPS32 1494 } // end of namespace MIPS32
1430 } // end of namespace Ice 1495 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLoweringMIPS32.h ('k') | tests_lit/llvm2ice_tests/64bit.pnacl.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698