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

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: 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 *T_Lo = I32Reg();
1029 if (Src0Ty == IceType_i32) { 1034 if (Src0Ty == IceType_i1) {
1030 _mov(DestLo, Src0R); 1035 _sll(T_Lo, Src0R, INT32_BITS - 1);
1036 _sra(DestLo, T_Lo, INT32_BITS - 1);
1037 _mov(DestHi, DestLo);
1031 } else if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16) { 1038 } else if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16) {
1032 _sll(T_Lo, Src0R, ShiftAmount); 1039 _sll(T_Lo, Src0R, ShiftAmount);
1033 _sra(DestLo, T_Lo, ShiftAmount); 1040 _sra(DestLo, T_Lo, ShiftAmount);
1041 _sra(DestHi, DestLo, INT32_BITS - 1);
1042 } else if (Src0Ty == IceType_i32) {
1043 _mov(DestLo, Src0R);
1044 _sra(DestHi, DestLo, INT32_BITS - 1);
1034 } 1045 }
1035 _sra(DestHi, DestLo, INT32_BITS - 1);
1036 } else { 1046 } else {
1037 Variable *Src0R = legalizeToReg(Src0); 1047 Variable *Src0R = legalizeToReg(Src0);
1038 Variable *T = makeReg(DestTy); 1048 Variable *T = makeReg(DestTy);
1039 if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16) { 1049 if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16 ||
1050 Src0Ty == IceType_i1) {
1040 _sll(T, Src0R, ShiftAmount); 1051 _sll(T, Src0R, ShiftAmount);
1041 _sra(Dest, T, ShiftAmount); 1052 _sra(Dest, T, ShiftAmount);
1042 } 1053 }
1043 } 1054 }
1044 break; 1055 break;
1045 } 1056 }
1046 case InstCast::Zext: { 1057 case InstCast::Zext: {
1047 if (DestTy == IceType_i64) { 1058 if (DestTy == IceType_i64) {
1048 auto *DestLo = llvm::cast<Variable>(loOperand(Dest)); 1059 auto *DestLo = llvm::cast<Variable>(loOperand(Dest));
1049 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest)); 1060 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest));
1050 Variable *Src0R = legalizeToReg(Src0); 1061 Variable *Src0R = legalizeToReg(Src0);
1051 1062
1052 switch (Src0Ty) { 1063 if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16 || Src0Ty == IceType_i1)
1053 default: { assert(Src0Ty != IceType_i64); } break; 1064 _andi(DestLo, Src0R, Mask);
1054 case IceType_i32: 1065 else if (Src0Ty == IceType_i32)
1055 _mov(DestLo, Src0R); 1066 _mov(DestLo, Src0R);
1056 break; 1067 else
1057 case IceType_i8: 1068 assert(Src0Ty != IceType_i64);
1058 case IceType_i16:
1059 _andi(DestLo, Src0R, Mask);
1060 break;
1061 }
1062 1069
1063 auto *Zero = getZero(); 1070 auto *Zero = getZero();
1064 _addiu(DestHi, Zero, 0); 1071 _addiu(DestHi, Zero, 0);
1065 } else { 1072 } else {
1066 Variable *Src0R = legalizeToReg(Src0); 1073 Variable *Src0R = legalizeToReg(Src0);
1067 Variable *T = makeReg(DestTy); 1074 if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16 || Src0Ty == IceType_i1)
1068 if (Src0Ty == IceType_i8 || Src0Ty == IceType_i16) 1075 _andi(Dest, Src0R, Mask);
Jim Stichnoth 2016/05/27 21:59:03 Here and above. Dest is a normal program variable
sagar.thakur 2016/05/30 10:46:02 Done. Added temporaries in all places were instruc
1069 _andi(T, Src0R, Mask);
1070 _mov(Dest, T);
1071 } 1076 }
1072 break; 1077 break;
1073 } 1078 }
1074 case InstCast::Trunc: { 1079 case InstCast::Trunc: {
1075 if (Src0Ty == IceType_i64) 1080 if (Src0Ty == IceType_i64)
1076 Src0 = loOperand(Src0); 1081 Src0 = loOperand(Src0);
1077 Variable *Src0R = legalizeToReg(Src0); 1082 Variable *Src0R = legalizeToReg(Src0);
1078 Variable *T = makeReg(DestTy); 1083 Variable *T = makeReg(DestTy);
1079 _mov(T, Src0R); 1084 _mov(T, Src0R);
1080 _mov(Dest, T); 1085 _mov(Dest, T);
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 Str << "\t.set\t" 1651 Str << "\t.set\t"
1647 << "nomips16\n"; 1652 << "nomips16\n";
1648 } 1653 }
1649 1654
1650 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM]; 1655 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM];
1651 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM]; 1656 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM];
1652 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM]; 1657 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM];
1653 1658
1654 } // end of namespace MIPS32 1659 } // end of namespace MIPS32
1655 } // end of namespace Ice 1660 } // 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