28 const std::shared_ptr<const rvsdg::Type> &
type)
40 Type_(std::move(
type)),
50 Type_(std::move(
type)),
66 if (
origin() == new_origin)
75 auto old_origin =
origin();
76 old_origin->remove_user(
this);
85 if (
auto node = std::get_if<Node *>(&
Owner_))
87 return (*node)->region();
102 if (input ==
nullptr)
105 const auto index = input->
index();
108 if (
auto node = std::get_if<Node *>(&owner))
110 return index + 1 < (*node)->ninputs() ? (*node)->input(index + 1) :
nullptr;
113 if (
auto region = std::get_if<Region *>(&owner))
115 return index + 1 < (*region)->nresults() ? (*region)->result(index + 1) :
nullptr;
147 Type_(std::move(
type))
153 if (
auto node = std::get_if<Node *>(&
Owner_))
155 return (*node)->region();
182 if (
auto node = TryGetOwnerNode<Node>(*
this))
184 node->numSuccessors_ -= 1;
198 if (
auto node = TryGetOwnerNode<Node>(*
this))
204 node->numSuccessors_ += 1;
214 if (output ==
nullptr)
217 const auto index = output->
index();
218 const auto owner = output->
GetOwner();
220 if (
const auto node = std::get_if<Node *>(&owner))
222 return index + 1 < (*node)->noutputs() ? (*node)->output(index + 1) :
nullptr;
225 if (
const auto region = std::get_if<Region *>(&owner))
227 return index + 1 < (*region)->narguments() ? (*region)->argument(index + 1) :
nullptr;
248 std::shared_ptr<const rvsdg::Type>
type)
257 : Id_(region->generateNodeId()),
298 const auto inputPtr =
inputs_.back().get();
313 size_t numLiveInputs = 0;
314 size_t numRemovedInputs = 0;
315 for (
size_t n = 0; n <
ninputs(); n++)
333 if (numLiveInputs == 0)
338 return numRemovedInputs;
347 size_t numLiveOutputs = 0;
348 size_t numRemovedOutputs = 0;
349 for (
size_t n = 0; n <
noutputs(); n++)
365 return numRemovedOutputs;
374 for (
size_t n = 0; n < noperands; n++)
383 if (®ion == output.
region())
391 throw std::logic_error(
"Output is not in an ancestor of region.");
398 [&origin, ®ion](
GammaNode & gammaNode)
400 auto [input, branchArgument] = gammaNode.AddEntryVar(&origin);
401 return branchArgument[region.index()];
405 return thetaNode.AddLoopVar(&origin).pre;
409 return lambdaNode.AddContextVar(origin).inner;
413 return phiNode.AddContextVar(origin).inner;
417 return deltaNode.AddContextVar(origin).inner;
Conditional operator / pattern matching.
Region & GetRootRegion() const noexcept
NodeOutput(Node *node, std::shared_ptr< const rvsdg::Type > type)
Graph * graph() const noexcept
bool IsDead() const noexcept
Determines whether the node is dead.
rvsdg::Region * region() const noexcept
std::vector< std::unique_ptr< NodeInput > > inputs_
std::vector< std::unique_ptr< NodeOutput > > outputs_
size_t RemoveInputs(const util::HashSet< size_t > &indices)
NodeInput * input(size_t index) const noexcept
NodeOutput * output(size_t index) const noexcept
size_t ninputs() const noexcept
size_t noutputs() const noexcept
NodeInput * addInput(std::unique_ptr< NodeInput > input, bool notifyRegion)
size_t RemoveOutputs(const util::HashSet< size_t > &indices)
virtual Node * copy(rvsdg::Region *region, const std::vector< jlm::rvsdg::Output * > &operands) const
Output * ComputeNext() const
Output * ComputeNext() const
void add_user(jlm::rvsdg::Input *user)
rvsdg::Region * region() const noexcept
std::variant< Node *, Region * > GetOwner() const noexcept
virtual ~Output() noexcept
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
virtual std::string debug_string() const
size_t index() const noexcept
void remove_user(jlm::rvsdg::Input *user)
std::variant< Node *, Region * > Owner_
bool IsDead() const noexcept
Output(Node &owner, std::shared_ptr< const rvsdg::Type > type)
A phi node represents the fixpoint of mutually recursive definitions.
Represent acyclic RVSDG subgraphs.
void onNodeRemoved(Node &node)
rvsdg::StructuralNode * node() const noexcept
void onNodeAdded(Node &node)
Adds node to the list of nodes in the region.
Graph * graph() const noexcept
void notifyInputChange(Input *input, Output *old_origin, Output *new_origin)
void onBottomNodeRemoved(Node &node)
void onTopNodeRemoved(Node &node)
void onTopNodeAdded(Node &node)
Adds node to the top nodes of the region.
void notifyInputDestroy(Input *input)
void notifyInputCreate(Input *input)
void onBottomNodeAdded(Node &node)
Adds node to the set of bottom nodes in the region.
void insert(const Output *original, Output *substitute)
bool Contains(const ItemType &item) const noexcept
bool IsEmpty() const noexcept
void erase(ElementType *element) noexcept
void push_back(ElementType *element) noexcept
#define JLM_UNREACHABLE(msg)
void MatchTypeOrFail(T &obj, const Fns &... fns)
Pattern match over subclass type of given object.
static std::string type(const Node *n)
Output & RouteToRegion(Output &output, Region ®ion)
static Input * ComputeNextInput(const Input *input)
static Output * ComputeNextOutput(const Output *output)
static std::vector< jlm::rvsdg::Output * > operands(const Node *node)
static std::string strfmt(Args... args)