Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1576)

Unified Diff: test/unittests/compiler/machine-operator-unittest.cc

Issue 1513543003: [turbofan] Make MachineType a pair of enums. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Moar rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/unittests/compiler/machine-operator-unittest.cc
diff --git a/test/unittests/compiler/machine-operator-unittest.cc b/test/unittests/compiler/machine-operator-unittest.cc
index f49fbd7b03949ed8ba14b55621874f0ad26e8b6e..c50db98115850b6b82242248f891bfc57d5c1e60 100644
--- a/test/unittests/compiler/machine-operator-unittest.cc
+++ b/test/unittests/compiler/machine-operator-unittest.cc
@@ -17,25 +17,31 @@ namespace compiler {
template <typename T>
class MachineOperatorTestWithParam
: public TestWithZone,
- public ::testing::WithParamInterface< ::testing::tuple<MachineType, T> > {
+ public ::testing::WithParamInterface<
+ ::testing::tuple<MachineRepresentation, T> > {
protected:
- MachineType type() const { return ::testing::get<0>(B::GetParam()); }
+ MachineRepresentation representation() const {
+ return ::testing::get<0>(B::GetParam());
+ }
const T& GetParam() const { return ::testing::get<1>(B::GetParam()); }
private:
- typedef ::testing::WithParamInterface< ::testing::tuple<MachineType, T> > B;
+ typedef ::testing::WithParamInterface<
+ ::testing::tuple<MachineRepresentation, T> > B;
};
namespace {
-const MachineType kMachineReps[] = {kRepWord32, kRepWord64};
+const MachineRepresentation kMachineReps[] = {MachineRepresentation::kWord32,
+ MachineRepresentation::kWord64};
const MachineType kMachineTypesForAccess[] = {
- kMachFloat32, kMachFloat64, kMachInt8, kMachUint8, kMachInt16,
- kMachUint16, kMachInt32, kMachUint32, kMachInt64, kMachUint64,
- kMachPtr, kMachAnyTagged, kMachPtr};
+ MachineType::Float32(), MachineType::Float64(), MachineType::Int8(),
+ MachineType::Uint8(), MachineType::Int16(), MachineType::Uint16(),
+ MachineType::Int32(), MachineType::Uint32(), MachineType::Int64(),
+ MachineType::Uint64(), MachineType::AnyTagged()};
} // namespace
@@ -49,14 +55,14 @@ typedef MachineOperatorTestWithParam<LoadRepresentation>
TEST_P(MachineLoadOperatorTest, InstancesAreGloballyShared) {
- MachineOperatorBuilder machine1(zone(), type());
- MachineOperatorBuilder machine2(zone(), type());
+ MachineOperatorBuilder machine1(zone(), representation());
+ MachineOperatorBuilder machine2(zone(), representation());
EXPECT_EQ(machine1.Load(GetParam()), machine2.Load(GetParam()));
}
TEST_P(MachineLoadOperatorTest, NumberOfInputsAndOutputs) {
- MachineOperatorBuilder machine(zone(), type());
+ MachineOperatorBuilder machine(zone(), representation());
const Operator* op = machine.Load(GetParam());
EXPECT_EQ(2, op->ValueInputCount());
@@ -71,13 +77,13 @@ TEST_P(MachineLoadOperatorTest, NumberOfInputsAndOutputs) {
TEST_P(MachineLoadOperatorTest, OpcodeIsCorrect) {
- MachineOperatorBuilder machine(zone(), type());
+ MachineOperatorBuilder machine(zone(), representation());
EXPECT_EQ(IrOpcode::kLoad, machine.Load(GetParam())->opcode());
}
TEST_P(MachineLoadOperatorTest, ParameterIsCorrect) {
- MachineOperatorBuilder machine(zone(), type());
+ MachineOperatorBuilder machine(zone(), representation());
EXPECT_EQ(GetParam(),
OpParameter<LoadRepresentation>(machine.Load(GetParam())));
}
@@ -108,14 +114,14 @@ class MachineStoreOperatorTest
TEST_P(MachineStoreOperatorTest, InstancesAreGloballyShared) {
- MachineOperatorBuilder machine1(zone(), type());
- MachineOperatorBuilder machine2(zone(), type());
+ MachineOperatorBuilder machine1(zone(), representation());
+ MachineOperatorBuilder machine2(zone(), representation());
EXPECT_EQ(machine1.Store(GetParam()), machine2.Store(GetParam()));
}
TEST_P(MachineStoreOperatorTest, NumberOfInputsAndOutputs) {
- MachineOperatorBuilder machine(zone(), type());
+ MachineOperatorBuilder machine(zone(), representation());
const Operator* op = machine.Store(GetParam());
EXPECT_EQ(3, op->ValueInputCount());
@@ -130,13 +136,13 @@ TEST_P(MachineStoreOperatorTest, NumberOfInputsAndOutputs) {
TEST_P(MachineStoreOperatorTest, OpcodeIsCorrect) {
- MachineOperatorBuilder machine(zone(), type());
+ MachineOperatorBuilder machine(zone(), representation());
EXPECT_EQ(IrOpcode::kStore, machine.Store(GetParam())->opcode());
}
TEST_P(MachineStoreOperatorTest, ParameterIsCorrect) {
- MachineOperatorBuilder machine(zone(), type());
+ MachineOperatorBuilder machine(zone(), representation());
EXPECT_EQ(GetParam(),
OpParameter<StoreRepresentation>(machine.Store(GetParam())));
}
@@ -256,14 +262,16 @@ const PureOperator kPureOperators[] = {
class MachinePureOperatorTest : public TestWithZone {
protected:
- MachineType word_type() { return kMachPtr; }
+ MachineRepresentation word_type() {
+ return MachineType::PointerRepresentation();
+ }
};
TEST_F(MachinePureOperatorTest, PureOperators) {
- TRACED_FOREACH(MachineType, machine_rep1, kMachineReps) {
+ TRACED_FOREACH(MachineRepresentation, machine_rep1, kMachineReps) {
MachineOperatorBuilder machine1(zone(), machine_rep1);
- TRACED_FOREACH(MachineType, machine_rep2, kMachineReps) {
+ TRACED_FOREACH(MachineRepresentation, machine_rep2, kMachineReps) {
MachineOperatorBuilder machine2(zone(), machine_rep2);
TRACED_FOREACH(PureOperator, pop, kPureOperators) {
const Operator* op1 = (machine1.*pop.constructor)();
@@ -317,15 +325,17 @@ const OptionalOperatorEntry kOptionalOperators[] = {
class MachineOptionalOperatorTest : public TestWithZone {
protected:
- MachineType word_type() { return kMachPtr; }
+ MachineRepresentation word_rep() {
+ return MachineType::PointerRepresentation();
+ }
};
TEST_F(MachineOptionalOperatorTest, OptionalOperators) {
TRACED_FOREACH(OptionalOperatorEntry, pop, kOptionalOperators) {
- TRACED_FOREACH(MachineType, machine_rep1, kMachineReps) {
+ TRACED_FOREACH(MachineRepresentation, machine_rep1, kMachineReps) {
MachineOperatorBuilder machine1(zone(), machine_rep1, pop.enabling_flag);
- TRACED_FOREACH(MachineType, machine_rep2, kMachineReps) {
+ TRACED_FOREACH(MachineRepresentation, machine_rep2, kMachineReps) {
MachineOperatorBuilder machine2(zone(), machine_rep2,
pop.enabling_flag);
const Operator* op1 = (machine1.*pop.constructor)().op();
@@ -335,7 +345,7 @@ TEST_F(MachineOptionalOperatorTest, OptionalOperators) {
EXPECT_EQ(pop.control_input_count, op1->ControlInputCount());
EXPECT_EQ(pop.value_output_count, op1->ValueOutputCount());
- MachineOperatorBuilder machine3(zone(), word_type());
+ MachineOperatorBuilder machine3(zone(), word_rep());
EXPECT_TRUE((machine1.*pop.constructor)().IsSupported());
EXPECT_FALSE((machine3.*pop.constructor)().IsSupported());
}
@@ -356,7 +366,7 @@ typedef TestWithZone MachineOperatorTest;
TEST_F(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs32Bit) {
- MachineOperatorBuilder machine(zone(), kRepWord32);
+ MachineOperatorBuilder machine(zone(), MachineRepresentation::kWord32);
EXPECT_EQ(machine.Word32And(), machine.WordAnd());
EXPECT_EQ(machine.Word32Or(), machine.WordOr());
EXPECT_EQ(machine.Word32Xor(), machine.WordXor());
@@ -378,7 +388,7 @@ TEST_F(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs32Bit) {
TEST_F(MachineOperatorTest, PseudoOperatorsWhenWordSizeIs64Bit) {
- MachineOperatorBuilder machine(zone(), kRepWord64);
+ MachineOperatorBuilder machine(zone(), MachineRepresentation::kWord64);
EXPECT_EQ(machine.Word64And(), machine.WordAnd());
EXPECT_EQ(machine.Word64Or(), machine.WordOr());
EXPECT_EQ(machine.Word64Xor(), machine.WordXor());

Powered by Google App Engine
This is Rietveld 408576698