Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "src/compiler/int64-lowering.h" | |
| 6 #include "src/compiler/common-operator.h" | |
| 7 #include "src/compiler/machine-operator.h" | |
| 8 #include "src/compiler/node.h" | |
| 9 | |
| 10 #include "src/compiler/node-properties.h" | |
| 11 | |
| 12 #include "src/signature.h" | |
| 13 | |
| 14 #include "test/unittests/compiler/graph-unittest.h" | |
| 15 | |
| 16 namespace v8 { | |
| 17 namespace internal { | |
| 18 namespace compiler { | |
| 19 | |
| 20 class Int64LoweringTest : public GraphTest { | |
| 21 public: | |
| 22 Int64LoweringTest() : GraphTest(), machine_(zone()) {} | |
| 23 | |
| 24 MachineOperatorBuilder* machine() { return &machine_; } | |
| 25 | |
| 26 void LowerGraph(Node* node, Signature<MachineRepresentation>* signature) { | |
| 27 Node* ret = graph()->NewNode(common()->Return(), node, graph()->start(), | |
| 28 graph()->start()); | |
| 29 NodeProperties::MergeControlToEnd(graph(), common(), ret); | |
| 30 | |
| 31 Int64Lowering lowering(graph(), machine(), common(), zone(), signature); | |
| 32 lowering.LowerGraph(); | |
| 33 } | |
| 34 | |
| 35 void LowerGraph(Node* node, MachineRepresentation return_type, | |
| 36 MachineRepresentation rep = MachineRepresentation::kWord32, | |
| 37 int num_params = 0) { | |
| 38 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, | |
| 39 num_params); | |
| 40 sig_builder.AddReturn(return_type); | |
| 41 for (int i = 0; i < num_params; i++) { | |
| 42 sig_builder.AddParam(rep); | |
| 43 } | |
| 44 LowerGraph(node, sig_builder.Build()); | |
| 45 } | |
| 46 | |
| 47 private: | |
| 48 MachineOperatorBuilder machine_; | |
| 49 }; | |
| 50 | |
| 51 TEST_F(Int64LoweringTest, Int64Constant) { | |
| 52 LowerGraph(Int64Constant(0x1234567890abcdef), MachineRepresentation::kWord64); | |
| 53 | |
| 54 Node* ret = graph()->end()->InputAt(1); | |
| 55 EXPECT_THAT(ret->opcode(), IrOpcode::kReturn); | |
| 56 EXPECT_THAT(NodeProperties::PastValueIndex(ret), 2); | |
| 57 EXPECT_THAT(ret->InputAt(0)->opcode(), IrOpcode::kInt32Constant); | |
|
titzer
2016/02/21 12:50:29
Please have a look at some of the other unittests.
| |
| 58 EXPECT_THAT(OpParameter<int32_t>(ret->InputAt(0)), 0x90abcdef); | |
| 59 EXPECT_THAT(ret->InputAt(1)->opcode(), IrOpcode::kInt32Constant); | |
| 60 EXPECT_THAT(OpParameter<int32_t>(ret->InputAt(1)), 0x12345678); | |
| 61 } | |
| 62 | |
| 63 } // namespace compiler | |
| 64 } // namespace internal | |
| 65 } // namespace v8 | |
| OLD | NEW |