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

Side by Side Diff: src/IceTargetLoweringMIPS32.cpp

Issue 2017043002: [Subzero][MIPS32] Implement i1 cast operations (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Added temporaries to avoid illegal code generation Created 4 years, 6 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 | « no previous file | 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 // 1 //
2 // The Subzero Code Generator 2 // The Subzero Code Generator
3 // 3 //
4 // This file is distributed under the University of Illinois Open Source 4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details. 5 // License. See LICENSE.TXT for details.
6 // 6 //
7 //===----------------------------------------------------------------------===// 7 //===----------------------------------------------------------------------===//
8 /// 8 ///
9 /// \file 9 /// \file
10 /// \brief Implements the TargetLoweringMIPS32 class, which consists almost 10 /// \brief Implements the TargetLoweringMIPS32 class, which consists almost
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 } 1002 }
1003 } 1003 }
1004 1004
1005 void TargetMIPS32::lowerCast(const InstCast *Instr) { 1005 void TargetMIPS32::lowerCast(const InstCast *Instr) {
1006 InstCast::OpKind CastKind = Instr->getCastKind(); 1006 InstCast::OpKind CastKind = Instr->getCastKind();
1007 Variable *Dest = Instr->getDest(); 1007 Variable *Dest = Instr->getDest();
1008 Operand *Src0 = legalizeUndef(Instr->getSrc(0)); 1008 Operand *Src0 = legalizeUndef(Instr->getSrc(0));
1009 const Type DestTy = Dest->getType(); 1009 const Type DestTy = Dest->getType();
1010 const Type Src0Ty = Src0->getType(); 1010 const Type Src0Ty = Src0->getType();
1011 const uint32_t ShiftAmount = 1011 const uint32_t ShiftAmount =
1012 INT32_BITS - (CHAR_BITS * typeWidthInBytes(Src0Ty)); 1012 (Src0Ty == IceType_i1
1013 const uint32_t Mask = (1 << (CHAR_BITS * typeWidthInBytes(Src0Ty))) - 1; 1013 ? INT32_BITS - 1
1014 : INT32_BITS - (CHAR_BITS * typeWidthInBytes(Src0Ty)));
1015 const uint32_t Mask =
1016 (Src0Ty == IceType_i1
1017 ? 1
1018 : (1 << (CHAR_BITS * typeWidthInBytes(Src0Ty))) - 1);
1014 1019
1015 if (isVectorType(DestTy) || Src0->getType() == IceType_i1) { 1020 if (isVectorType(DestTy)) {
1016 UnimplementedLoweringError(this, Instr); 1021 UnimplementedLoweringError(this, Instr);
1017 return; 1022 return;
1018 } 1023 }
1019 switch (CastKind) { 1024 switch (CastKind) {
1020 default: 1025 default:
1021 Func->setError("Cast type not supported"); 1026 Func->setError("Cast type not supported");
1022 return; 1027 return;
1023 case InstCast::Sext: { 1028 case InstCast::Sext: {
1024 if (DestTy == IceType_i64) { 1029 if (DestTy == IceType_i64) {
1025 auto *DestLo = llvm::cast<Variable>(loOperand(Dest)); 1030 auto *DestLo = llvm::cast<Variable>(loOperand(Dest));
1026 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest)); 1031 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest));
1027 Variable *Src0R = legalizeToReg(Src0); 1032 Variable *Src0R = legalizeToReg(Src0);
1028 Variable *T_Lo = I32Reg(); 1033 Variable *T1_Lo = I32Reg();
1029 if (Src0Ty == IceType_i32) { 1034 Variable *T2_Lo = I32Reg();
1030 _mov(DestLo, Src0R); 1035 Variable *T_Hi = I32Reg();
1036 if (Src0Ty == IceType_i1) {
1037 _sll(T1_Lo, Src0R, INT32_BITS - 1);
1038 _sra(T2_Lo, T1_Lo, INT32_BITS - 1);
1039 _mov(DestHi, T2_Lo);
1040 _mov(DestLo, T2_Lo);
1031 } else if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16) { 1041 } else if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16) {
1032 _sll(T_Lo, Src0R, ShiftAmount); 1042 _sll(T1_Lo, Src0R, ShiftAmount);
1033 _sra(DestLo, T_Lo, ShiftAmount); 1043 _sra(T2_Lo, T1_Lo, ShiftAmount);
1044 _sra(T_Hi, T2_Lo, INT32_BITS - 1);
1045 _mov(DestHi, T_Hi);
1046 _mov(DestLo, T2_Lo);
1047 } else if (Src0Ty == IceType_i32) {
1048 _mov(T1_Lo, Src0R);
1049 _sra(T_Hi, T1_Lo, INT32_BITS - 1);
1050 _mov(DestHi, T_Hi);
1051 _mov(DestLo, T1_Lo);
1034 } 1052 }
1035 _sra(DestHi, DestLo, INT32_BITS - 1);
1036 } else { 1053 } else {
1037 Variable *Src0R = legalizeToReg(Src0); 1054 Variable *Src0R = legalizeToReg(Src0);
1038 Variable *T = makeReg(DestTy); 1055 Variable *T1 = makeReg(DestTy);
1039 if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16) { 1056 Variable *T2 = makeReg(DestTy);
1040 _sll(T, Src0R, ShiftAmount); 1057 if (Src0Ty == IceType_i1 || Src0Ty == IceType_i8 ||
1041 _sra(Dest, T, ShiftAmount); 1058 Src0Ty == IceType_i16) {
1059 _sll(T1, Src0R, ShiftAmount);
1060 _sra(T2, T1, ShiftAmount);
1061 _mov(Dest, T2);
1042 } 1062 }
1043 } 1063 }
1044 break; 1064 break;
1045 } 1065 }
1046 case InstCast::Zext: { 1066 case InstCast::Zext: {
1047 if (DestTy == IceType_i64) { 1067 if (DestTy == IceType_i64) {
1048 auto *DestLo = llvm::cast<Variable>(loOperand(Dest)); 1068 auto *DestLo = llvm::cast<Variable>(loOperand(Dest));
1049 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest)); 1069 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest));
1050 Variable *Src0R = legalizeToReg(Src0); 1070 Variable *Src0R = legalizeToReg(Src0);
1071 Variable *T_Lo = I32Reg();
1072 Variable *T_Hi = I32Reg();
1051 1073
1052 switch (Src0Ty) { 1074 if (Src0Ty == IceType_i1 || Src0Ty == IceType_i8 || Src0Ty == IceType_i16)
1053 default: { assert(Src0Ty != IceType_i64); } break; 1075 _andi(T_Lo, Src0R, Mask);
1054 case IceType_i32: 1076 else if (Src0Ty == IceType_i32)
1055 _mov(DestLo, Src0R); 1077 _mov(T_Lo, Src0R);
1056 break; 1078 else
1057 case IceType_i8: 1079 assert(Src0Ty != IceType_i64);
1058 case IceType_i16: 1080 _mov(DestLo, T_Lo);
1059 _andi(DestLo, Src0R, Mask);
1060 break;
1061 }
1062 1081
1063 auto *Zero = getZero(); 1082 auto *Zero = getZero();
1064 _addiu(DestHi, Zero, 0); 1083 _addiu(T_Hi, Zero, 0);
1084 _mov(DestHi, T_Hi);
1065 } else { 1085 } else {
1066 Variable *Src0R = legalizeToReg(Src0); 1086 Variable *Src0R = legalizeToReg(Src0);
1067 Variable *T = makeReg(DestTy); 1087 Variable *T = makeReg(DestTy);
1068 if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16) 1088 if (Src0Ty == IceType_i1 || Src0Ty == IceType_i8 ||
1089 Src0Ty == IceType_i16) {
1069 _andi(T, Src0R, Mask); 1090 _andi(T, Src0R, Mask);
1070 _mov(Dest, T); 1091 _mov(Dest, T);
1092 }
1071 } 1093 }
1072 break; 1094 break;
1073 } 1095 }
1074 case InstCast::Trunc: { 1096 case InstCast::Trunc: {
1075 if (Src0Ty == IceType_i64) 1097 if (Src0Ty == IceType_i64)
1076 Src0 = loOperand(Src0); 1098 Src0 = loOperand(Src0);
1077 Variable *Src0R = legalizeToReg(Src0); 1099 Variable *Src0R = legalizeToReg(Src0);
1078 Variable *T = makeReg(DestTy); 1100 Variable *T = makeReg(DestTy);
1079 _mov(T, Src0R); 1101 _mov(T, Src0R);
1080 _mov(Dest, T); 1102 _mov(Dest, T);
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 Str << "\t.set\t" 1668 Str << "\t.set\t"
1647 << "nomips16\n"; 1669 << "nomips16\n";
1648 } 1670 }
1649 1671
1650 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM]; 1672 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM];
1651 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM]; 1673 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM];
1652 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM]; 1674 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM];
1653 1675
1654 } // end of namespace MIPS32 1676 } // end of namespace MIPS32
1655 } // end of namespace Ice 1677 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/64bit.pnacl.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698