Skip to content

Commit

Permalink
add GetNode method to output (symmetric to input) (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
caleridas authored Oct 1, 2024
1 parent 99fe50b commit 8e11f8c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions jlm/rvsdg/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ output::debug_string() const
return jlm::util::strfmt(index());
}

rvsdg::node *
output::GetNode(const rvsdg::output & output) noexcept
{
auto nodeOutput = dynamic_cast<const rvsdg::node_output *>(&output);
return nodeOutput ? nodeOutput->node() : nullptr;
}

void
output::remove_user(jlm::rvsdg::input * user)
{
Expand Down
11 changes: 11 additions & 0 deletions jlm/rvsdg/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,17 @@ class output
virtual std::string
debug_string() const;

/**
* Retrieve the associated node from \p output if \p output is derived from
* jlm::rvsdg::node_output.
*
* @param output The output from which to retrieve the node.
* @return The node associated with \p output if output is derived from jlm::rvsdg::node_output,
* otherwise nullptr.
*/
[[nodiscard]] static rvsdg::node *
GetNode(const rvsdg::output & output) noexcept;

template<class T>
class iterator
{
Expand Down

0 comments on commit 8e11f8c

Please sign in to comment.