Chromium Code Reviews| 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/crankshaft/s390/lithium-s390.h" | 5 #include "src/crankshaft/s390/lithium-s390.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/crankshaft/hydrogen-osr.h" | 9 #include "src/crankshaft/hydrogen-osr.h" |
| 10 #include "src/crankshaft/lithium-inl.h" | 10 #include "src/crankshaft/lithium-inl.h" |
| 11 #include "src/crankshaft/s390/lithium-codegen-s390.h" | 11 #include "src/crankshaft/s390/lithium-codegen-s390.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 | 15 |
| 16 #define DEFINE_COMPILE(type) \ | 16 #define DEFINE_COMPILE(type) \ |
| 17 void L##type::CompileToNative(LCodeGen* generator) { \ | 17 void L##type::CompileToNative(LCodeGen* generator) { \ |
| 18 generator->Do##type(this); \ | 18 generator->Do##type(this); \ |
| 19 } | 19 } |
| 20 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) | 20 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) |
| 21 #undef DEFINE_COMPILE | 21 #undef DEFINE_COMPILE |
| 22 | 22 |
| 23 const char* LInstruction::GetOpcodeName(LInstruction::Opcode op) { | |
| 24 switch (op) { | |
|
JoranSiu
2016/12/07 21:01:42
What is the purpose of this new function? I don't
| |
| 25 #define DECLARE_OPCODE(type) \ | |
| 26 case Opcode::k##type: \ | |
| 27 return #type; | |
| 28 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) | |
| 29 #undef DECLARE_OPCODE | |
| 30 default: | |
| 31 return NULL; | |
| 32 } | |
| 33 } | |
| 34 | |
| 23 #ifdef DEBUG | 35 #ifdef DEBUG |
| 24 void LInstruction::VerifyCall() { | 36 void LInstruction::VerifyCall() { |
| 25 // Call instructions can use only fixed registers as temporaries and | 37 // Call instructions can use only fixed registers as temporaries and |
| 26 // outputs because all registers are blocked by the calling convention. | 38 // outputs because all registers are blocked by the calling convention. |
| 27 // Inputs operands must use a fixed register or use-at-start policy or | 39 // Inputs operands must use a fixed register or use-at-start policy or |
| 28 // a non-register policy. | 40 // a non-register policy. |
| 29 DCHECK(Output() == NULL || LUnallocated::cast(Output())->HasFixedPolicy() || | 41 DCHECK(Output() == NULL || LUnallocated::cast(Output())->HasFixedPolicy() || |
| 30 !LUnallocated::cast(Output())->HasRegisterPolicy()); | 42 !LUnallocated::cast(Output())->HasRegisterPolicy()); |
| 31 for (UseIterator it(this); !it.Done(); it.Advance()) { | 43 for (UseIterator it(this); !it.Done(); it.Advance()) { |
| 32 LUnallocated* operand = LUnallocated::cast(it.Current()); | 44 LUnallocated* operand = LUnallocated::cast(it.Current()); |
| (...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1346 } else { | 1358 } else { |
| 1347 return DoArithmeticT(Token::MUL, instr); | 1359 return DoArithmeticT(Token::MUL, instr); |
| 1348 } | 1360 } |
| 1349 } | 1361 } |
| 1350 | 1362 |
| 1351 LInstruction* LChunkBuilder::DoSub(HSub* instr) { | 1363 LInstruction* LChunkBuilder::DoSub(HSub* instr) { |
| 1352 if (instr->representation().IsSmiOrInteger32()) { | 1364 if (instr->representation().IsSmiOrInteger32()) { |
| 1353 DCHECK(instr->left()->representation().Equals(instr->representation())); | 1365 DCHECK(instr->left()->representation().Equals(instr->representation())); |
| 1354 DCHECK(instr->right()->representation().Equals(instr->representation())); | 1366 DCHECK(instr->right()->representation().Equals(instr->representation())); |
| 1355 | 1367 |
| 1356 if (instr->left()->IsConstant() && | |
| 1357 !instr->CheckFlag(HValue::kCanOverflow)) { | |
| 1358 // If lhs is constant, do reverse subtraction instead. | |
| 1359 return DoRSub(instr); | |
| 1360 } | |
| 1361 | |
| 1362 LOperand* left = UseRegisterAtStart(instr->left()); | 1368 LOperand* left = UseRegisterAtStart(instr->left()); |
| 1363 LOperand* right = UseOrConstantAtStart(instr->right()); | 1369 LOperand* right = UseOrConstantAtStart(instr->right()); |
| 1364 LSubI* sub = new (zone()) LSubI(left, right); | 1370 LSubI* sub = new (zone()) LSubI(left, right); |
| 1365 LInstruction* result = DefineAsRegister(sub); | 1371 LInstruction* result = DefineAsRegister(sub); |
| 1366 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1372 if (instr->CheckFlag(HValue::kCanOverflow)) { |
| 1367 result = AssignEnvironment(result); | 1373 result = AssignEnvironment(result); |
| 1368 } | 1374 } |
| 1369 return result; | 1375 return result; |
| 1370 } else if (instr->representation().IsDouble()) { | 1376 } else if (instr->representation().IsDouble()) { |
| 1371 return DoArithmeticD(Token::SUB, instr); | 1377 return DoArithmeticD(Token::SUB, instr); |
| 1372 } else { | 1378 } else { |
| 1373 return DoArithmeticT(Token::SUB, instr); | 1379 return DoArithmeticT(Token::SUB, instr); |
| 1374 } | 1380 } |
| 1375 } | 1381 } |
| 1376 | 1382 |
| 1377 LInstruction* LChunkBuilder::DoRSub(HSub* instr) { | |
| 1378 DCHECK(instr->representation().IsSmiOrInteger32()); | |
| 1379 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
| 1380 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
| 1381 DCHECK(!instr->CheckFlag(HValue::kCanOverflow)); | |
| 1382 | |
| 1383 // Note: The lhs of the subtraction becomes the rhs of the | |
| 1384 // reverse-subtraction. | |
| 1385 LOperand* left = UseRegisterAtStart(instr->right()); | |
| 1386 LOperand* right = UseOrConstantAtStart(instr->left()); | |
| 1387 LRSubI* rsb = new (zone()) LRSubI(left, right); | |
| 1388 LInstruction* result = DefineAsRegister(rsb); | |
| 1389 return result; | |
| 1390 } | |
| 1391 | |
| 1392 LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) { | 1383 LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) { |
| 1393 LOperand* multiplier_op = UseRegister(mul->left()); | 1384 LOperand* multiplier_op = UseRegister(mul->left()); |
| 1394 LOperand* multiplicand_op = UseRegister(mul->right()); | 1385 LOperand* multiplicand_op = UseRegister(mul->right()); |
| 1395 LOperand* addend_op = UseRegister(addend); | 1386 LOperand* addend_op = UseRegister(addend); |
| 1396 return DefineAsRegister( | 1387 return DefineAsRegister( |
| 1397 new (zone()) LMultiplyAddD(addend_op, multiplier_op, multiplicand_op)); | 1388 new (zone()) LMultiplyAddD(addend_op, multiplier_op, multiplicand_op)); |
| 1398 } | 1389 } |
| 1399 | 1390 |
| 1400 LInstruction* LChunkBuilder::DoMultiplySub(HValue* minuend, HMul* mul) { | 1391 LInstruction* LChunkBuilder::DoMultiplySub(HValue* minuend, HMul* mul) { |
| 1401 LOperand* minuend_op = UseRegister(minuend); | 1392 LOperand* minuend_op = UseRegister(minuend); |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2166 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2157 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2167 LOperand* object = UseRegister(instr->object()); | 2158 LOperand* object = UseRegister(instr->object()); |
| 2168 LOperand* index = UseTempRegister(instr->index()); | 2159 LOperand* index = UseTempRegister(instr->index()); |
| 2169 LLoadFieldByIndex* load = new (zone()) LLoadFieldByIndex(object, index); | 2160 LLoadFieldByIndex* load = new (zone()) LLoadFieldByIndex(object, index); |
| 2170 LInstruction* result = DefineSameAsFirst(load); | 2161 LInstruction* result = DefineSameAsFirst(load); |
| 2171 return AssignPointerMap(result); | 2162 return AssignPointerMap(result); |
| 2172 } | 2163 } |
| 2173 | 2164 |
| 2174 } // namespace internal | 2165 } // namespace internal |
| 2175 } // namespace v8 | 2166 } // namespace v8 |
| OLD | NEW |