32 std::shared_ptr<const rvsdg::Type> type)
39 throw util::Error(
"Argument cannot be added to input.");
66 std::shared_ptr<const rvsdg::Type> type)
81 std::shared_ptr<const rvsdg::Type> type)
82 :
Input(*region, *origin, std::
move(type)),
88 throw util::Error(
"Result cannot be added to output.");
116 std::shared_ptr<const rvsdg::Type> type)
150 id_(graph->generateRegionId()),
161 : graph_(node->graph()),
162 id_(node->graph()->generateRegionId()),
163 depth_(node->region()->getDepth() + 1),
182 throw util::Error(
"Appending argument to wrong region.");
193 throw util::Error(
"Inserting argument to wrong region.");
196 throw util::Error(
"Inserting argument after end of region.");
270 throw util::Error(
"Appending result to wrong region.");
338 for (
size_t n = 0;
n <
snode->nsubregions();
n++)
459 for (
auto & node : region.Nodes())
494 std::stringstream
stream{};
502 std::stringstream
stream{};
512 std::stringstream &
stream)
noexcept
524 return a.Label() < b.Label();
540 for (
auto & node : region.Nodes())
554 stream <<
"\"StructuralNodes\":[";
573 std::stringstream &
stream)
noexcept
587 return a.Label() < b.Label();
606 stream <<
"\"Subregions\":[";
671 std::stringstream &
stream)
noexcept
680 region.IsRootRegion() ?
"RootRegion" :
util::strfmt(
"Region[", region.index(),
"]");
689 for (
auto & node : region.Nodes())
787std::unordered_map<const Node *, size_t>
790 std::unordered_map<const Node *, size_t>
depthMap;
794 for (
auto & input : node->Inputs())
810 size_t n = region->numNodes();
811 for (
const auto & node : region->Nodes())
815 for (
size_t r = 0;
r <
snode->nsubregions();
r++)
827 for (
const auto & node : region->Nodes())
831 for (
size_t r = 0;
r <
snode->nsubregions();
r++)
844 for (
const auto & node : region->Nodes())
848 for (
size_t r = 0;
r <
snode->nsubregions();
r++)
863 size_t n = region->nresults();
864 for (
const auto & node : region->Nodes())
868 for (
size_t r = 0;
r <
snode->nsubregions();
r++)
Region & GetRootRegion() const noexcept
bool IsDead() const noexcept
Determines whether the node is dead.
rvsdg::Region * region() const noexcept
size_t ninputs() const noexcept
virtual Node * copy(rvsdg::Region *region, const std::vector< jlm::rvsdg::Output * > &operands) const
rvsdg::Region * region() const noexcept
size_t index() const noexcept
bool IsDead() const noexcept
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
Represents the argument of a region.
RegionArgument(rvsdg::Region *region, StructuralInput *input, std::shared_ptr< const rvsdg::Type > type)
std::string debug_string() const override
virtual RegionArgument & Copy(Region ®ion, StructuralInput *input) const
~RegionArgument() noexcept override
static RegionArgument & Create(rvsdg::Region ®ion, StructuralInput *input, std::shared_ptr< const rvsdg::Type > type)
Creates region entry argument.
StructuralInput * input() const noexcept
Proxy object to observe changes to a region.
virtual ~RegionObserver() noexcept
RegionObserver(const Region ®ion)
Represents the result of a region.
RegionResult(rvsdg::Region *region, rvsdg::Output *origin, StructuralOutput *output, std::shared_ptr< const rvsdg::Type > type)
StructuralOutput * output() const noexcept
~RegionResult() noexcept override
virtual RegionResult & Copy(rvsdg::Output &origin, StructuralOutput *output) const
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.
size_t RemoveResults(const util::HashSet< size_t > &indices)
RegionArgument * argument(size_t index) const noexcept
RegionArgument & addArgument(std::unique_ptr< RegionArgument > argument)
void notifyNodeDestroy(Node *node)
void copy(Region *target, SubstitutionMap &smap) const
Copy a region with substitutions.
Graph * graph() const noexcept
static std::string ToString(const std::vector< util::Annotation > &annotations, char annotationSeparator, char labelValueSeparator)
size_t numNodes() const noexcept
static std::string toJson(const Region ®ion, const util::AnnotationMap &annotationMap) noexcept
static std::string ToTree(const rvsdg::Region ®ion, const util::AnnotationMap &annotationMap) noexcept
void onNodeRemoved(Node &node)
void onNodeAdded(Node &node)
Adds node to the list of nodes in the region.
void notifyInputChange(Input *input, Output *old_origin, Output *new_origin)
size_t nresults() const noexcept
RegionObserver * observers_
std::vector< RegionResult * > results_
RegionResult & addResult(std::unique_ptr< RegionResult > result)
void prune(bool recursive)
RegionResult * result(size_t index) const noexcept
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)
void notifyNodeCreate(Node *node)
size_t numTopNodes() const noexcept
bool IsRootRegion() const noexcept
static size_t NumRegions(const rvsdg::Region ®ion) noexcept
void onTopNodeRemoved(Node &node)
rvsdg::StructuralNode * node() const noexcept
size_t numBottomNodes() const noexcept
size_t RemoveArguments(const util::HashSet< size_t > &indices)
void removeNode(Node *node)
static bool isAncestor(const rvsdg::Region ®ion, const rvsdg::Region &ancestor) noexcept
region_top_node_list topNodes_
void onTopNodeAdded(Node &node)
Adds node to the top nodes of the region.
region_bottom_node_list bottomNodes_
NodeRange Nodes() noexcept
void notifyInputDestroy(Input *input)
void notifyInputCreate(Input *input)
RegionArgument & insertArgument(size_t index, std::unique_ptr< RegionArgument > argument)
static std::string toJsonKeyValue(const util::Annotation &annotation) noexcept
size_t narguments() const noexcept
void onBottomNodeAdded(Node &node)
Adds node to the set of bottom nodes in the region.
StructuralNode * node() const noexcept
static FilePath createUniqueFileName(const FilePath &directory, const std::string &fileNamePrefix, const std::string &fileNameSuffix)
Generates a unique file in a given directory with a prefix and suffix.
static FilePath TempDirectoryPath()
bool insert(ItemType item)
bool Contains(const ItemType &item) const noexcept
bool IsEmpty() const noexcept
ElementType * first() const noexcept
void erase(ElementType *element) noexcept
void push_back(ElementType *element) noexcept
#define JLM_UNREACHABLE(msg)
size_t nsimpnodes(const rvsdg::Region *region) noexcept
size_t nstructnodes(const rvsdg::Region *region) noexcept
std::unordered_map< const Node *, size_t > computeDepthMap(const Region ®ion)
detail::TopDownTraverserGeneric< true > TopDownConstTraverser
Traverser for visiting every node in a const region in a top down order.
size_t nnodes(const jlm::rvsdg::Region *region) noexcept
size_t ninputs(const rvsdg::Region *region) noexcept
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
std::string getDotViewer()
static std::string strfmt(Args... args)
int executeProgramAndWait(const std::string &programName, const std::vector< std::string > &programArguments)