7 #include <gtest/gtest.h>
17 for (
const auto & node : region->
Nodes())
26 TEST(GraphTests, test_recursive_prune)
39 auto input0 = n3->addInputWithArguments(imp);
40 auto & a1 = *n3->addArguments(t).argument[0];
43 auto o1 = n3->addOutputWithResults({ n4->output(0) });
62 TEST(GraphTests, test_empty_graph_pruning)
75 TEST(GraphTests, test_prune_replace)
91 n2->output(0)->divert_users(n4->output(0));
92 EXPECT_EQ(n2->output(0)->nusers(), 0u);
112 auto newGraph = graph.
Copy();
115 EXPECT_EQ(newGraph->GetRootRegion().narguments(), 1u);
116 auto copiedArgument = newGraph->GetRootRegion().argument(0);
117 EXPECT_TRUE(is<jlm::rvsdg::GraphImport>(copiedArgument));
119 EXPECT_EQ(newGraph->GetRootRegion().numNodes(), 1u);
120 auto copiedNode = newGraph->GetRootRegion().Nodes().begin().ptr();
121 EXPECT_EQ(copiedNode->ninputs() == 1 && copiedNode->noutputs(), 1);
122 EXPECT_EQ(copiedNode->input(0)->origin(), copiedArgument);
124 EXPECT_EQ(newGraph->GetRootRegion().nresults(), 1u);
125 auto copiedResult = newGraph->GetRootRegion().result(0);
126 EXPECT_TRUE(is<jlm::rvsdg::GraphExport>(*copiedResult));
127 EXPECT_EQ(copiedResult->origin(), copiedNode->output(0));
static bool region_contains_node(const jlm::rvsdg::Region *region, const jlm::rvsdg::Node *n)
TEST(GraphTests, test_recursive_prune)
static GraphExport & Create(Output &origin, std::string name)
static GraphImport & Create(Graph &graph, std::shared_ptr< const rvsdg::Type > type, std::string name)
std::unique_ptr< Graph > Copy() const
Region & GetRootRegion() const noexcept
Represent acyclic RVSDG subgraphs.
size_t numNodes() const noexcept
NodeRange Nodes() noexcept
static SimpleNode * createNode(Region *region, const std::vector< Output * > &operands, std::vector< std::shared_ptr< const Type >> resultTypes)
static TestStructuralNode * create(Region *parent, const size_t numSubregions)
static std::shared_ptr< const TestType > createValueType()
std::string view(const rvsdg::Region *region)