| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/int64-lowering.h" | 5 #include "src/compiler/int64-lowering.h" |
| 6 #include "src/compiler/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
| 7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
| 8 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
| 9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 machine_(zone(), MachineRepresentation::kWord32, | 33 machine_(zone(), MachineRepresentation::kWord32, |
| 34 MachineOperatorBuilder::Flag::kAllOptionalOps) { | 34 MachineOperatorBuilder::Flag::kAllOptionalOps) { |
| 35 value_[0] = 0x1234567890abcdef; | 35 value_[0] = 0x1234567890abcdef; |
| 36 value_[1] = 0x1edcba098765432f; | 36 value_[1] = 0x1edcba098765432f; |
| 37 value_[2] = 0x1133557799886644; | 37 value_[2] = 0x1133557799886644; |
| 38 } | 38 } |
| 39 | 39 |
| 40 MachineOperatorBuilder* machine() { return &machine_; } | 40 MachineOperatorBuilder* machine() { return &machine_; } |
| 41 | 41 |
| 42 void LowerGraph(Node* node, Signature<MachineRepresentation>* signature) { | 42 void LowerGraph(Node* node, Signature<MachineRepresentation>* signature) { |
| 43 Node* ret = graph()->NewNode(common()->Return(), node, graph()->start(), | 43 Node* zero = graph()->NewNode(common()->Int32Constant(0)); |
| 44 graph()->start()); | 44 Node* ret = graph()->NewNode(common()->Return(), zero, node, |
| 45 graph()->start(), graph()->start()); |
| 45 NodeProperties::MergeControlToEnd(graph(), common(), ret); | 46 NodeProperties::MergeControlToEnd(graph(), common(), ret); |
| 46 | 47 |
| 47 Int64Lowering lowering(graph(), machine(), common(), zone(), signature); | 48 Int64Lowering lowering(graph(), machine(), common(), zone(), signature); |
| 48 lowering.LowerGraph(); | 49 lowering.LowerGraph(); |
| 49 } | 50 } |
| 50 | 51 |
| 51 void LowerGraph(Node* node, MachineRepresentation return_type, | 52 void LowerGraph(Node* node, MachineRepresentation return_type, |
| 52 MachineRepresentation rep = MachineRepresentation::kWord32, | 53 MachineRepresentation rep = MachineRepresentation::kWord32, |
| 53 int num_params = 0) { | 54 int num_params = 0) { |
| 54 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, | 55 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 int32_t index = 2222; \ | 210 int32_t index = 2222; \ |
| 210 int32_t return_value = 0x5555; \ | 211 int32_t return_value = 0x5555; \ |
| 211 \ | 212 \ |
| 212 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 0); \ | 213 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 0); \ |
| 213 sig_builder.AddReturn(MachineRepresentation::kWord32); \ | 214 sig_builder.AddReturn(MachineRepresentation::kWord32); \ |
| 214 \ | 215 \ |
| 215 Node* store = graph()->NewNode(machine()->kStore(kRep64), \ | 216 Node* store = graph()->NewNode(machine()->kStore(kRep64), \ |
| 216 Int32Constant(base), Int32Constant(index), \ | 217 Int32Constant(base), Int32Constant(index), \ |
| 217 Int64Constant(value(0)), start(), start()); \ | 218 Int64Constant(value(0)), start(), start()); \ |
| 218 \ | 219 \ |
| 219 Node* ret = graph()->NewNode(common()->Return(), \ | 220 Node* zero = graph()->NewNode(common()->Int32Constant(0)); \ |
| 221 Node* ret = graph()->NewNode(common()->Return(), zero, \ |
| 220 Int32Constant(return_value), store, start()); \ | 222 Int32Constant(return_value), store, start()); \ |
| 221 \ | 223 \ |
| 222 NodeProperties::MergeControlToEnd(graph(), common(), ret); \ | 224 NodeProperties::MergeControlToEnd(graph(), common(), ret); \ |
| 223 \ | 225 \ |
| 224 Int64Lowering lowering(graph(), machine(), common(), zone(), \ | 226 Int64Lowering lowering(graph(), machine(), common(), zone(), \ |
| 225 sig_builder.Build()); \ | 227 sig_builder.Build()); \ |
| 226 lowering.LowerGraph(); \ | 228 lowering.LowerGraph(); \ |
| 227 \ | 229 \ |
| 228 STORE_VERIFY(kStore, kRep32) | 230 STORE_VERIFY(kStore, kRep32) |
| 229 | 231 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 Matcher<Node*> call_matcher = | 308 Matcher<Node*> call_matcher = |
| 307 IsCall(testing::_, IsInt32Constant(function), start(), start()); | 309 IsCall(testing::_, IsInt32Constant(function), start(), start()); |
| 308 | 310 |
| 309 EXPECT_THAT(graph()->end()->InputAt(1), | 311 EXPECT_THAT(graph()->end()->InputAt(1), |
| 310 IsReturn2(IsProjection(0, AllOf(CaptureEq(&call), call_matcher)), | 312 IsReturn2(IsProjection(0, AllOf(CaptureEq(&call), call_matcher)), |
| 311 IsProjection(1, AllOf(CaptureEq(&call), call_matcher)), | 313 IsProjection(1, AllOf(CaptureEq(&call), call_matcher)), |
| 312 start(), start())); | 314 start(), start())); |
| 313 | 315 |
| 314 CompareCallDescriptors( | 316 CompareCallDescriptors( |
| 315 OpParameter<const CallDescriptor*>( | 317 OpParameter<const CallDescriptor*>( |
| 316 graph()->end()->InputAt(1)->InputAt(0)->InputAt(0)), | 318 graph()->end()->InputAt(1)->InputAt(1)->InputAt(0)), |
| 317 wasm::ModuleEnv::GetI32WasmCallDescriptor(zone(), desc)); | 319 wasm::ModuleEnv::GetI32WasmCallDescriptor(zone(), desc)); |
| 318 } | 320 } |
| 319 | 321 |
| 320 TEST_F(Int64LoweringTest, CallI64Parameter) { | 322 TEST_F(Int64LoweringTest, CallI64Parameter) { |
| 321 int32_t function = 0x9999; | 323 int32_t function = 0x9999; |
| 322 | 324 |
| 323 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 3); | 325 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 3); |
| 324 sig_builder.AddReturn(MachineRepresentation::kWord32); | 326 sig_builder.AddReturn(MachineRepresentation::kWord32); |
| 325 sig_builder.AddParam(MachineRepresentation::kWord64); | 327 sig_builder.AddParam(MachineRepresentation::kWord64); |
| 326 sig_builder.AddParam(MachineRepresentation::kWord32); | 328 sig_builder.AddParam(MachineRepresentation::kWord32); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 340 IsReturn(IsCall(testing::_, IsInt32Constant(function), | 342 IsReturn(IsCall(testing::_, IsInt32Constant(function), |
| 341 IsInt32Constant(low_word_value(0)), | 343 IsInt32Constant(low_word_value(0)), |
| 342 IsInt32Constant(high_word_value(0)), | 344 IsInt32Constant(high_word_value(0)), |
| 343 IsInt32Constant(low_word_value(1)), | 345 IsInt32Constant(low_word_value(1)), |
| 344 IsInt32Constant(low_word_value(2)), | 346 IsInt32Constant(low_word_value(2)), |
| 345 IsInt32Constant(high_word_value(2)), start(), start()), | 347 IsInt32Constant(high_word_value(2)), start(), start()), |
| 346 start(), start())); | 348 start(), start())); |
| 347 | 349 |
| 348 CompareCallDescriptors( | 350 CompareCallDescriptors( |
| 349 OpParameter<const CallDescriptor*>( | 351 OpParameter<const CallDescriptor*>( |
| 350 graph()->end()->InputAt(1)->InputAt(0)), | 352 graph()->end()->InputAt(1)->InputAt(1)), |
| 351 wasm::ModuleEnv::GetI32WasmCallDescriptor(zone(), desc)); | 353 wasm::ModuleEnv::GetI32WasmCallDescriptor(zone(), desc)); |
| 352 } | 354 } |
| 353 | 355 |
| 354 TEST_F(Int64LoweringTest, Int64Add) { | 356 TEST_F(Int64LoweringTest, Int64Add) { |
| 355 LowerGraph(graph()->NewNode(machine()->Int64Add(), Int64Constant(value(0)), | 357 LowerGraph(graph()->NewNode(machine()->Int64Add(), Int64Constant(value(0)), |
| 356 Int64Constant(value(1))), | 358 Int64Constant(value(1))), |
| 357 MachineRepresentation::kWord64); | 359 MachineRepresentation::kWord64); |
| 358 | 360 |
| 359 Capture<Node*> add; | 361 Capture<Node*> add; |
| 360 Matcher<Node*> add_matcher = IsInt32PairAdd( | 362 Matcher<Node*> add_matcher = IsInt32PairAdd( |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 | 871 |
| 870 eff_phi->InsertInput(zone(), 1, store); | 872 eff_phi->InsertInput(zone(), 1, store); |
| 871 NodeProperties::ChangeOp(eff_phi, | 873 NodeProperties::ChangeOp(eff_phi, |
| 872 common()->ResizeMergeOrPhi(eff_phi->op(), 2)); | 874 common()->ResizeMergeOrPhi(eff_phi->op(), 2)); |
| 873 | 875 |
| 874 LowerGraph(load, MachineRepresentation::kWord64); | 876 LowerGraph(load, MachineRepresentation::kWord64); |
| 875 } | 877 } |
| 876 } // namespace compiler | 878 } // namespace compiler |
| 877 } // namespace internal | 879 } // namespace internal |
| 878 } // namespace v8 | 880 } // namespace v8 |
| OLD | NEW |