OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 break; | 290 break; |
291 default: | 291 default: |
292 break; | 292 break; |
293 } | 293 } |
294 UNREACHABLE(); | 294 UNREACHABLE(); |
295 return kNoCondition; | 295 return kNoCondition; |
296 } | 296 } |
297 | 297 |
298 } // namespace | 298 } // namespace |
299 | 299 |
300 #define ASSEMBLE_FLOAT_UNOP_RC(asm_instr) \ | 300 #define ASSEMBLE_FLOAT_UNOP_RC(asm_instr, round) \ |
301 do { \ | 301 do { \ |
302 __ asm_instr(i.OutputDoubleRegister(), i.InputDoubleRegister(0), \ | 302 __ asm_instr(i.OutputDoubleRegister(), i.InputDoubleRegister(0), \ |
303 i.OutputRCBit()); \ | 303 i.OutputRCBit()); \ |
| 304 if (round) { \ |
| 305 __ frsp(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \ |
| 306 } \ |
304 } while (0) | 307 } while (0) |
305 | 308 |
306 | 309 #define ASSEMBLE_FLOAT_BINOP_RC(asm_instr, round) \ |
307 #define ASSEMBLE_FLOAT_BINOP_RC(asm_instr) \ | |
308 do { \ | 310 do { \ |
309 __ asm_instr(i.OutputDoubleRegister(), i.InputDoubleRegister(0), \ | 311 __ asm_instr(i.OutputDoubleRegister(), i.InputDoubleRegister(0), \ |
310 i.InputDoubleRegister(1), i.OutputRCBit()); \ | 312 i.InputDoubleRegister(1), i.OutputRCBit()); \ |
| 313 if (round) { \ |
| 314 __ frsp(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \ |
| 315 } \ |
311 } while (0) | 316 } while (0) |
312 | 317 |
313 | |
314 #define ASSEMBLE_BINOP(asm_instr_reg, asm_instr_imm) \ | 318 #define ASSEMBLE_BINOP(asm_instr_reg, asm_instr_imm) \ |
315 do { \ | 319 do { \ |
316 if (HasRegisterInput(instr, 1)) { \ | 320 if (HasRegisterInput(instr, 1)) { \ |
317 __ asm_instr_reg(i.OutputRegister(), i.InputRegister(0), \ | 321 __ asm_instr_reg(i.OutputRegister(), i.InputRegister(0), \ |
318 i.InputRegister(1)); \ | 322 i.InputRegister(1)); \ |
319 } else { \ | 323 } else { \ |
320 __ asm_instr_imm(i.OutputRegister(), i.InputRegister(0), \ | 324 __ asm_instr_imm(i.OutputRegister(), i.InputRegister(0), \ |
321 i.InputImmediate(1)); \ | 325 i.InputImmediate(1)); \ |
322 } \ | 326 } \ |
323 } while (0) | 327 } while (0) |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1082 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1079 } | 1083 } |
1080 #if V8_TARGET_ARCH_PPC64 | 1084 #if V8_TARGET_ARCH_PPC64 |
1081 } | 1085 } |
1082 #endif | 1086 #endif |
1083 break; | 1087 break; |
1084 case kPPC_AddWithOverflow32: | 1088 case kPPC_AddWithOverflow32: |
1085 ASSEMBLE_ADD_WITH_OVERFLOW32(); | 1089 ASSEMBLE_ADD_WITH_OVERFLOW32(); |
1086 break; | 1090 break; |
1087 case kPPC_AddDouble: | 1091 case kPPC_AddDouble: |
1088 ASSEMBLE_FLOAT_BINOP_RC(fadd); | 1092 ASSEMBLE_FLOAT_BINOP_RC(fadd, MiscField::decode(instr->opcode())); |
1089 break; | 1093 break; |
1090 case kPPC_Sub: | 1094 case kPPC_Sub: |
1091 #if V8_TARGET_ARCH_PPC64 | 1095 #if V8_TARGET_ARCH_PPC64 |
1092 if (FlagsModeField::decode(instr->opcode()) != kFlags_none) { | 1096 if (FlagsModeField::decode(instr->opcode()) != kFlags_none) { |
1093 ASSEMBLE_SUB_WITH_OVERFLOW(); | 1097 ASSEMBLE_SUB_WITH_OVERFLOW(); |
1094 } else { | 1098 } else { |
1095 #endif | 1099 #endif |
1096 if (HasRegisterInput(instr, 1)) { | 1100 if (HasRegisterInput(instr, 1)) { |
1097 __ sub(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), | 1101 __ sub(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), |
1098 LeaveOE, i.OutputRCBit()); | 1102 LeaveOE, i.OutputRCBit()); |
1099 } else { | 1103 } else { |
1100 __ subi(i.OutputRegister(), i.InputRegister(0), i.InputImmediate(1)); | 1104 __ subi(i.OutputRegister(), i.InputRegister(0), i.InputImmediate(1)); |
1101 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1105 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1102 } | 1106 } |
1103 #if V8_TARGET_ARCH_PPC64 | 1107 #if V8_TARGET_ARCH_PPC64 |
1104 } | 1108 } |
1105 #endif | 1109 #endif |
1106 break; | 1110 break; |
1107 case kPPC_SubWithOverflow32: | 1111 case kPPC_SubWithOverflow32: |
1108 ASSEMBLE_SUB_WITH_OVERFLOW32(); | 1112 ASSEMBLE_SUB_WITH_OVERFLOW32(); |
1109 break; | 1113 break; |
1110 case kPPC_SubDouble: | 1114 case kPPC_SubDouble: |
1111 ASSEMBLE_FLOAT_BINOP_RC(fsub); | 1115 ASSEMBLE_FLOAT_BINOP_RC(fsub, MiscField::decode(instr->opcode())); |
1112 break; | 1116 break; |
1113 case kPPC_Mul32: | 1117 case kPPC_Mul32: |
1114 __ mullw(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), | 1118 __ mullw(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), |
1115 LeaveOE, i.OutputRCBit()); | 1119 LeaveOE, i.OutputRCBit()); |
1116 break; | 1120 break; |
1117 #if V8_TARGET_ARCH_PPC64 | 1121 #if V8_TARGET_ARCH_PPC64 |
1118 case kPPC_Mul64: | 1122 case kPPC_Mul64: |
1119 __ mulld(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), | 1123 __ mulld(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), |
1120 LeaveOE, i.OutputRCBit()); | 1124 LeaveOE, i.OutputRCBit()); |
1121 break; | 1125 break; |
1122 #endif | 1126 #endif |
1123 case kPPC_MulHigh32: | 1127 case kPPC_MulHigh32: |
1124 __ mulhw(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), | 1128 __ mulhw(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), |
1125 i.OutputRCBit()); | 1129 i.OutputRCBit()); |
1126 break; | 1130 break; |
1127 case kPPC_MulHighU32: | 1131 case kPPC_MulHighU32: |
1128 __ mulhwu(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), | 1132 __ mulhwu(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), |
1129 i.OutputRCBit()); | 1133 i.OutputRCBit()); |
1130 break; | 1134 break; |
1131 case kPPC_MulDouble: | 1135 case kPPC_MulDouble: |
1132 ASSEMBLE_FLOAT_BINOP_RC(fmul); | 1136 ASSEMBLE_FLOAT_BINOP_RC(fmul, MiscField::decode(instr->opcode())); |
1133 break; | 1137 break; |
1134 case kPPC_Div32: | 1138 case kPPC_Div32: |
1135 __ divw(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); | 1139 __ divw(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); |
1136 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1140 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1137 break; | 1141 break; |
1138 #if V8_TARGET_ARCH_PPC64 | 1142 #if V8_TARGET_ARCH_PPC64 |
1139 case kPPC_Div64: | 1143 case kPPC_Div64: |
1140 __ divd(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); | 1144 __ divd(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); |
1141 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1145 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1142 break; | 1146 break; |
1143 #endif | 1147 #endif |
1144 case kPPC_DivU32: | 1148 case kPPC_DivU32: |
1145 __ divwu(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); | 1149 __ divwu(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); |
1146 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1150 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1147 break; | 1151 break; |
1148 #if V8_TARGET_ARCH_PPC64 | 1152 #if V8_TARGET_ARCH_PPC64 |
1149 case kPPC_DivU64: | 1153 case kPPC_DivU64: |
1150 __ divdu(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); | 1154 __ divdu(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); |
1151 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1155 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1152 break; | 1156 break; |
1153 #endif | 1157 #endif |
1154 case kPPC_DivDouble: | 1158 case kPPC_DivDouble: |
1155 ASSEMBLE_FLOAT_BINOP_RC(fdiv); | 1159 ASSEMBLE_FLOAT_BINOP_RC(fdiv, MiscField::decode(instr->opcode())); |
1156 break; | 1160 break; |
1157 case kPPC_Mod32: | 1161 case kPPC_Mod32: |
1158 ASSEMBLE_MODULO(divw, mullw); | 1162 ASSEMBLE_MODULO(divw, mullw); |
1159 break; | 1163 break; |
1160 #if V8_TARGET_ARCH_PPC64 | 1164 #if V8_TARGET_ARCH_PPC64 |
1161 case kPPC_Mod64: | 1165 case kPPC_Mod64: |
1162 ASSEMBLE_MODULO(divd, mulld); | 1166 ASSEMBLE_MODULO(divd, mulld); |
1163 break; | 1167 break; |
1164 #endif | 1168 #endif |
1165 case kPPC_ModU32: | 1169 case kPPC_ModU32: |
(...skipping 12 matching lines...) Expand all Loading... |
1178 case kPPC_Neg: | 1182 case kPPC_Neg: |
1179 __ neg(i.OutputRegister(), i.InputRegister(0), LeaveOE, i.OutputRCBit()); | 1183 __ neg(i.OutputRegister(), i.InputRegister(0), LeaveOE, i.OutputRCBit()); |
1180 break; | 1184 break; |
1181 case kPPC_MaxDouble: | 1185 case kPPC_MaxDouble: |
1182 ASSEMBLE_FLOAT_MAX(kScratchDoubleReg); | 1186 ASSEMBLE_FLOAT_MAX(kScratchDoubleReg); |
1183 break; | 1187 break; |
1184 case kPPC_MinDouble: | 1188 case kPPC_MinDouble: |
1185 ASSEMBLE_FLOAT_MIN(kScratchDoubleReg); | 1189 ASSEMBLE_FLOAT_MIN(kScratchDoubleReg); |
1186 break; | 1190 break; |
1187 case kPPC_AbsDouble: | 1191 case kPPC_AbsDouble: |
1188 ASSEMBLE_FLOAT_UNOP_RC(fabs); | 1192 ASSEMBLE_FLOAT_UNOP_RC(fabs, 0); |
1189 break; | 1193 break; |
1190 case kPPC_SqrtDouble: | 1194 case kPPC_SqrtDouble: |
1191 ASSEMBLE_FLOAT_UNOP_RC(fsqrt); | 1195 ASSEMBLE_FLOAT_UNOP_RC(fsqrt, MiscField::decode(instr->opcode())); |
1192 break; | 1196 break; |
1193 case kPPC_FloorDouble: | 1197 case kPPC_FloorDouble: |
1194 ASSEMBLE_FLOAT_UNOP_RC(frim); | 1198 ASSEMBLE_FLOAT_UNOP_RC(frim, MiscField::decode(instr->opcode())); |
1195 break; | 1199 break; |
1196 case kPPC_CeilDouble: | 1200 case kPPC_CeilDouble: |
1197 ASSEMBLE_FLOAT_UNOP_RC(frip); | 1201 ASSEMBLE_FLOAT_UNOP_RC(frip, MiscField::decode(instr->opcode())); |
1198 break; | 1202 break; |
1199 case kPPC_TruncateDouble: | 1203 case kPPC_TruncateDouble: |
1200 ASSEMBLE_FLOAT_UNOP_RC(friz); | 1204 ASSEMBLE_FLOAT_UNOP_RC(friz, MiscField::decode(instr->opcode())); |
1201 break; | 1205 break; |
1202 case kPPC_RoundDouble: | 1206 case kPPC_RoundDouble: |
1203 ASSEMBLE_FLOAT_UNOP_RC(frin); | 1207 ASSEMBLE_FLOAT_UNOP_RC(frin, MiscField::decode(instr->opcode())); |
1204 break; | 1208 break; |
1205 case kPPC_NegDouble: | 1209 case kPPC_NegDouble: |
1206 ASSEMBLE_FLOAT_UNOP_RC(fneg); | 1210 ASSEMBLE_FLOAT_UNOP_RC(fneg, 0); |
1207 break; | 1211 break; |
1208 case kPPC_Cntlz32: | 1212 case kPPC_Cntlz32: |
1209 __ cntlzw_(i.OutputRegister(), i.InputRegister(0)); | 1213 __ cntlzw_(i.OutputRegister(), i.InputRegister(0)); |
1210 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1214 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1211 break; | 1215 break; |
1212 #if V8_TARGET_ARCH_PPC64 | 1216 #if V8_TARGET_ARCH_PPC64 |
1213 case kPPC_Cntlz64: | 1217 case kPPC_Cntlz64: |
1214 __ cntlzd_(i.OutputRegister(), i.InputRegister(0)); | 1218 __ cntlzd_(i.OutputRegister(), i.InputRegister(0)); |
1215 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1219 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1216 break; | 1220 break; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 __ li(i.OutputRegister(1), Operand::Zero()); | 1406 __ li(i.OutputRegister(1), Operand::Zero()); |
1403 __ bc(v8::internal::Assembler::kInstrSize * 2, BT, crbit); | 1407 __ bc(v8::internal::Assembler::kInstrSize * 2, BT, crbit); |
1404 __ li(i.OutputRegister(1), Operand(1)); | 1408 __ li(i.OutputRegister(1), Operand(1)); |
1405 } | 1409 } |
1406 } | 1410 } |
1407 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1411 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1408 break; | 1412 break; |
1409 } | 1413 } |
1410 #endif | 1414 #endif |
1411 case kPPC_DoubleToFloat32: | 1415 case kPPC_DoubleToFloat32: |
1412 ASSEMBLE_FLOAT_UNOP_RC(frsp); | 1416 ASSEMBLE_FLOAT_UNOP_RC(frsp, 0); |
1413 break; | 1417 break; |
1414 case kPPC_Float32ToDouble: | 1418 case kPPC_Float32ToDouble: |
1415 // Nothing to do. | 1419 // Nothing to do. |
1416 __ Move(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); | 1420 __ Move(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); |
1417 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1421 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1418 break; | 1422 break; |
1419 case kPPC_DoubleExtractLowWord32: | 1423 case kPPC_DoubleExtractLowWord32: |
1420 __ MovDoubleLowToInt(i.OutputRegister(), i.InputDoubleRegister(0)); | 1424 __ MovDoubleLowToInt(i.OutputRegister(), i.InputDoubleRegister(0)); |
1421 DCHECK_EQ(LeaveRC, i.OutputRCBit()); | 1425 DCHECK_EQ(LeaveRC, i.OutputRCBit()); |
1422 break; | 1426 break; |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 padding_size -= v8::internal::Assembler::kInstrSize; | 2011 padding_size -= v8::internal::Assembler::kInstrSize; |
2008 } | 2012 } |
2009 } | 2013 } |
2010 } | 2014 } |
2011 | 2015 |
2012 #undef __ | 2016 #undef __ |
2013 | 2017 |
2014 } // namespace compiler | 2018 } // namespace compiler |
2015 } // namespace internal | 2019 } // namespace internal |
2016 } // namespace v8 | 2020 } // namespace v8 |
OLD | NEW |