Jlm
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Friends | List of all members
jlm::rvsdg::PhiNode Class Referencefinal

A phi node represents the fixpoint of mutually recursive definitions. More...

#include <Phi.hpp>

Inheritance diagram for jlm::rvsdg::PhiNode:
Inheritance graph
[legend]
Collaboration diagram for jlm::rvsdg::PhiNode:
Collaboration graph
[legend]

Classes

struct  ContextVar
 Bound context variable. More...
 
struct  FixVar
 Description of a recursively defined variable. More...
 

Public Member Functions

 ~PhiNode () override
 
const PhiOperationGetOperation () const noexcept override
 
ContextVar AddContextVar (jlm::rvsdg::Output &origin)
 Adds a context variable to the phi node. More...
 
void RemoveContextVars (std::vector< ContextVar > vars)
 Removes context variables from phi node. More...
 
std::vector< ContextVarGetContextVars () const noexcept
 Gets all bound context variables. More...
 
ContextVar MapInputContextVar (const rvsdg::Input &input) const noexcept
 Maps input to context variable. More...
 
std::optional< ContextVarMapArgumentContextVar (const rvsdg::Output &argument) const noexcept
 Attempts to map bound variable reference to context variable. More...
 
void RemoveFixVars (std::vector< FixVar > vars)
 Removes fixpoint variables from the phi node. More...
 
std::vector< FixVarGetFixVars () const noexcept
 Gets all fixpoint variables. More...
 
std::optional< FixVarMapArgumentFixVar (const rvsdg::Output &argument) const noexcept
 Tries to map region argument to fixpoint variable. More...
 
FixVar MapResultFixVar (const rvsdg::Input &result) const noexcept
 Maps region result to fixpoint variable. More...
 
FixVar MapOutputFixVar (const rvsdg::Output &output) const noexcept
 Maps output to fixpoint variable. More...
 
std::variant< FixVar, ContextVarMapArgument (const rvsdg::Output &argument) const noexcept
 Maps region argument to its function. More...
 
rvsdg::Regionsubregion () const noexcept
 
PhiNodecopy (rvsdg::Region *region, rvsdg::SubstitutionMap &smap) const override
 Copy a node with substitutions. More...
 
- Public Member Functions inherited from jlm::rvsdg::StructuralNode
 ~StructuralNode () noexcept override
 
std::string DebugString () const override
 
size_t nsubregions () const noexcept
 
rvsdg::Regionsubregion (size_t index) const noexcept
 
SubregionIteratorRange Subregions ()
 
SubregionConstIteratorRange Subregions () const
 
StructuralInputinput (size_t index) const noexcept
 
StructuralOutputoutput (size_t index) const noexcept
 
- Public Member Functions inherited from jlm::rvsdg::Node
virtual ~Node ()
 
 Node (Region *region)
 
Id GetNodeId () const noexcept
 
size_t ninputs () const noexcept
 
NodeInputinput (size_t index) const noexcept
 
InputIteratorRange Inputs () noexcept
 
InputConstIteratorRange Inputs () const noexcept
 
size_t noutputs () const noexcept
 
NodeOutputoutput (size_t index) const noexcept
 
OutputIteratorRange Outputs () noexcept
 
OutputConstIteratorRange Outputs () const noexcept
 
bool IsDead () const noexcept
 Determines whether the node is dead. More...
 
std::size_t numSuccessors () const noexcept
 
size_t RemoveInputs (const util::HashSet< size_t > &indices)
 
size_t RemoveOutputs (const util::HashSet< size_t > &indices)
 
Graphgraph () const noexcept
 
rvsdg::Regionregion () const noexcept
 
virtual Nodecopy (rvsdg::Region *region, const std::vector< jlm::rvsdg::Output * > &operands) const
 

Static Public Member Functions

static std::vector< rvsdg::LambdaNode * > ExtractLambdaNodes (const PhiNode &phiNode)
 

Private Member Functions

 PhiNode (rvsdg::Region *parent)
 

Static Private Member Functions

static PhiNodecreate (rvsdg::Region *parent)
 

Friends

class PhiBuilder
 

Additional Inherited Members

- Public Types inherited from jlm::rvsdg::Node
using Id = uint64_t
 
using InputIteratorRange = util::IteratorRange< Input::Iterator >
 
using InputConstIteratorRange = util::IteratorRange< Input::ConstIterator >
 
