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

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 339643003: Legalize div/idiv operands to avoid immediates. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: space Created 6 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/div_legalization.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/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 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 // This file implements the TargetLoweringX8632 class, which 10 // This file implements the TargetLoweringX8632 class, which
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 _mov(Dest, T); 1129 _mov(Dest, T);
1130 break; 1130 break;
1131 case InstArithmetic::Ashr: 1131 case InstArithmetic::Ashr:
1132 _mov(T, Src0); 1132 _mov(T, Src0);
1133 if (!llvm::isa<Constant>(Src1)) 1133 if (!llvm::isa<Constant>(Src1))
1134 Src1 = legalizeToVar(Src1, false, Reg_ecx); 1134 Src1 = legalizeToVar(Src1, false, Reg_ecx);
1135 _sar(T, Src1); 1135 _sar(T, Src1);
1136 _mov(Dest, T); 1136 _mov(Dest, T);
1137 break; 1137 break;
1138 case InstArithmetic::Udiv: 1138 case InstArithmetic::Udiv:
1139 Src1 = legalize(Src1, Legal_Reg | Legal_Mem, true);
Jim Stichnoth 2014/06/17 05:35:06 It's hard to wrap my head around the AllowOverlap
jvoung (off chromium) 2014/06/17 16:11:08 Done. Yeah it looks like it will be ignored in thi
1139 if (Dest->getType() == IceType_i8) { 1140 if (Dest->getType() == IceType_i8) {
1140 Variable *T_ah = NULL; 1141 Variable *T_ah = NULL;
1141 Constant *Zero = Ctx->getConstantInt(IceType_i8, 0); 1142 Constant *Zero = Ctx->getConstantInt(IceType_i8, 0);
1142 _mov(T, Src0, Reg_eax); 1143 _mov(T, Src0, Reg_eax);
1143 _mov(T_ah, Zero, Reg_ah); 1144 _mov(T_ah, Zero, Reg_ah);
1144 _div(T, Src1, T_ah); 1145 _div(T, Src1, T_ah);
1145 _mov(Dest, T); 1146 _mov(Dest, T);
1146 } else { 1147 } else {
1147 Constant *Zero = Ctx->getConstantInt(IceType_i32, 0); 1148 Constant *Zero = Ctx->getConstantInt(IceType_i32, 0);
1148 _mov(T, Src0, Reg_eax); 1149 _mov(T, Src0, Reg_eax);
1149 _mov(T_edx, Zero, Reg_edx); 1150 _mov(T_edx, Zero, Reg_edx);
1150 _div(T, Src1, T_edx); 1151 _div(T, Src1, T_edx);
1151 _mov(Dest, T); 1152 _mov(Dest, T);
1152 } 1153 }
1153 break; 1154 break;
1154 case InstArithmetic::Sdiv: 1155 case InstArithmetic::Sdiv:
1156 Src1 = legalize(Src1, Legal_Reg | Legal_Mem, true);
1155 T_edx = makeReg(IceType_i32, Reg_edx); 1157 T_edx = makeReg(IceType_i32, Reg_edx);
1156 _mov(T, Src0, Reg_eax); 1158 _mov(T, Src0, Reg_eax);
1157 _cdq(T_edx, T); 1159 _cdq(T_edx, T);
1158 _idiv(T, Src1, T_edx); 1160 _idiv(T, Src1, T_edx);
1159 _mov(Dest, T); 1161 _mov(Dest, T);
1160 break; 1162 break;
1161 case InstArithmetic::Urem: 1163 case InstArithmetic::Urem:
1164 Src1 = legalize(Src1, Legal_Reg | Legal_Mem, true);
1162 if (Dest->getType() == IceType_i8) { 1165 if (Dest->getType() == IceType_i8) {
1163 Variable *T_ah = NULL; 1166 Variable *T_ah = NULL;
1164 Constant *Zero = Ctx->getConstantInt(IceType_i8, 0); 1167 Constant *Zero = Ctx->getConstantInt(IceType_i8, 0);
1165 _mov(T, Src0, Reg_eax); 1168 _mov(T, Src0, Reg_eax);
1166 _mov(T_ah, Zero, Reg_ah); 1169 _mov(T_ah, Zero, Reg_ah);
1167 _div(T_ah, Src1, T); 1170 _div(T_ah, Src1, T);
1168 _mov(Dest, T_ah); 1171 _mov(Dest, T_ah);
1169 } else { 1172 } else {
1170 Constant *Zero = Ctx->getConstantInt(IceType_i32, 0); 1173 Constant *Zero = Ctx->getConstantInt(IceType_i32, 0);
1171 _mov(T_edx, Zero, Reg_edx); 1174 _mov(T_edx, Zero, Reg_edx);
1172 _mov(T, Src0, Reg_eax); 1175 _mov(T, Src0, Reg_eax);
1173 _div(T_edx, Src1, T); 1176 _div(T_edx, Src1, T);
1174 _mov(Dest, T_edx); 1177 _mov(Dest, T_edx);
1175 } 1178 }
1176 break; 1179 break;
1177 case InstArithmetic::Srem: 1180 case InstArithmetic::Srem:
1181 Src1 = legalize(Src1, Legal_Reg | Legal_Mem, true);
1178 T_edx = makeReg(IceType_i32, Reg_edx); 1182 T_edx = makeReg(IceType_i32, Reg_edx);
1179 _mov(T, Src0, Reg_eax); 1183 _mov(T, Src0, Reg_eax);
1180 _cdq(T_edx, T); 1184 _cdq(T_edx, T);
1181 _idiv(T_edx, Src1, T); 1185 _idiv(T_edx, Src1, T);
1182 _mov(Dest, T_edx); 1186 _mov(Dest, T_edx);
1183 break; 1187 break;
1184 case InstArithmetic::Fadd: 1188 case InstArithmetic::Fadd:
1185 _mov(T, Src0); 1189 _mov(T, Src0);
1186 _addss(T, Src1); 1190 _addss(T, Src1);
1187 _mov(Dest, T); 1191 _mov(Dest, T);
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 // llvm-mc doesn't parse "dword ptr [.L$foo]". 2265 // llvm-mc doesn't parse "dword ptr [.L$foo]".
2262 Str << "dword ptr [L$" << IceType_f32 << "$" << getPoolEntryID() << "]"; 2266 Str << "dword ptr [L$" << IceType_f32 << "$" << getPoolEntryID() << "]";
2263 } 2267 }
2264 2268
2265 template <> void ConstantDouble::emit(GlobalContext *Ctx) const { 2269 template <> void ConstantDouble::emit(GlobalContext *Ctx) const {
2266 Ostream &Str = Ctx->getStrEmit(); 2270 Ostream &Str = Ctx->getStrEmit();
2267 Str << "qword ptr [L$" << IceType_f64 << "$" << getPoolEntryID() << "]"; 2271 Str << "qword ptr [L$" << IceType_f64 << "$" << getPoolEntryID() << "]";
2268 } 2272 }
2269 2273
2270 } // end of namespace Ice 2274 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/div_legalization.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698