Commit 643ed5b8 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Fix missing MachineOperator unittest.

The machine-operator-unittest.cc file was missing from unittests.gyp.
Fixed the compiler errors and added it back.

TBR=machenbach@chromium.org

Review URL: https://codereview.chromium.org/824243003

Cr-Commit-Position: refs/heads/master@{#25948}
parent c6e74e70
...@@ -230,11 +230,13 @@ class MachineOperatorBuilder FINAL : public ZoneObject { ...@@ -230,11 +230,13 @@ class MachineOperatorBuilder FINAL : public ZoneObject {
const MachineOperatorGlobalCache& cache_; const MachineOperatorGlobalCache& cache_;
const MachineType word_; const MachineType word_;
const Flags flags_; const Flags flags_;
DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder);
}; };
DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags)
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "src/compiler/machine-operator.h" #include "src/compiler/machine-operator.h"
#include "src/compiler/operator-properties-inl.h" #include "src/compiler/opcodes.h"
#include "testing/gtest-support.h" #include "src/compiler/operator.h"
#include "src/compiler/operator-properties.h"
#include "test/unittests/test-utils.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -14,13 +16,14 @@ namespace compiler { ...@@ -14,13 +16,14 @@ namespace compiler {
template <typename T> template <typename T>
class MachineOperatorTestWithParam class MachineOperatorTestWithParam
: public ::testing::TestWithParam< ::testing::tuple<MachineType, T> > { : public TestWithZone,
public ::testing::WithParamInterface< ::testing::tuple<MachineType, T> > {
protected: protected:
MachineType type() const { return ::testing::get<0>(B::GetParam()); } MachineType type() const { return ::testing::get<0>(B::GetParam()); }
const T& GetParam() const { return ::testing::get<1>(B::GetParam()); } const T& GetParam() const { return ::testing::get<1>(B::GetParam()); }
private: private:
typedef ::testing::TestWithParam< ::testing::tuple<MachineType, T> > B; typedef ::testing::WithParamInterface< ::testing::tuple<MachineType, T> > B;
}; };
...@@ -47,14 +50,14 @@ typedef MachineOperatorTestWithParam<LoadRepresentation> ...@@ -47,14 +50,14 @@ typedef MachineOperatorTestWithParam<LoadRepresentation>
TEST_P(MachineLoadOperatorTest, InstancesAreGloballyShared) { TEST_P(MachineLoadOperatorTest, InstancesAreGloballyShared) {
MachineOperatorBuilder machine1(type()); MachineOperatorBuilder machine1(zone(), type());
MachineOperatorBuilder machine2(type()); MachineOperatorBuilder machine2(zone(), type());
EXPECT_EQ(machine1.Load(GetParam()), machine2.Load(GetParam())); EXPECT_EQ(machine1.Load(GetParam()), machine2.Load(GetParam()));
} }
TEST_P(MachineLoadOperatorTest, NumberOfInputsAndOutputs) { TEST_P(MachineLoadOperatorTest, NumberOfInputsAndOutputs) {
MachineOperatorBuilder machine(type()); MachineOperatorBuilder machine(zone(), type());
const Operator* op = machine.Load(GetParam()); const Operator* op = machine.Load(GetParam());
EXPECT_EQ(2, op->ValueInputCount()); EXPECT_EQ(2, op->ValueInputCount());
...@@ -69,13 +72,13 @@ TEST_P(MachineLoadOperatorTest, NumberOfInputsAndOutputs) { ...@@ -69,13 +72,13 @@ TEST_P(MachineLoadOperatorTest, NumberOfInputsAndOutputs) {
TEST_P(MachineLoadOperatorTest, OpcodeIsCorrect) { TEST_P(MachineLoadOperatorTest, OpcodeIsCorrect) {
MachineOperatorBuilder machine(type()); MachineOperatorBuilder machine(zone(), type());
EXPECT_EQ(IrOpcode::kLoad, machine.Load(GetParam())->opcode()); EXPECT_EQ(IrOpcode::kLoad, machine.Load(GetParam())->opcode());
} }
TEST_P(MachineLoadOperatorTest, ParameterIsCorrect) { TEST_P(MachineLoadOperatorTest, ParameterIsCorrect) {
MachineOperatorBuilder machine(type()); MachineOperatorBuilder machine(zone(), type());
EXPECT_EQ(GetParam(), EXPECT_EQ(GetParam(),
OpParameter<LoadRepresentation>(machine.Load(GetParam()))); OpParameter<LoadRepresentation>(machine.Load(GetParam())));
} }
...@@ -105,14 +108,14 @@ class MachineStoreOperatorTest ...@@ -105,14 +108,14 @@ class MachineStoreOperatorTest
TEST_P(MachineStoreOperatorTest, InstancesAreGloballyShared) { TEST_P(MachineStoreOperatorTest, InstancesAreGloballyShared) {
MachineOperatorBuilder machine1(type()); MachineOperatorBuilder machine1(zone(), type());
MachineOperatorBuilder machine2(type()); MachineOperatorBuilder machine2(zone(), type());
EXPECT_EQ(machine1.Store(GetParam()), machine2.Store(GetParam())); EXPECT_EQ(machine1.Store(GetParam()), machine2.Store(GetParam()));
} }
TEST_P(MachineStoreOperatorTest, NumberOfInputsAndOutputs) { TEST_P(MachineStoreOperatorTest, NumberOfInputsAndOutputs) {
MachineOperatorBuilder machine(type()); MachineOperatorBuilder machine(zone(), type());
const Operator* op = machine.Store(GetParam()); const Operator* op = machine.Store(GetParam());
EXPECT_EQ(3, op->ValueInputCount()); EXPECT_EQ(3, op->ValueInputCount());
...@@ -127,13 +130,13 @@ TEST_P(MachineStoreOperatorTest, NumberOfInputsAndOutputs) { ...@@ -127,13 +130,13 @@ TEST_P(MachineStoreOperatorTest, NumberOfInputsAndOutputs) {
TEST_P(MachineStoreOperatorTest, OpcodeIsCorrect) { TEST_P(MachineStoreOperatorTest, OpcodeIsCorrect) {
MachineOperatorBuilder machine(type()); MachineOperatorBuilder machine(zone(), type());
EXPECT_EQ(IrOpcode::kStore, machine.Store(GetParam())->opcode()); EXPECT_EQ(IrOpcode::kStore, machine.Store(GetParam())->opcode());
} }
TEST_P(MachineStoreOperatorTest, ParameterIsCorrect) { TEST_P(MachineStoreOperatorTest, ParameterIsCorrect) {
MachineOperatorBuilder machine(type()); MachineOperatorBuilder machine(zone(), type());
EXPECT_EQ(GetParam(), EXPECT_EQ(GetParam(),
OpParameter<StoreRepresentation>(machine.Store(GetParam()))); OpParameter<StoreRepresentation>(machine.Store(GetParam())));
} }
...@@ -215,14 +218,14 @@ typedef MachineOperatorTestWithParam<PureOperator> MachinePureOperatorTest; ...@@ -215,14 +218,14 @@ typedef MachineOperatorTestWithParam<PureOperator> MachinePureOperatorTest;
TEST_P(MachinePureOperatorTest, InstancesAreGloballyShared) { TEST_P(MachinePureOperatorTest, InstancesAreGloballyShared) {
const PureOperator& pop = GetParam(); const PureOperator& pop = GetParam();
MachineOperatorBuilder machine1(type()); MachineOperatorBuilder machine1(zone(), type());
MachineOperatorBuilder machine2(type()); MachineOperatorBuilder machine2(zone(), type());
EXPECT_EQ((machine1.*pop.constructor)(), (machine2.*pop.constructor)()); EXPECT_EQ((machine1.*pop.constructor)(), (machine2.*pop.constructor)());
} }
TEST_P(MachinePureOperatorTest, NumberOfInputsAndOutputs) { TEST_P(MachinePureOperatorTest, NumberOfInputsAndOutputs) {
MachineOperatorBuilder machine(type()); MachineOperatorBuilder machine(zone(), type());
const PureOperator& pop = GetParam(); const PureOperator& pop = GetParam();
const Operator* op = (machine.*pop.constructor)(); const Operator* op = (machine.*pop.constructor)();
...@@ -239,7 +242,7 @@ TEST_P(MachinePureOperatorTest, NumberOfInputsAndOutputs) { ...@@ -239,7 +242,7 @@ TEST_P(MachinePureOperatorTest, NumberOfInputsAndOutputs) {
TEST_P(MachinePureOperatorTest, MarkedAsPure) { TEST_P(MachinePureOperatorTest, MarkedAsPure) {
MachineOperatorBuilder machine(type()); MachineOperatorBuilder machine(zone(), type());
const PureOperator& pop = GetParam(); const PureOperator& pop = GetParam();
const Operator* op = (machine.*pop.constructor)(); const Operator* op = (machine.*pop.constructor)();
EXPECT_TRUE(op->HasProperty(Operator::kPure)); EXPECT_TRUE(op->HasProperty(Operator::kPure));
...@@ -247,7 +250,7 @@ TEST_P(MachinePureOperatorTest, MarkedAsPure) { ...@@ -247,7 +250,7 @@ TEST_P(MachinePureOperatorTest, MarkedAsPure) {
TEST_P(MachinePureOperatorTest, OpcodeIsCorrect) { TEST_P(MachinePureOperatorTest, OpcodeIsCorrect) {
MachineOperatorBuilder machine(type()); MachineOperatorBuilder machine(zone(), type());
const PureOperator& pop = GetParam(); const PureOperator& pop = GetParam();
const Operator* op = (machine.*pop.constructor)(); const Operator* op = (machine.*pop.constructor)();
EXPECT_EQ(pop.opcode, op->opcode()); EXPECT_EQ(pop.opcode, op->opcode());
...@@ -266,8 +269,15 @@ INSTANTIATE_TEST_CASE_P( ...@@ -266,8 +269,15 @@ INSTANTIATE_TEST_CASE_P(
// Pseudo operators. // Pseudo operators.
TEST(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs32Bit) { namespace {
MachineOperatorBuilder machine(kRepWord32);
typedef TestWithZone MachineOperatorTest;
} // namespace
TEST_F(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs32Bit) {
MachineOperatorBuilder machine(zone(), kRepWord32);
EXPECT_EQ(machine.Word32And(), machine.WordAnd()); EXPECT_EQ(machine.Word32And(), machine.WordAnd());
EXPECT_EQ(machine.Word32Or(), machine.WordOr()); EXPECT_EQ(machine.Word32Or(), machine.WordOr());
EXPECT_EQ(machine.Word32Xor(), machine.WordXor()); EXPECT_EQ(machine.Word32Xor(), machine.WordXor());
...@@ -288,8 +298,8 @@ TEST(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs32Bit) { ...@@ -288,8 +298,8 @@ TEST(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs32Bit) {
} }
TEST(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs64Bit) { TEST_F(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs64Bit) {
MachineOperatorBuilder machine(kRepWord64); MachineOperatorBuilder machine(zone(), kRepWord64);
EXPECT_EQ(machine.Word64And(), machine.WordAnd()); EXPECT_EQ(machine.Word64And(), machine.WordAnd());
EXPECT_EQ(machine.Word64Or(), machine.WordOr()); EXPECT_EQ(machine.Word64Or(), machine.WordOr());
EXPECT_EQ(machine.Word64Xor(), machine.WordXor()); EXPECT_EQ(machine.Word64Xor(), machine.WordXor());
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
'compiler/js-typed-lowering-unittest.cc', 'compiler/js-typed-lowering-unittest.cc',
'compiler/load-elimination-unittest.cc', 'compiler/load-elimination-unittest.cc',
'compiler/machine-operator-reducer-unittest.cc', 'compiler/machine-operator-reducer-unittest.cc',
'compiler/machine-operator-unittest.cc',
'compiler/move-optimizer-unittest.cc', 'compiler/move-optimizer-unittest.cc',
'compiler/node-matchers-unittest.cc', 'compiler/node-matchers-unittest.cc',
'compiler/node-test-utils.cc', 'compiler/node-test-utils.cc',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment