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

Unified Diff: test/unittests/compiler/common-operator-reducer-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/common-operator-reducer-unittest.cc
diff --git a/test/unittests/compiler/common-operator-reducer-unittest.cc b/test/unittests/compiler/common-operator-reducer-unittest.cc
index 5aff78cf07c079caa952625379aedee653627f9d..1c163706f2183eda9b1f10adfad808c659b3add8 100644
--- a/test/unittests/compiler/common-operator-reducer-unittest.cc
+++ b/test/unittests/compiler/common-operator-reducer-unittest.cc
@@ -28,7 +28,8 @@ class CommonOperatorReducerTest : public GraphTest {
Reduction Reduce(
AdvancedReducer::Editor* editor, Node* node,
MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags) {
- MachineOperatorBuilder machine(zone(), kMachPtr, flags);
+ MachineOperatorBuilder machine(zone(), MachineType::PointerRepresentation(),
+ flags);
CommonOperatorReducer reducer(editor, graph(), common(), &machine);
return reducer.Reduce(node);
}
@@ -54,11 +55,11 @@ const BranchHint kBranchHints[] = {BranchHint::kNone, BranchHint::kFalse,
BranchHint::kTrue};
-const MachineType kMachineTypes[] = {
- kMachFloat32, kMachFloat64, kMachInt8, kMachUint8, kMachInt16,
- kMachUint16, kMachInt32, kMachUint32, kMachInt64, kMachUint64,
- kMachPtr, kMachAnyTagged, kRepBit, kRepWord8, kRepWord16,
- kRepWord32, kRepWord64, kRepFloat32, kRepFloat64, kRepTagged};
+const MachineRepresentation kMachineRepresentations[] = {
+ MachineRepresentation::kBit, MachineRepresentation::kWord8,
+ MachineRepresentation::kWord16, MachineRepresentation::kWord32,
+ MachineRepresentation::kWord64, MachineRepresentation::kFloat32,
+ MachineRepresentation::kFloat64, MachineRepresentation::kTagged};
const Operator kOp0(0, Operator::kNoProperties, "Op0", 0, 0, 0, 1, 1, 0);
@@ -279,7 +280,7 @@ TEST_F(CommonOperatorReducerTest, PhiWithMerge) {
Node* const input = graph()->NewNode(&kOp0);
TRACED_FORRANGE(int, input_count, 2, kMaxInputs - 1) {
int const value_input_count = input_count - 1;
- TRACED_FOREACH(MachineType, type, kMachineTypes) {
+ TRACED_FOREACH(MachineRepresentation, rep, kMachineRepresentations) {
for (int i = 0; i < value_input_count; ++i) {
inputs[i] = graph()->start();
}
@@ -292,7 +293,7 @@ TEST_F(CommonOperatorReducerTest, PhiWithMerge) {
StrictMock<MockAdvancedReducerEditor> editor;
EXPECT_CALL(editor, Revisit(merge));
Reduction r = Reduce(
- &editor, graph()->NewNode(common()->Phi(type, value_input_count),
+ &editor, graph()->NewNode(common()->Phi(rep, value_input_count),
input_count, inputs));
ASSERT_TRUE(r.Changed());
EXPECT_EQ(input, r.replacement());
@@ -306,8 +307,8 @@ TEST_F(CommonOperatorReducerTest, PhiWithLoop) {
Node* const loop =
graph()->NewNode(common()->Loop(2), graph()->start(), graph()->start());
loop->ReplaceInput(1, loop);
- Node* const phi =
- graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop);
+ Node* const phi = graph()->NewNode(
+ common()->Phi(MachineRepresentation::kTagged, 2), p0, p0, loop);
phi->ReplaceInput(1, phi);
StrictMock<MockAdvancedReducerEditor> editor;
EXPECT_CALL(editor, Revisit(loop));
@@ -327,8 +328,8 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat32Abs) {
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
Node* vfalse = graph()->NewNode(machine()->Float32Sub(), c0, p0);
Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
- Node* phi =
- graph()->NewNode(common()->Phi(kMachFloat32, 2), vtrue, vfalse, merge);
+ Node* phi = graph()->NewNode(
+ common()->Phi(MachineRepresentation::kFloat32, 2), vtrue, vfalse, merge);
StrictMock<MockAdvancedReducerEditor> editor;
EXPECT_CALL(editor, Revisit(merge));
Reduction r = Reduce(&editor, phi);
@@ -347,8 +348,8 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat64Abs) {
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
Node* vfalse = graph()->NewNode(machine()->Float64Sub(), c0, p0);
Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
- Node* phi =
- graph()->NewNode(common()->Phi(kMachFloat64, 2), vtrue, vfalse, merge);
+ Node* phi = graph()->NewNode(
+ common()->Phi(MachineRepresentation::kFloat64, 2), vtrue, vfalse, merge);
StrictMock<MockAdvancedReducerEditor> editor;
EXPECT_CALL(editor, Revisit(merge));
Reduction r = Reduce(&editor, phi);
@@ -365,7 +366,8 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat32Max) {
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
- Node* phi = graph()->NewNode(common()->Phi(kMachFloat32, 2), p1, p0, merge);
+ Node* phi = graph()->NewNode(
+ common()->Phi(MachineRepresentation::kFloat32, 2), p1, p0, merge);
StrictMock<MockAdvancedReducerEditor> editor;
EXPECT_CALL(editor, Revisit(merge));
Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat32Max);
@@ -382,7 +384,8 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat64Max) {
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
- Node* phi = graph()->NewNode(common()->Phi(kMachFloat64, 2), p1, p0, merge);
+ Node* phi = graph()->NewNode(
+ common()->Phi(MachineRepresentation::kFloat64, 2), p1, p0, merge);
StrictMock<MockAdvancedReducerEditor> editor;
EXPECT_CALL(editor, Revisit(merge));
Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat64Max);
@@ -399,7 +402,8 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat32Min) {
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
- Node* phi = graph()->NewNode(common()->Phi(kMachFloat32, 2), p0, p1, merge);
+ Node* phi = graph()->NewNode(
+ common()->Phi(MachineRepresentation::kFloat32, 2), p0, p1, merge);
StrictMock<MockAdvancedReducerEditor> editor;
EXPECT_CALL(editor, Revisit(merge));
Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat32Min);
@@ -416,7 +420,8 @@ TEST_F(CommonOperatorReducerTest, PhiToFloat64Min) {
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
- Node* phi = graph()->NewNode(common()->Phi(kMachFloat64, 2), p0, p1, merge);
+ Node* phi = graph()->NewNode(
+ common()->Phi(MachineRepresentation::kFloat64, 2), p0, p1, merge);
StrictMock<MockAdvancedReducerEditor> editor;
EXPECT_CALL(editor, Revisit(merge));
Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat64Min);
@@ -440,8 +445,8 @@ TEST_F(CommonOperatorReducerTest, ReturnWithPhiAndEffectPhiAndMerge) {
Node* vfalse = Parameter(1);
Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge);
- Node* phi =
- graph()->NewNode(common()->Phi(kMachAnyTagged, 2), vtrue, vfalse, merge);
+ Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
+ vtrue, vfalse, merge);
Node* ret = graph()->NewNode(common()->Return(), phi, ephi, merge);
graph()->SetEnd(graph()->NewNode(common()->End(1), ret));
StrictMock<MockAdvancedReducerEditor> editor;
@@ -461,9 +466,9 @@ TEST_F(CommonOperatorReducerTest, ReturnWithPhiAndEffectPhiAndMerge) {
TEST_F(CommonOperatorReducerTest, SelectWithSameThenAndElse) {
Node* const input = graph()->NewNode(&kOp0);
TRACED_FOREACH(BranchHint, hint, kBranchHints) {
- TRACED_FOREACH(MachineType, type, kMachineTypes) {
+ TRACED_FOREACH(MachineRepresentation, rep, kMachineRepresentations) {
Reduction r = Reduce(
- graph()->NewNode(common()->Select(type, hint), input, input, input));
+ graph()->NewNode(common()->Select(rep, hint), input, input, input));
ASSERT_TRUE(r.Changed());
EXPECT_EQ(input, r.replacement());
}
@@ -474,8 +479,9 @@ TEST_F(CommonOperatorReducerTest, SelectWithSameThenAndElse) {
TEST_F(CommonOperatorReducerTest, SelectWithInt32ZeroConstant) {
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
- Node* select = graph()->NewNode(common()->Select(kMachAnyTagged),
- Int32Constant(0), p0, p1);
+ Node* select =
+ graph()->NewNode(common()->Select(MachineRepresentation::kTagged),
+ Int32Constant(0), p0, p1);
Reduction r = Reduce(select);
ASSERT_TRUE(r.Changed());
EXPECT_EQ(p1, r.replacement());
@@ -485,8 +491,9 @@ TEST_F(CommonOperatorReducerTest, SelectWithInt32ZeroConstant) {
TEST_F(CommonOperatorReducerTest, SelectWithInt32OneConstant) {
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
- Node* select = graph()->NewNode(common()->Select(kMachAnyTagged),
- Int32Constant(1), p0, p1);
+ Node* select =
+ graph()->NewNode(common()->Select(MachineRepresentation::kTagged),
+ Int32Constant(1), p0, p1);
Reduction r = Reduce(select);
ASSERT_TRUE(r.Changed());
EXPECT_EQ(p0, r.replacement());
@@ -496,8 +503,9 @@ TEST_F(CommonOperatorReducerTest, SelectWithInt32OneConstant) {
TEST_F(CommonOperatorReducerTest, SelectWithInt64ZeroConstant) {
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
- Node* select = graph()->NewNode(common()->Select(kMachAnyTagged),
- Int64Constant(0), p0, p1);
+ Node* select =
+ graph()->NewNode(common()->Select(MachineRepresentation::kTagged),
+ Int64Constant(0), p0, p1);
Reduction r = Reduce(select);
ASSERT_TRUE(r.Changed());
EXPECT_EQ(p1, r.replacement());
@@ -507,8 +515,9 @@ TEST_F(CommonOperatorReducerTest, SelectWithInt64ZeroConstant) {
TEST_F(CommonOperatorReducerTest, SelectWithInt64OneConstant) {
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
- Node* select = graph()->NewNode(common()->Select(kMachAnyTagged),
- Int64Constant(1), p0, p1);
+ Node* select =
+ graph()->NewNode(common()->Select(MachineRepresentation::kTagged),
+ Int64Constant(1), p0, p1);
Reduction r = Reduce(select);
ASSERT_TRUE(r.Changed());
EXPECT_EQ(p0, r.replacement());
@@ -518,8 +527,9 @@ TEST_F(CommonOperatorReducerTest, SelectWithInt64OneConstant) {
TEST_F(CommonOperatorReducerTest, SelectWithFalseConstant) {
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
- Node* select = graph()->NewNode(common()->Select(kMachAnyTagged),
- FalseConstant(), p0, p1);
+ Node* select =
+ graph()->NewNode(common()->Select(MachineRepresentation::kTagged),
+ FalseConstant(), p0, p1);
Reduction r = Reduce(select);
ASSERT_TRUE(r.Changed());
EXPECT_EQ(p1, r.replacement());
@@ -529,8 +539,8 @@ TEST_F(CommonOperatorReducerTest, SelectWithFalseConstant) {
TEST_F(CommonOperatorReducerTest, SelectWithTrueConstant) {
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
- Node* select = graph()->NewNode(common()->Select(kMachAnyTagged),
- TrueConstant(), p0, p1);
+ Node* select = graph()->NewNode(
+ common()->Select(MachineRepresentation::kTagged), TrueConstant(), p0, p1);
Reduction r = Reduce(select);
ASSERT_TRUE(r.Changed());
EXPECT_EQ(p0, r.replacement());
@@ -542,8 +552,8 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat32Abs) {
Node* c0 = Float32Constant(0.0);
Node* check = graph()->NewNode(machine()->Float32LessThan(), c0, p0);
Node* select =
- graph()->NewNode(common()->Select(kMachFloat32), check, p0,
- graph()->NewNode(machine()->Float32Sub(), c0, p0));
+ graph()->NewNode(common()->Select(MachineRepresentation::kFloat32), check,
+ p0, graph()->NewNode(machine()->Float32Sub(), c0, p0));
Reduction r = Reduce(select);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat32Abs(p0));
@@ -555,8 +565,8 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat64Abs) {
Node* c0 = Float64Constant(0.0);
Node* check = graph()->NewNode(machine()->Float64LessThan(), c0, p0);
Node* select =
- graph()->NewNode(common()->Select(kMachFloat64), check, p0,
- graph()->NewNode(machine()->Float64Sub(), c0, p0));
+ graph()->NewNode(common()->Select(MachineRepresentation::kFloat64), check,
+ p0, graph()->NewNode(machine()->Float64Sub(), c0, p0));
Reduction r = Reduce(select);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat64Abs(p0));
@@ -567,8 +577,8 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat32Max) {
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
Node* check = graph()->NewNode(machine()->Float32LessThan(), p0, p1);
- Node* select =
- graph()->NewNode(common()->Select(kMachFloat32), check, p1, p0);
+ Node* select = graph()->NewNode(
+ common()->Select(MachineRepresentation::kFloat32), check, p1, p0);
Reduction r = Reduce(select, MachineOperatorBuilder::kFloat32Max);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat32Max(p1, p0));
@@ -579,8 +589,8 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat64Max) {
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
Node* check = graph()->NewNode(machine()->Float64LessThan(), p0, p1);
- Node* select =
- graph()->NewNode(common()->Select(kMachFloat64), check, p1, p0);
+ Node* select = graph()->NewNode(
+ common()->Select(MachineRepresentation::kFloat64), check, p1, p0);
Reduction r = Reduce(select, MachineOperatorBuilder::kFloat64Max);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat64Max(p1, p0));
@@ -591,8 +601,8 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat32Min) {
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
Node* check = graph()->NewNode(machine()->Float32LessThan(), p0, p1);
- Node* select =
- graph()->NewNode(common()->Select(kMachFloat32), check, p0, p1);
+ Node* select = graph()->NewNode(
+ common()->Select(MachineRepresentation::kFloat32), check, p0, p1);
Reduction r = Reduce(select, MachineOperatorBuilder::kFloat32Min);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat32Min(p0, p1));
@@ -603,8 +613,8 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat64Min) {
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
Node* check = graph()->NewNode(machine()->Float64LessThan(), p0, p1);
- Node* select =
- graph()->NewNode(common()->Select(kMachFloat64), check, p0, p1);
+ Node* select = graph()->NewNode(
+ common()->Select(MachineRepresentation::kFloat64), check, p0, p1);
Reduction r = Reduce(select, MachineOperatorBuilder::kFloat64Min);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat64Min(p0, p1));
« no previous file with comments | « test/unittests/compiler/change-lowering-unittest.cc ('k') | test/unittests/compiler/common-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698