Jlm
structural-node.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016 Nico Reißmann <nico.reissmann@gmail.com>
3  * See COPYING for terms of redistribution.
4  */
5 
6 #include <jlm/rvsdg/graph.hpp>
9 
10 namespace jlm::rvsdg
11 {
12 
13 /* structural input */
14 
16 {
18 }
19 
21  rvsdg::StructuralNode * node,
22  jlm::rvsdg::Output * origin,
23  std::shared_ptr<const rvsdg::Type> type)
24  : NodeInput(origin, node, std::move(type))
25 {}
26 
27 /* structural output */
28 
30 {
32 }
33 
34 StructuralOutput::StructuralOutput(StructuralNode * node, std::shared_ptr<const rvsdg::Type> type)
35  : NodeOutput(node, std::move(type))
36 {}
37 
38 /* structural node */
39 
41 {
42  region()->notifyNodeDestroy(this);
43 
44  subregions_.clear();
45 }
46 
47 StructuralNode::StructuralNode(rvsdg::Region * region, size_t nsubregions)
48  : Node(region)
49 {
50  if (nsubregions == 0)
51  throw util::Error("Number of subregions must be greater than zero.");
52 
53  for (size_t n = 0; n < nsubregions; n++)
54  subregions_.emplace_back(std::unique_ptr<rvsdg::Region>(new jlm::rvsdg::Region(this, n)));
55 
56  region->notifyNodeCreate(this);
57 }
58 
59 std::string
61 {
62  return GetOperation().debug_string();
63 }
64 
65 }
virtual const Operation & GetOperation() const noexcept=0
rvsdg::Region * region() const noexcept
Definition: node.hpp:761
virtual std::string debug_string() const =0
Represent acyclic RVSDG subgraphs.
Definition: region.hpp:213
void notifyNodeDestroy(Node *node)
Definition: region.cpp:417
void notifyNodeCreate(Node *node)
Definition: region.cpp:408
~StructuralInput() noexcept override
StructuralInput(StructuralNode *node, jlm::rvsdg::Output *origin, std::shared_ptr< const rvsdg::Type > type)
std::string DebugString() const override
~StructuralNode() noexcept override
std::vector< std::unique_ptr< rvsdg::Region > > subregions_
StructuralNode(rvsdg::Region *region, size_t nsubregions)
size_t nsubregions() const noexcept
~StructuralOutput() noexcept override
StructuralOutput(StructuralNode *node, std::shared_ptr< const rvsdg::Type > type)
bool empty() const noexcept
#define JLM_ASSERT(x)
Definition: common.hpp:16
static std::string type(const Node *n)
Definition: view.cpp:255