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

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: Addressed review comments 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 ----------===//
2 // 1 //
3 // The Subzero Code Generator 2 // The Subzero Code Generator
4 // 3 //
5 // This file is distributed under the University of Illinois Open Source 4 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 5 // License. See LICENSE.TXT for details.
7 // 6 //
8 //===----------------------------------------------------------------------===// 7 //===----------------------------------------------------------------------===//
9 /// 8 ///
10 /// \file 9 /// \file
11 /// \brief Implements the TargetLoweringMIPS32 class, which consists almost 10 /// \brief Implements the TargetLoweringMIPS32 class, which consists almost
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 return; 897 return;
899 } else { 898 } else {
900 _mov(Dest, ReturnReg); 899 _mov(Dest, ReturnReg);
901 } 900 }
902 } 901 }
903 } 902 }
904 } 903 }
905 904
906 void TargetMIPS32::lowerCast(const InstCast *Instr) { 905 void TargetMIPS32::lowerCast(const InstCast *Instr) {
907 InstCast::OpKind CastKind = Instr->getCastKind(); 906 InstCast::OpKind CastKind = Instr->getCastKind();
907 Variable *Dest = Instr->getDest();
908 Operand *Src0 = legalizeUndef(Instr->getSrc(0));
909 const Type DestTy = Dest->getType();
910 const Type Src0Ty = Src0->getType();
911 const uint32_t ShiftAmount =
912 INT32_BITS - (CHAR_BITS * typeWidthInBytes(Src0Ty));
913 const uint32_t Mask = (1 << (CHAR_BITS * typeWidthInBytes(Src0Ty))) - 1;
914
915 if (isVectorType(DestTy) || Src0->getType() == IceType_i1) {
916 UnimplementedLoweringError(this, Instr);
917 return;
918 }
908 switch (CastKind) { 919 switch (CastKind) {
909 default: 920 default:
910 Func->setError("Cast type not supported"); 921 Func->setError("Cast type not supported");
911 return; 922 return;
912 case InstCast::Sext: { 923 case InstCast::Sext: {
913 UnimplementedLoweringError(this, Instr); 924 if (DestTy == IceType_i64) {
925 auto *DestLo = llvm::cast<Variable>(loOperand(Dest));
926 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest));
927 Variable *Src0R = legalizeToReg(Src0);
928 Variable *T_Lo = I32Reg();
929 if (Src0Ty == IceType_i32) {
930 _mov(DestLo, Src0R);
931 } else if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16) {
932 _sll(T_Lo, Src0R, ShiftAmount);
933 _sra(DestLo, T_Lo, ShiftAmount);
934 }
935 _sra(DestHi, DestLo, INT32_BITS - 1);
936 } else {
937 Variable *Src0R = legalizeToReg(Src0);
938 Variable *T = makeReg(DestTy);
939 if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16) {
940 _sll(T, Src0R, ShiftAmount);
941 _sra(Dest, T, ShiftAmount);
942 }
943 }
914 break; 944 break;
915 } 945 }
916 case InstCast::Zext: { 946 case InstCast::Zext: {
917 UnimplementedLoweringError(this, Instr); 947 if (DestTy == IceType_i64) {
948 auto *DestLo = llvm::cast<Variable>(loOperand(Dest));
949 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest));
950 Variable *Src0R = legalizeToReg(Src0);
951
952 switch (Src0Ty) {
Jim Stichnoth 2016/05/09 18:41:27 It would probably be cleaner if all of the similar
953 default: { assert(Src0Ty != IceType_i64); } break;
954 case IceType_i32:
955 _mov(DestLo, Src0R);
956 break;
957 case IceType_i8:
958 case IceType_i16:
959 _andi(DestLo, Src0R, Mask);
960 break;
961 }
962
963 auto *Zero = getZero();
964 _addiu(DestHi, Zero, 0);
965 } else {
966 Variable *Src0R = legalizeToReg(Src0);
967 Variable *T = makeReg(DestTy);
968 if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16)
969 _andi(T, Src0R, Mask);
970 _mov(Dest, T);
971 }
918 break; 972 break;
919 } 973 }
920 case InstCast::Trunc: { 974 case InstCast::Trunc: {
921 UnimplementedLoweringError(this, Instr); 975 if (Src0Ty == IceType_i64)
976 Src0 = loOperand(Src0);
977 Variable *Src0R = legalizeToReg(Src0);
978 Variable *T = makeReg(DestTy);
979 _mov(T, Src0R);
980 _mov(Dest, T);
922 break; 981 break;
923 } 982 }
924 case InstCast::Fptrunc: 983 case InstCast::Fptrunc:
925 UnimplementedLoweringError(this, Instr); 984 UnimplementedLoweringError(this, Instr);
926 break; 985 break;
927 case InstCast::Fpext: { 986 case InstCast::Fpext: {
928 UnimplementedLoweringError(this, Instr); 987 UnimplementedLoweringError(this, Instr);
929 break; 988 break;
930 } 989 }
931 case InstCast::Fptosi: 990 case InstCast::Fptosi:
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 Str << "\t.set\t" 1480 Str << "\t.set\t"
1422 << "nomips16\n"; 1481 << "nomips16\n";
1423 } 1482 }
1424 1483
1425 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM]; 1484 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM];
1426 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM]; 1485 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM];
1427 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM]; 1486 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM];
1428 1487
1429 } // end of namespace MIPS32 1488 } // end of namespace MIPS32
1430 } // end of namespace Ice 1489 } // 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