7 #ifndef JLM_RVSDG_REGION_HPP
8 #define JLM_RVSDG_REGION_HPP
25 class SimpleOperation;
26 class StructuralInput;
28 class StructuralOutput;
29 class SubstitutionMap;
53 std::shared_ptr<const rvsdg::
Type>
type);
65 [[nodiscard]] std::
string
133 std::shared_ptr<const rvsdg::
Type>
type);
145 [[nodiscard]] std::
string
192 std::shared_ptr<const rvsdg::Type>
type);
362 [[nodiscard]]
Graph *
530 prune(
bool recursive);
645 template<
class Operation>
658 template<
class NodeType>
670 [[nodiscard]]
static size_t
697 [[nodiscard]]
static std::string
720 [[nodiscard]]
static std::string
728 size_t indentationDepth,
729 std::stringstream & stream) noexcept;
731 [[nodiscard]]
static std::string
735 char annotationSeparator,
736 char labelValueSeparator);
738 [[nodiscard]]
static std::string
740 const std::vector<util::Annotation> & annotations,
741 char annotationSeparator,
742 char labelValueSeparator);
744 [[nodiscard]]
static std::string
860 const std::vector<size_t> &
872 const std::vector<Node::Id> &
884 const std::vector<Node::Id> &
896 const std::vector<size_t> &
908 const std::vector<size_t> &
928 std::unordered_map<const Node *, size_t>
970 template<
typename NodeType>
977 return dynamic_cast<NodeType *
>(region->node());
1006 template<
typename NodeType>
1013 return dynamic_cast<NodeType *
>(region->node());
1040 template<
typename NodeType>
1044 auto node = TryGetRegionParentNode<NodeType>(input);
1047 throw std::logic_error(std::string(
"expected node of type ") +
typeid(NodeType).name());
1071 template<
typename NodeType>
1075 auto node = TryGetRegionParentNode<NodeType>(output);
1078 throw std::logic_error(std::string(
"expected node of type ") +
typeid(NodeType).name());
Id GetNodeId() const noexcept
rvsdg::Region * region() const noexcept
rvsdg::Region * region() const noexcept
std::vector< size_t > createdInputIndices_
std::vector< size_t > changedInputIndices_
std::vector< Node::Id > destroyedNodes_
void onInputDestroy(Input *input) override
std::vector< Node::Id > createNodes_
~RecordingObserver() noexcept override=default
std::vector< size_t > destroyedInputIndices_
const std::vector< Node::Id > & destroyedNodes() const noexcept
void onInputCreate(Input *input) override
const std::vector< size_t > & createdInputIndices() const noexcept
const std::vector< Node::Id > & createdNodes() const noexcept
void onNodeCreate(Node *node) override
const std::vector< size_t > & changedInputIndices() const noexcept
void onNodeDestroy(Node *node) override
void onInputChange(Input *input, Output *, Output *) override
const std::vector< size_t > & destroyedInputIndices() const noexcept
Represents the argument of a region.
util::IntrusiveListAnchor< RegionArgument > structural_input_anchor_
std::string debug_string() const override
virtual RegionArgument & Copy(Region ®ion, StructuralInput *input) const
StructuralInput * input() const noexcept
~RegionArgument() noexcept override
static RegionArgument & Create(rvsdg::Region ®ion, StructuralInput *input, std::shared_ptr< const rvsdg::Type > type)
Creates region entry argument.
util::IntrusiveListAccessor< RegionArgument, &RegionArgument::structural_input_anchor_ > structural_input_accessor
Proxy object to observe changes to a region.
virtual void onInputChange(Input *input, Output *old_origin, Output *new_origin)=0
virtual ~RegionObserver() noexcept
virtual void onNodeCreate(Node *node)=0
virtual void onNodeDestroy(Node *node)=0
virtual void onInputCreate(Input *input)=0
RegionObserver(const RegionObserver &)=delete
virtual void onInputDestroy(Input *input)=0
RegionObserver & operator=(const RegionObserver &)=delete
RegionObserver(const Region ®ion)
Represents the result of a region.
StructuralOutput * output() const noexcept
StructuralOutput * output_
~RegionResult() noexcept override
util::IntrusiveListAccessor< RegionResult, &RegionResult::structural_output_anchor_ > structural_output_accessor
virtual RegionResult & Copy(rvsdg::Output &origin, StructuralOutput *output) const
util::IntrusiveListAnchor< RegionResult > structural_output_anchor_
std::string debug_string() const override
static RegionResult & Create(rvsdg::Region ®ion, rvsdg::Output &origin, StructuralOutput *output, std::shared_ptr< const rvsdg::Type > type)
Create region exit result.
Represent acyclic RVSDG subgraphs.
RegionResult * result(size_t index) const noexcept
size_t RemoveResults(const util::HashSet< size_t > &indices)
RegionArgument & addArgument(std::unique_ptr< RegionArgument > argument)
util::IteratorRange< NodeIterator > NodeRange
std::vector< RegionResult * >::const_iterator RegionResultConstIterator
void notifyNodeDestroy(Node *node)
RegionArgumentRange Arguments() noexcept
void copy(Region *target, SubstitutionMap &smap) const
Copy a region with substitutions.
Node::Id generateNodeId() noexcept
NodeConstRange Nodes() const noexcept
BottomNodeRange BottomNodes() noexcept
BottomNodeConstRange BottomNodes() const noexcept
util::IteratorRange< BottomNodeConstIterator > BottomNodeConstRange
static std::string ToString(const std::vector< util::Annotation > &annotations, char annotationSeparator, char labelValueSeparator)
util::IteratorRange< RegionArgumentConstIterator > RegionArgumentConstRange
static bool ContainsOperation(const rvsdg::Region ®ion, bool checkSubregions)
size_t numNodes() const noexcept
util::IteratorRange< RegionArgumentIterator > RegionArgumentRange
Node::Id getNextNodeId() const noexcept
region_top_node_list::ConstIterator TopNodeConstIterator
TopNodeConstRange TopNodes() const noexcept
util::IteratorRange< NodeConstIterator > NodeConstRange
util::IteratorRange< TopNodeIterator > TopNodeRange
static std::string ToTree(const rvsdg::Region ®ion, const util::AnnotationMap &annotationMap) noexcept
void onNodeRemoved(Node &node)
rvsdg::StructuralNode * node() const noexcept
void onNodeAdded(Node &node)
Adds node to the list of nodes in the region.
region_top_node_list::Iterator TopNodeIterator
Graph * graph() const noexcept
void notifyInputChange(Input *input, Output *old_origin, Output *new_origin)
util::IteratorRange< BottomNodeIterator > BottomNodeRange
size_t nresults() const noexcept
region_nodes_list::ConstIterator NodeConstIterator
RegionObserver * observers_
region_nodes_list::Iterator NodeIterator
util::IteratorRange< TopNodeConstIterator > TopNodeConstRange
std::vector< RegionResult * > results_
static bool ContainsNodeType(const rvsdg::Region ®ion, bool checkSubregions)
RegionResult & addResult(std::unique_ptr< RegionResult > result)
TopNodeRange TopNodes() noexcept
Id getRegionId() const noexcept
region_bottom_node_list::Iterator BottomNodeIterator
std::vector< RegionArgument * >::const_iterator RegionArgumentConstIterator
void prune(bool recursive)
std::vector< RegionArgument * > arguments_
void onBottomNodeRemoved(Node &node)
size_t index() const noexcept
static std::string GetAnnotationString(const void *key, const util::AnnotationMap &annotationMap, char annotationSeparator, char labelValueSeparator)
RegionArgument * argument(size_t index) const noexcept
void notifyNodeCreate(Node *node)
size_t numTopNodes() const noexcept
util::IteratorRange< RegionResultIterator > RegionResultRange
bool IsRootRegion() const noexcept
static size_t NumRegions(const rvsdg::Region ®ion) noexcept
region_bottom_node_list::ConstIterator BottomNodeConstIterator
void onTopNodeRemoved(Node &node)
std::vector< RegionArgument * >::iterator RegionArgumentIterator
size_t numBottomNodes() const noexcept
size_t RemoveArguments(const util::HashSet< size_t > &indices)
void removeNode(Node *node)
region_top_node_list topNodes_
void onTopNodeAdded(Node &node)
Adds node to the top nodes of the region.
region_bottom_node_list bottomNodes_
std::vector< RegionResult * >::iterator RegionResultIterator
NodeRange Nodes() noexcept
rvsdg::StructuralNode * node_
void notifyInputDestroy(Input *input)
RegionResultConstRange Results() const noexcept
void notifyInputCreate(Input *input)
RegionArgument & insertArgument(size_t index, std::unique_ptr< RegionArgument > argument)
size_t narguments() const noexcept
void onBottomNodeAdded(Node &node)
Adds node to the set of bottom nodes in the region.
util::IteratorRange< RegionResultConstIterator > RegionResultConstRange
RegionResultRange Results() noexcept
RegionArgumentConstRange Arguments() const noexcept
Iterator begin() noexcept
size_t nsimpnodes(const rvsdg::Region *region) noexcept
size_t nstructnodes(const rvsdg::Region *region) noexcept
NodeType & AssertGetRegionParentNode(const rvsdg::Input &input)
Asserts that this is a result of a region inside a node of specified type.
static void remove(Node *node)
std::unordered_map< const Node *, size_t > computeDepthMap(const Region ®ion)
static std::string type(const Node *n)
size_t nnodes(const jlm::rvsdg::Region *region) noexcept
size_t ninputs(const rvsdg::Region *region) noexcept
Region * TryGetOwnerRegion(const rvsdg::Input &input) noexcept
NodeType * TryGetRegionParentNode(const rvsdg::Input &input) noexcept
Checks if this is a result of a region inside a node of specified type.