chromium/v8/test/unittests/compiler/graph-reducer-unittest.cc

// Copyright 2014 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 "test/unittests/compiler/graph-reducer-unittest.h"
#include "src/codegen/tick-counter.h"
#include "src/compiler/common-operator.h"
#include "src/compiler/graph.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/node.h"
#include "src/compiler/operator.h"
#include "test/unittests/test-utils.h"

_;
DefaultValue;
ElementsAre;
Return;
Sequence;
StrictMock;
UnorderedElementsAre;

namespace v8 {
namespace internal {
namespace compiler {
namespace graph_reducer_unittest {

namespace {

struct TestOperator : public Operator {};


const uint8_t kOpcodeA0 =;
const uint8_t kOpcodeA1 =;
const uint8_t kOpcodeA2 =;
const uint8_t kOpcodeB0 =;
const uint8_t kOpcodeB1 =;
const uint8_t kOpcodeB2 =;
const uint8_t kOpcodeC0 =;
const uint8_t kOpcodeC1 =;
const uint8_t kOpcodeC2 =;

static TestOperator kOpA0(kOpcodeA0, Operator::kNoWrite, "opa1", 0, 1);
static TestOperator kOpA1(kOpcodeA1, Operator::kNoProperties, "opa2", 1, 1);
static TestOperator kOpA2(kOpcodeA2, Operator::kNoProperties, "opa3", 2, 1);
static TestOperator kOpB0(kOpcodeB0, Operator::kNoWrite, "opb0", 0, 1);
static TestOperator kOpB1(kOpcodeB1, Operator::kNoWrite, "opb1", 1, 1);
static TestOperator kOpB2(kOpcodeB2, Operator::kNoWrite, "opb2", 2, 1);
static TestOperator kOpC0(kOpcodeC0, Operator::kNoWrite, "opc0", 0, 1);
static TestOperator kOpC1(kOpcodeC1, Operator::kNoWrite, "opc1", 1, 1);
static TestOperator kOpC2(kOpcodeC2, Operator::kNoWrite, "opc2", 2, 1);

struct MockReducer : public Reducer {};


// Replaces all "A" operators with "B" operators without creating new nodes.
class InPlaceABReducer final : public Reducer {};


// Replaces all "A" operators with "B" operators by allocating new nodes.
class NewABReducer final : public Reducer {};


// Wraps all "kOpA0" nodes in "kOpB1" operators by allocating new nodes.
class A0Wrapper final : public Reducer {};


// Wraps all "kOpB0" nodes in two "kOpC1" operators by allocating new nodes.
class B0Wrapper final : public Reducer {};


// Replaces all "kOpA1" nodes with the first input.
class A1Forwarder final : public Reducer {};


// Replaces all "kOpB1" nodes with the first input.
class B1Forwarder final : public Reducer {};


// Replaces all "B" operators with "C" operators without creating new nodes.
class InPlaceBCReducer final : public Reducer {};


// Swaps the inputs to "kOp2A" and "kOp2B" nodes based on ids.
class AB2Sorter final : public Reducer {};

}  // namespace


class AdvancedReducerTest : public TestWithZone {};


TEST_F(AdvancedReducerTest, Replace) {}


TEST_F(AdvancedReducerTest, Revisit) {}


namespace {

struct ReplaceWithValueReducer final : public AdvancedReducer {};

const Operator kMockOperator(IrOpcode::kDead, Operator::kNoProperties,
                             "MockOperator", 0, 0, 0, 1, 0, 0);
const Operator kMockOpEffect(IrOpcode::kDead, Operator::kNoProperties,
                             "MockOpEffect", 0, 1, 0, 1, 1, 0);
const Operator kMockOpControl(IrOpcode::kDead, Operator::kNoProperties,
                              "MockOpControl", 0, 0, 1, 1, 0, 1);

}  // namespace


TEST_F(AdvancedReducerTest, ReplaceWithValue_ValueUse) {}


TEST_F(AdvancedReducerTest, ReplaceWithValue_EffectUse) {}


TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse1) {}


TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse2) {}


TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse3) {}


class GraphReducerTest : public TestWithZone {};


TEST_F(GraphReducerTest, NodeIsDeadAfterReplace) {}


TEST_F(GraphReducerTest, ReduceOnceForEveryReducer) {}


TEST_F(GraphReducerTest, ReduceAgainAfterChanged) {}


TEST_F(GraphReducerTest, ReduceGraphFromEnd1) {}


TEST_F(GraphReducerTest, ReduceGraphFromEnd2) {}


TEST_F(GraphReducerTest, ReduceInPlace1) {}


TEST_F(GraphReducerTest, ReduceInPlace2) {}


TEST_F(GraphReducerTest, ReduceNew1) {}


TEST_F(GraphReducerTest, Wrapping1) {}


TEST_F(GraphReducerTest, Wrapping2) {}


TEST_F(GraphReducerTest, Forwarding1) {}


TEST_F(GraphReducerTest, Forwarding2) {}


TEST_F(GraphReducerTest, Forwarding3) {}


TEST_F(GraphReducerTest, ReduceForward1) {}


TEST_F(GraphReducerTest, Sorter1) {}


namespace {

// Generate a node graph with the given permutations.
void GenDAG(Graph* graph, int* p3, int* p2, int* p1) {}

}  // namespace


TEST_F(GraphReducerTest, SortForwardReduce) {}


TEST_F(GraphReducerTest, Order) {}

}  // namespace graph_reducer_unittest
}  // namespace compiler
}  // namespace internal
}  // namespace v8