using OutputIteratorRange = util::IteratorRange< Output::Iterator >
 
using OutputConstIteratorRange = util::IteratorRange< Output::ConstIterator >
 
typedef util::IntrusiveListAccessor< Node, &Node::region_node_list_anchor_region_node_list_accessor
 
typedef util::IntrusiveListAccessor< Node, &Node::region_top_node_list_anchor_region_top_node_list_accessor
 
typedef util::IntrusiveListAccessor< Node, &Node::region_bottom_node_list_anchor_region_bottom_node_list_accessor
 
- Protected Member Functions inherited from jlm::rvsdg::StructuralNode
 StructuralNode (rvsdg::Region *region, size_t nsubregions)
 
StructuralInputaddInput (std::unique_ptr< StructuralInput > input, bool notifyRegion)
 
StructuralOutputaddOutput (std::unique_ptr< StructuralOutput > input)
 
- Protected Member Functions inherited from jlm::rvsdg::Node
NodeInputaddInput (std::unique_ptr< NodeInput > input, bool notifyRegion)
 
NodeOutputaddOutput (std::unique_ptr< NodeOutput > output)
 

Detailed Description

A phi node represents the fixpoint of mutually recursive definitions.

A phi node may contain multiple definitions of objects that mutually reference each other. It represents the fixpoint of infinitely unrolling the definitions.

A phi node may reference external definitions as ContextVars, and it may both define and reference several mutually recursive objects as FixVars.

Definition at line 45 of file Phi.hpp.

Constructor & Destructor Documentation

◆ ~PhiNode()

jlm::rvsdg::PhiNode::~PhiNode ( )
overridedefault

◆ PhiNode()

jlm::rvsdg::PhiNode::PhiNode ( rvsdg::Region parent)
inlineexplicitprivate

Definition at line 53 of file Phi.hpp.

Member Function Documentation

◆ AddContextVar()

PhiNode::ContextVar jlm::rvsdg::PhiNode::AddContextVar ( jlm::rvsdg::Output origin)

Adds a context variable to the phi node.

Parameters
originThe value to be bound into the phi node.
Precondition
origin must be from the same region as the phi node.
Returns
The context variable argument of the phi abstraction.

Binds a new variable as context variable into the phi node. Its value can now be referenced from within the phi region.

Definition at line 40 of file Phi.cpp.

◆ copy()

PhiNode * jlm::rvsdg::PhiNode::copy ( rvsdg::Region region,
rvsdg::SubstitutionMap smap 
) const
overridevirtual

Copy a node with substitutions.

Parameters
regionTarget region to create node in
smapOperand substitutions
Returns
Copied node

Create a new node that is semantically equivalent to an existing node. The newly created node will use the same operands as the existing node unless there is a substitution registered for a particular operand.

The given substitution map is updated so that all outputs of the original node will be substituted by corresponding outputs of the newly created node in subsequent copy operations.

Implements jlm::rvsdg::Node.

Definition at line 191 of file Phi.cpp.

◆ create()

static PhiNode* jlm::rvsdg::PhiNode::create ( rvsdg::Region parent)
inlinestaticprivate

Definition at line 58 of file Phi.hpp.

◆ ExtractLambdaNodes()

std::vector< rvsdg::LambdaNode * > jlm::rvsdg::PhiNode::ExtractLambdaNodes ( const PhiNode phiNode)
static

Extracts all lambda nodes from a phi node.

The function is capable of handling nested phi nodes.

Parameters
phiNodeThe phi node from which the lambda nodes should be extracted.
Returns
A vector of lambda nodes.

Definition at line 226 of file Phi.cpp.

◆ GetContextVars()

std::vector< PhiNode::ContextVar > jlm::rvsdg::PhiNode::GetContextVars ( ) const
noexcept

Gets all bound context variables.

Returns
The context variable descriptions.

Returns all context variable descriptions.

Definition at line 50 of file Phi.cpp.

◆ GetFixVars()

std::vector< PhiNode::FixVar > jlm::rvsdg::PhiNode::GetFixVars ( ) const
noexcept

Gets all fixpoint variables.

Returns
The fixpoint variable descriptions.

Returns all fixpoint variable descriptions.

Definition at line 63 of file Phi.cpp.

◆ GetOperation()

const PhiOperation & jlm::rvsdg::PhiNode::GetOperation ( ) const
overridevirtualnoexcept

Implements jlm::rvsdg::Node.

