OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "src/compiler/machine-operator.h" | |
6 #include "src/compiler/operator-properties-inl.h" | |
7 #include "test/compiler-unittests/compiler-unittests.h" | |
8 #include "testing/gmock/include/gmock/gmock.h" | |
9 | |
10 using testing::IsNull; | |
11 | |
12 namespace v8 { | |
13 namespace internal { | |
14 namespace compiler { | |
15 | |
16 class MachineOperatorCommonTest : public CompilerTestWithParam<MachineType> { | |
17 public: | |
18 MachineOperatorCommonTest() : machine_(NULL) {} | |
19 virtual ~MachineOperatorCommonTest() { EXPECT_THAT(machine_, IsNull()); } | |
20 | |
21 virtual void SetUp() V8_OVERRIDE { | |
22 CompilerTestWithParam<MachineType>::SetUp(); | |
23 machine_ = new MachineOperatorBuilder(zone(), GetParam()); | |
24 } | |
25 | |
26 virtual void TearDown() V8_OVERRIDE { | |
27 delete machine_; | |
28 machine_ = NULL; | |
29 CompilerTestWithParam<MachineType>::TearDown(); | |
30 } | |
31 | |
32 protected: | |
33 MachineOperatorBuilder* machine() const { return machine_; } | |
34 | |
35 private: | |
36 MachineOperatorBuilder* machine_; | |
37 }; | |
38 | |
39 | |
40 TEST_P(MachineOperatorCommonTest, ChangeInt32ToInt64) { | |
41 Operator* op = machine()->ChangeInt32ToInt64(); | |
42 EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); | |
43 EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); | |
44 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); | |
45 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); | |
46 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); | |
47 } | |
48 | |
49 | |
50 TEST_P(MachineOperatorCommonTest, ChangeUint32ToUint64) { | |
51 Operator* op = machine()->ChangeUint32ToUint64(); | |
52 EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); | |
53 EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); | |
54 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); | |
55 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); | |
56 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); | |
57 } | |
58 | |
59 | |
60 TEST_P(MachineOperatorCommonTest, TruncateFloat64ToInt32) { | |
61 Operator* op = machine()->TruncateFloat64ToInt32(); | |
62 EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); | |
63 EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); | |
64 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); | |
65 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); | |
66 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); | |
67 } | |
68 | |
69 | |
70 TEST_P(MachineOperatorCommonTest, TruncateInt64ToInt32) { | |
71 Operator* op = machine()->TruncateInt64ToInt32(); | |
72 EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); | |
73 EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); | |
74 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); | |
75 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); | |
76 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); | |
77 } | |
78 | |
79 | |
80 INSTANTIATE_TEST_CASE_P(MachineOperatorTest, MachineOperatorCommonTest, | |
81 ::testing::Values(kRepWord32, kRepWord64)); | |
82 | |
83 } // namespace compiler | |
84 } // namespace internal | |
85 } // namespace v8 | |
OLD | NEW |