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