Definition at line 32 of file Phi.cpp.

◆ MapArgument()

std::variant< PhiNode::FixVar, PhiNode::ContextVar > jlm::rvsdg::PhiNode::MapArgument ( const rvsdg::Output argument) const
noexcept

Maps region argument to its function.

Parameters
argumentThe argument of the phi node to be mapped.
Returns
Either the fixpoint variable description or the context variable description, depending on the designation of the argument.
Precondition
argument must be an argument of the region within this phi node.

Maps output of the phi node to either a fixpoint or context variable.

Definition at line 132 of file Phi.cpp.

◆ MapArgumentContextVar()

std::optional< PhiNode::ContextVar > jlm::rvsdg::PhiNode::MapArgumentContextVar ( const rvsdg::Output argument) const
noexcept

Attempts to map bound variable reference to context variable.

Parameters
argumentRegion argument to phi subregion.
Returns
The context variable description corresponding to argument, or std::nullopt.
Precondition
argument must be an argument to the subregion of this node.

Checks whether the given argument corresponds to a context variable and returns its description in that case. All arguments of a phi region are either context or fixpoint variables, see MapArgumentFixVar.

Definition at line 117 of file Phi.cpp.

◆ MapArgumentFixVar()

std::optional< PhiNode::FixVar > jlm::rvsdg::PhiNode::MapArgumentFixVar ( const rvsdg::Output argument) const
noexcept

Tries to map region argument to fixpoint variable.

Parameters
argumentThe argument of the region to be mapped.
Returns
Fixpoint variable description corresponding to argument, or std::nullopt.
Precondition
argument must be an argument of the subregion contained in the phi node.

Checks whether the given argument corresponds to a fixpoint variable and returns its description in that case. All arguments of a phi region are either context or fixpoint variables, see MapArgumentContextVar.

Definition at line 76 of file Phi.cpp.

◆ MapInputContextVar()

PhiNode::ContextVar jlm::rvsdg::PhiNode::MapInputContextVar ( const rvsdg::Input input) const
noexcept

Maps input to context variable.

Parameters
inputInput to the phi node.
Returns
The context variable description corresponding to the input.
Precondition
input must be input to this node.

Returns the context variable description corresponding to this input of the phi node. All inputs to the phi node are by definition bound context variables that are accessible in the subregion through the corresponding argument.

Definition at line 109 of file Phi.cpp.

◆ MapOutputFixVar()

PhiNode::FixVar jlm::rvsdg::PhiNode::MapOutputFixVar ( const rvsdg::Output output) const
noexcept

Maps output to fixpoint variable.

Parameters
outputThe output of the phi node to be mapped.
Returns
Fixpoint variable description corresponding to output.
Precondition
output must be an output of this phi node.

Maps output of the phi node to a fixpoint variable.

Definition at line 100 of file Phi.cpp.

◆ MapResultFixVar()

PhiNode::FixVar jlm::rvsdg::PhiNode::MapResultFixVar ( const rvsdg::Input result) const
noexcept

Maps region result to fixpoint variable.

Parameters
resultThe result of the region to be mapped.
Returns
Fixpoint variable description corresponding to input.
Precondition
result must be a result of the subregion contained in the phi node.

Maps result of the region to a fixpoint variable.

Definition at line 91 of file Phi.cpp.

◆ RemoveContextVars()

void jlm::rvsdg::PhiNode::RemoveContextVars ( std::vector< ContextVar vars)

Removes context variables from phi node.

Parameters
varsVariables to be removed.
Precondition
vars must be context variables of the phi node and they must be unused within the region.

Removes the given context variables.

Definition at line 150 of file Phi.cpp.

◆ RemoveFixVars()

void jlm::rvsdg::PhiNode::RemoveFixVars ( std::vector< FixVar vars)

Removes fixpoint variables from the phi node.

Parameters
varsVariables to be removed.
Precondition
vars must be fixpoint variables of the phi node, and they must be identity mappings within the phi region.

Removes the given fixpoint variables

Definition at line 168 of file Phi.cpp.

◆ subregion()

rvsdg::Region* jlm::rvsdg::PhiNode::subregion ( ) const
inlinenoexcept

Definition at line 320 of file Phi.hpp.

Friends And Related Function Documentation

◆ PhiBuilder

friend class PhiBuilder
friend

Definition at line 47 of file Phi.hpp.


The documentation for this class was generated from the following files: