Chromium Code Reviews| Index: test/unittests/compiler/int64-lowering-unittest.cc |
| diff --git a/test/unittests/compiler/int64-lowering-unittest.cc b/test/unittests/compiler/int64-lowering-unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bfd3857bcb4c2d7b7a042c516f7a0737a8f91ef1 |
| --- /dev/null |
| +++ b/test/unittests/compiler/int64-lowering-unittest.cc |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2016 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "src/compiler/int64-lowering.h" |
| +#include "src/compiler/common-operator.h" |
| +#include "src/compiler/machine-operator.h" |
| +#include "src/compiler/node.h" |
| + |
| +#include "src/compiler/node-properties.h" |
| + |
| +#include "src/signature.h" |
| + |
| +#include "test/unittests/compiler/graph-unittest.h" |
| + |
| +namespace v8 { |
| +namespace internal { |
| +namespace compiler { |
| + |
| +class Int64LoweringTest : public GraphTest { |
| + public: |
| + Int64LoweringTest() : GraphTest(), machine_(zone()) {} |
| + |
| + MachineOperatorBuilder* machine() { return &machine_; } |
| + |
| + void LowerGraph(Node* node, Signature<MachineRepresentation>* signature) { |
| + Node* ret = graph()->NewNode(common()->Return(), node, graph()->start(), |
| + graph()->start()); |
| + NodeProperties::MergeControlToEnd(graph(), common(), ret); |
| + |
| + Int64Lowering lowering(graph(), machine(), common(), zone(), signature); |
| + lowering.LowerGraph(); |
| + } |
| + |
| + void LowerGraph(Node* node, MachineRepresentation return_type, |
| + MachineRepresentation rep = MachineRepresentation::kWord32, |
| + int num_params = 0) { |
| + Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, |
| + num_params); |
| + sig_builder.AddReturn(return_type); |
| + for (int i = 0; i < num_params; i++) { |
| + sig_builder.AddParam(rep); |
| + } |
| + LowerGraph(node, sig_builder.Build()); |
| + } |
| + |
| + private: |
| + MachineOperatorBuilder machine_; |
| +}; |
| + |
| +TEST_F(Int64LoweringTest, Int64Constant) { |
| + LowerGraph(Int64Constant(0x1234567890abcdef), MachineRepresentation::kWord64); |
| + |
| + Node* ret = graph()->end()->InputAt(1); |
| + EXPECT_THAT(ret->opcode(), IrOpcode::kReturn); |
| + EXPECT_THAT(NodeProperties::PastValueIndex(ret), 2); |
| + 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.
|
| + EXPECT_THAT(OpParameter<int32_t>(ret->InputAt(0)), 0x90abcdef); |
| + EXPECT_THAT(ret->InputAt(1)->opcode(), IrOpcode::kInt32Constant); |
| + EXPECT_THAT(OpParameter<int32_t>(ret->InputAt(1)), 0x12345678); |
| +} |
| + |
| +} // namespace compiler |
| +} // namespace internal |
| +} // namespace v8 |