Reduct  v4.0.5-1-g4851deb
A functional and immutable language.
Loading...
Searching...
No Matches
RVSDG

Detailed Description

Reduct uses a IR (Intermediate representation) heavily inspired by the RVSDG (Regionalized Value State Dependence Graph).

Nodes, Regions and Edges

A RVSDG representation is made up of nodes, regions and edges. Nodes represent operations (addition, subtraction, branches, functions, etc.), regions represent computations (a sequence of nodes) and edges represent data dependencies between nodes.

Each node can have any number of inputs but will always have exactly one output. Each region can have any number of arguments but will also always have exactly one result.

The output of nodes and the arguments of regions are the origins of edges, while the input or results of a region are the users of edges.

Note
Nodes having one output and regions having one result is a deviation from the paper, however, since Reduct is immutable, we can know that any expression will always produce exactly one output/result. So we can simply things.

Structure

Included is a simple description of how data flows through the RVSDG:

Node Types

A node can either be simple or structural, a simple node represents a primitive operation such as addition or subtraction. Structural nodes contain regions and represent more complex logic such as function calls, loops or conditionals.

There are multiple types of structural node which defines how it passes data to and from the regions it might contain. Included below is a list of all such types.

Note
Since Reduct is immutable and does not have traditional global variables, some node types, for example delta nodes, will not be used. Omega nodes are also replaced with lambda nodes.

Gamma Nodes

A gamma node represents a branch or decision point. The first input to a gamma node is a predicate, which should evaluate to a positive integer representing the index of the region to execute. The remaining inputs are passed as arguments to the corresponding region with that regions outputs mapped to the gamma nodes outputs.

Lambda Nodes

A lambda node represents a function and contains a single region representing a function's body. The inputs are not the arguments to the lambda but instead captured variables. The single output is the function itself, not the result of the function.

Note
The paper describes an "apply" node to represent a function invocation. For simplicity, this is represented as simple REDUCT_OPCODE_CALL or REDUCT_OPCODE_CALL_CONST node.

Phi Nodes

A phi node allows a function to recursively call itself. It contains a single region containing a lambda node, the output of the lambda node should be connected to the result of this region with the arguments of this region connected to the inputs of the lambda node. The phi node itself only takes inputs for captured variables and a outputs the lambda.

Note
The paper describes a phi node as being able to contain multiple lambda nodes for mutual recursion. This will not be needed within Reduct.
See also
https://arxiv.org/abs/1912.05036 "RVSDG: An Intermediate Representation for Optimizing Compilers" (Nico Reissmann et al., 2020)

Data Structures

struct  reduct_rvsdg_origin_t
 Origin of a data dependency edge. More...
 
struct  reduct_rvsdg_user_t
 User of a data dependency edge. More...
 
struct  reduct_rvsdg_edge_t
 Edge structure representing a data dependency. More...
 
struct  reduct_rvsdg_node_info_t
 Information about a node type. More...
 
struct  reduct_rvsdg_node_t
 
struct  reduct_rvsdg_region_t
 

Macros

#define REDUCT_RVSDG_NODE_TYPE_INVALID   0
 Invalid node type.
 
#define REDUCT_RVSDG_NODE_TYPE_SIMPLE_OPCODE   1
 Represents a primitive operation (opcode).
 
#define REDUCT_RVSDG_NODE_TYPE_SIMPLE_CONST   2
 Represents a constant.
 
#define REDUCT_RVSDG_NODE_TYPE_GAMMA   3
 Represents a branch or decision point.
 
#define REDUCT_RVSDG_NODE_TYPE_LAMBDA   4
 Represents a function.
 
#define REDUCT_RVSDG_NODE_TYPE_PHI   5
 Represents a phi node.
 
#define REDUCT_RVSDG_NODE_FLAGS_NONE   0
 No flags.
 
#define REDUCT_RVSDG_NODE_FLAGS_LAMBDA_VARIADIC   (1 << 0)
 Lambda node is variadic.
 

Typedefs

typedef uint8_t reduct_rvsdg_node_type_t
 Node type.
 
typedef uint8_t reduct_rvsdg_node_flags_t
 Node flags.
 

Enumerations

enum  reduct_rvsdg_owner_kind_t { REDUCT_RVSDG_OWNER_NODE , REDUCT_RVSDG_OWNER_REGION }
 Owner of a data dependency origin or user. More...
 

Functions

REDUCT_API const reduct_rvsdg_node_info_treduct_rvsdg_node_get_info (reduct_rvsdg_node_type_t type)
 Get information about a node type.
 
REDUCT_API reduct_rvsdg_edge_treduct_rvsdg_edge_new (struct reduct *reduct)
 Allocate a new IR edge.
 
REDUCT_API void reduct_rvsdg_edge_connect (struct reduct *reduct, reduct_rvsdg_origin_t *origin, reduct_rvsdg_user_t *user)
 Connects an origin to a user via an edge.
 
REDUCT_API void reduct_rvsdg_edge_disconnect (reduct_rvsdg_edge_t *edge)
 Disconnect an edge from its origin and user.
 
REDUCT_API reduct_rvsdg_node_treduct_rvsdg_node_new (struct reduct *reduct)
 Allocate a new IR node.
 
REDUCT_API reduct_rvsdg_node_treduct_rvsdg_node_new_simple_opcode (struct reduct *reduct, reduct_rvsdg_region_t *region, reduct_opcode_t opcode)
 Create a simple opcode node.
 
REDUCT_API reduct_rvsdg_node_treduct_rvsdg_node_new_simple_constant (struct reduct *reduct, reduct_rvsdg_region_t *region, reduct_handle_t constant)
 Create a simple constant node.
 
REDUCT_API reduct_rvsdg_node_treduct_rvsdg_node_new_simple_unary (struct reduct *reduct, reduct_rvsdg_region_t *region, reduct_opcode_t opcode, struct reduct_rvsdg_origin *input)
 Create a simple unary opcode node.
 
REDUCT_API reduct_rvsdg_node_treduct_rvsdg_node_new_simple_binary (struct reduct *reduct, reduct_rvsdg_region_t *region, reduct_opcode_t opcode, struct reduct_rvsdg_origin *left, struct reduct_rvsdg_origin *right)
 Create a simple binary opcode node.
 
REDUCT_API reduct_rvsdg_node_treduct_rvsdg_node_new_simple_ternary (struct reduct *reduct, reduct_rvsdg_region_t *region, reduct_opcode_t opcode, struct reduct_rvsdg_origin *a, struct reduct_rvsdg_origin *b, struct reduct_rvsdg_origin *c)
 Create a simple ternary opcode node.
 
REDUCT_API reduct_rvsdg_node_treduct_rvsdg_node_new_lambda (struct reduct *reduct, reduct_rvsdg_region_t *region)
 Create a lambda node.
 
REDUCT_API reduct_rvsdg_node_treduct_rvsdg_node_new_phi (struct reduct *reduct, reduct_rvsdg_region_t *region)
 Create a phi node.
 
REDUCT_API reduct_rvsdg_node_treduct_rvsdg_node_new_gamma (struct reduct *reduct, reduct_rvsdg_region_t *region, uint8_t regionCount)
 Create a gamma node.
 
REDUCT_API struct reduct_rvsdg_user * reduct_rvsdg_node_get_input (reduct_rvsdg_node_t *node, uint16_t index)
 Get an input port of a node by index.
 
REDUCT_API struct reduct_rvsdg_origin * reduct_rvsdg_node_get_input_origin (reduct_rvsdg_node_t *node, uint16_t index)
 Get the output of the node connected to an input node of a node by index.
 
REDUCT_API struct reduct_rvsdg_node * reduct_rvsdg_node_get_input_node (reduct_rvsdg_node_t *node, uint16_t index)
 Get the node connected to an input node of a node by index.
 
REDUCT_API void reduct_rvsdg_origin_redirect_users (struct reduct_rvsdg_origin *origin, struct reduct_rvsdg_origin *newOrigin)
 Redirect all users of a origin to a new origin.
 
REDUCT_API struct reduct_rvsdg_origin * reduct_rvsdg_region_get_argument (reduct_rvsdg_region_t *region, uint16_t index)
 Get an argument port of a region by index.
 
REDUCT_API bool reduct_rvsdg_region_is_ancestor_or_same (reduct_rvsdg_region_t *region, reduct_rvsdg_region_t *ancestor)
 Check if a region is an ancestor of another, or if they are the same.
 
REDUCT_API void reduct_rvsdg_edge_redirect (reduct_rvsdg_edge_t *edge, reduct_rvsdg_origin_t *newOrigin)
 Redirect an existing edge from its current origin to a new origin.
 
REDUCT_API void reduct_rvsdg_node_phi_wrap_lambda (struct reduct *reduct, reduct_rvsdg_node_t *lambda)
 Wrap a lambda node in a phi node for recursive calls.
 
REDUCT_API bool reduct_rvsdg_node_is_inside_phi (reduct_rvsdg_node_t *node)
 Check if a nodes grandparent is a phi node.
 
REDUCT_API reduct_rvsdg_node_treduct_rvsdg_node_new_call (struct reduct *reduct, reduct_rvsdg_region_t *region, reduct_rvsdg_origin_t *callable)
 Create a CALL opcode node and connect a callable as its first input.
 
REDUCT_API bool reduct_rvsdg_node_map_input_to_argument (reduct_rvsdg_node_t *node, struct reduct_rvsdg_region *region, uint16_t inputIndex, uint16_t *outArgIndex)
 Map a node input index to a region argument index.
 
REDUCT_API bool reduct_rvsdg_node_map_argument_to_input (reduct_rvsdg_node_t *node, struct reduct_rvsdg_region *region, uint16_t argIndex, uint16_t *outInputIndex)
 Map a region argument index to an input index of the parent node.
 
REDUCT_API bool reduct_rvsdg_node_is_recur_origin (reduct_rvsdg_node_t *node, struct reduct_rvsdg_origin *origin)
 Check if an origin is a recursion target for a given phi node.
 
REDUCT_API reduct_rvsdg_region_treduct_rvsdg_region_new (struct reduct *reduct)
 Allocate a new IR region.
 
REDUCT_API reduct_rvsdg_user_treduct_rvsdg_user_new (struct reduct *reduct)
 Allocate a new IR user port.
 
REDUCT_API reduct_rvsdg_origin_treduct_rvsdg_origin_new (struct reduct *reduct)
 Allocate a new IR origin port.
 
REDUCT_API reduct_rvsdg_user_treduct_rvsdg_node_add_input (struct reduct *reduct, reduct_rvsdg_node_t *node)
 Add a new input port to a node.
 
REDUCT_API reduct_rvsdg_region_treduct_rvsdg_node_add_region (struct reduct *reduct, reduct_rvsdg_node_t *node)
 Add a new region to a node.
 
REDUCT_API reduct_rvsdg_origin_treduct_rvsdg_region_add_argument (struct reduct *reduct, reduct_rvsdg_region_t *region)
 Add a new argument port to a region.
 
REDUCT_API void reduct_rvsdg_region_add_node (reduct_rvsdg_region_t *region, reduct_rvsdg_node_t *node)
 Adds a node to a region.
 
REDUCT_API void reduct_rvsdg_region_remove_node (reduct_rvsdg_node_t *node)
 Removes a node from its region.
 
REDUCT_API void reduct_rvsdg_node_delete (struct reduct *reduct, reduct_rvsdg_node_t *node)
 Removes from the region and disconnects from any connections a node and any nodes connected to its input.
 
REDUCT_API bool reduct_rvsdg_node_is_identical (struct reduct *reduct, reduct_rvsdg_node_t *nodeA, reduct_rvsdg_node_t *nodeB)
 Check if two nodes are structurally identical.
 
REDUCT_API reduct_rvsdg_origin_treduct_rvsdg_region_lift_origin (struct reduct *reduct, reduct_rvsdg_region_t *region, reduct_rvsdg_origin_t *outerValue)
 Lift an origin from an outer region to an inner region, creating a new argument in the inner region and connecting it to the outer origin.
 
REDUCT_API struct reduct_rvsdg_node * reduct_rvsdg_node_copy (struct reduct *reduct, reduct_rvsdg_region_t *region, struct reduct_rvsdg_node *node)
 Recursively copy a node.
 

Macro Definition Documentation

◆ REDUCT_RVSDG_NODE_TYPE_INVALID

#define REDUCT_RVSDG_NODE_TYPE_INVALID   0

Invalid node type.

Definition at line 150 of file rvsdg.h.

◆ REDUCT_RVSDG_NODE_TYPE_SIMPLE_OPCODE

#define REDUCT_RVSDG_NODE_TYPE_SIMPLE_OPCODE   1

Represents a primitive operation (opcode).

Definition at line 151 of file rvsdg.h.

◆ REDUCT_RVSDG_NODE_TYPE_SIMPLE_CONST

#define REDUCT_RVSDG_NODE_TYPE_SIMPLE_CONST   2

Represents a constant.

Definition at line 152 of file rvsdg.h.

◆ REDUCT_RVSDG_NODE_TYPE_GAMMA

#define REDUCT_RVSDG_NODE_TYPE_GAMMA   3

Represents a branch or decision point.

Definition at line 153 of file rvsdg.h.

◆ REDUCT_RVSDG_NODE_TYPE_LAMBDA

#define REDUCT_RVSDG_NODE_TYPE_LAMBDA   4

Represents a function.

Definition at line 154 of file rvsdg.h.

◆ REDUCT_RVSDG_NODE_TYPE_PHI

#define REDUCT_RVSDG_NODE_TYPE_PHI   5

Represents a phi node.

Definition at line 155 of file rvsdg.h.

◆ REDUCT_RVSDG_NODE_FLAGS_NONE

#define REDUCT_RVSDG_NODE_FLAGS_NONE   0

No flags.

Definition at line 161 of file rvsdg.h.

◆ REDUCT_RVSDG_NODE_FLAGS_LAMBDA_VARIADIC

#define REDUCT_RVSDG_NODE_FLAGS_LAMBDA_VARIADIC   (1 << 0)

Lambda node is variadic.

Definition at line 162 of file rvsdg.h.

Typedef Documentation

◆ reduct_rvsdg_node_type_t

typedef uint8_t reduct_rvsdg_node_type_t

Node type.

Definition at line 149 of file rvsdg.h.

◆ reduct_rvsdg_node_flags_t

typedef uint8_t reduct_rvsdg_node_flags_t

Node flags.

Definition at line 160 of file rvsdg.h.

Enumeration Type Documentation

◆ reduct_rvsdg_owner_kind_t

Owner of a data dependency origin or user.

Enumerator
REDUCT_RVSDG_OWNER_NODE 
REDUCT_RVSDG_OWNER_REGION 

Definition at line 95 of file rvsdg.h.

Function Documentation

◆ reduct_rvsdg_node_get_info()

REDUCT_API const reduct_rvsdg_node_info_t * reduct_rvsdg_node_get_info ( reduct_rvsdg_node_type_t  type)

Get information about a node type.

Parameters
typeThe node type.
Returns
Pointer to the node info structure.

◆ reduct_rvsdg_edge_new()

REDUCT_API reduct_rvsdg_edge_t * reduct_rvsdg_edge_new ( struct reduct *  reduct)

Allocate a new IR edge.

Parameters
reductPointer to the Reduct structure.
Returns
The newly allocated edge.

◆ reduct_rvsdg_edge_connect()

REDUCT_API void reduct_rvsdg_edge_connect ( struct reduct *  reduct,
reduct_rvsdg_origin_t origin,
reduct_rvsdg_user_t user 
)

Connects an origin to a user via an edge.

Parameters
reductPointer to the Reduct structure.
originPointer to the origin port.
userPointer to the user port.

◆ reduct_rvsdg_edge_disconnect()

REDUCT_API void reduct_rvsdg_edge_disconnect ( reduct_rvsdg_edge_t edge)

Disconnect an edge from its origin and user.

Parameters
edgePointer to the edge to disconnect.

◆ reduct_rvsdg_node_new()

REDUCT_API reduct_rvsdg_node_t * reduct_rvsdg_node_new ( struct reduct *  reduct)

Allocate a new IR node.

Parameters
reductPointer to the Reduct structure.
Returns
The newly allocated node.

◆ reduct_rvsdg_node_new_simple_opcode()

REDUCT_API reduct_rvsdg_node_t * reduct_rvsdg_node_new_simple_opcode ( struct reduct *  reduct,
reduct_rvsdg_region_t region,
reduct_opcode_t  opcode 
)

Create a simple opcode node.

Parameters
reductPointer to the Reduct structure.
regionThe region to add the node to, or NULL.
opcodeThe opcode to use.
Returns
The newly allocated node.

◆ reduct_rvsdg_node_new_simple_constant()

REDUCT_API reduct_rvsdg_node_t * reduct_rvsdg_node_new_simple_constant ( struct reduct *  reduct,
reduct_rvsdg_region_t region,
reduct_handle_t  constant 
)

Create a simple constant node.

Parameters
reductPointer to the Reduct structure.
regionThe region to add the node to, or NULL.
constantThe constant to use.
Returns
The newly allocated node.

◆ reduct_rvsdg_node_new_simple_unary()

REDUCT_API reduct_rvsdg_node_t * reduct_rvsdg_node_new_simple_unary ( struct reduct *  reduct,
reduct_rvsdg_region_t region,
reduct_opcode_t  opcode,
struct reduct_rvsdg_origin *  input 
)

Create a simple unary opcode node.

Parameters
reductPointer to the Reduct structure.
regionThe region to add the node to, or NULL.
opcodeThe opcode to use.
inputThe origin of the input.
Returns
The newly allocated node.

◆ reduct_rvsdg_node_new_simple_binary()

REDUCT_API reduct_rvsdg_node_t * reduct_rvsdg_node_new_simple_binary ( struct reduct *  reduct,
reduct_rvsdg_region_t region,
reduct_opcode_t  opcode,
struct reduct_rvsdg_origin *  left,
struct reduct_rvsdg_origin *  right 
)

Create a simple binary opcode node.

Parameters
reductPointer to the Reduct structure.
regionThe region to add the node to, or NULL.
opcodeThe opcode to use.
leftThe origin of the left input.
rightThe origin of the right input.
Returns
The newly allocated node.

◆ reduct_rvsdg_node_new_simple_ternary()

REDUCT_API reduct_rvsdg_node_t * reduct_rvsdg_node_new_simple_ternary ( struct reduct *  reduct,
reduct_rvsdg_region_t region,
reduct_opcode_t  opcode,
struct reduct_rvsdg_origin *  a,
struct reduct_rvsdg_origin *  b,
struct reduct_rvsdg_origin *  c 
)

Create a simple ternary opcode node.

Parameters
reductPointer to the Reduct structure.
regionThe region to add the node to, or NULL.
opcodeThe opcode to use.
aThe origin of the first input.
bThe origin of the second input.
cThe origin of the third input.
Returns
The newly allocated node.

◆ reduct_rvsdg_node_new_lambda()

REDUCT_API reduct_rvsdg_node_t * reduct_rvsdg_node_new_lambda ( struct reduct *  reduct,
reduct_rvsdg_region_t region 
)

Create a lambda node.

Parameters
reductPointer to the Reduct structure.
regionThe region to add the node to, or NULL.
Returns
The newly allocated node.

◆ reduct_rvsdg_node_new_phi()

REDUCT_API reduct_rvsdg_node_t * reduct_rvsdg_node_new_phi ( struct reduct *  reduct,
reduct_rvsdg_region_t region 
)

Create a phi node.

Parameters
reductPointer to the Reduct structure.
regionThe region to add the node to, or NULL.
Returns
The newly allocated node.

◆ reduct_rvsdg_node_new_gamma()

REDUCT_API reduct_rvsdg_node_t * reduct_rvsdg_node_new_gamma ( struct reduct *  reduct,
reduct_rvsdg_region_t region,
uint8_t  regionCount 
)

Create a gamma node.

Parameters
reductPointer to the Reduct structure.
regionThe region to add the node to, or NULL.
regionCountThe number of regions (branches) to create.
Returns
The newly allocated node.

◆ reduct_rvsdg_node_get_input()

REDUCT_API struct reduct_rvsdg_user * reduct_rvsdg_node_get_input ( reduct_rvsdg_node_t node,
uint16_t  index 
)

Get an input port of a node by index.

Parameters
nodeThe node to search.
indexThe index of the input port.
Returns
The user port, or NULL if not found.

◆ reduct_rvsdg_node_get_input_origin()

REDUCT_API struct reduct_rvsdg_origin * reduct_rvsdg_node_get_input_origin ( reduct_rvsdg_node_t node,
uint16_t  index 
)

Get the output of the node connected to an input node of a node by index.

Parameters
nodeThe node to search.
indexThe index of the input port.
Returns
The origin port, or NULL if not found or not connected.

◆ reduct_rvsdg_node_get_input_node()

REDUCT_API struct reduct_rvsdg_node * reduct_rvsdg_node_get_input_node ( reduct_rvsdg_node_t node,
uint16_t  index 
)

Get the node connected to an input node of a node by index.

Parameters
nodeThe node to search.
indexThe index of the input port.
Returns
The input node, or NULL if not found or the port is not connected to a node.

◆ reduct_rvsdg_origin_redirect_users()

REDUCT_API void reduct_rvsdg_origin_redirect_users ( struct reduct_rvsdg_origin *  origin,
struct reduct_rvsdg_origin *  newOrigin 
)

Redirect all users of a origin to a new origin.

Parameters
originThe current origin.
newOriginThe new origin to redirect users to.

◆ reduct_rvsdg_region_get_argument()

REDUCT_API struct reduct_rvsdg_origin * reduct_rvsdg_region_get_argument ( reduct_rvsdg_region_t region,
uint16_t  index 
)

Get an argument port of a region by index.

Parameters
regionThe region to search.
indexThe index of the argument port.
Returns
The origin port, or NULL if not found.

◆ reduct_rvsdg_region_is_ancestor_or_same()

REDUCT_API bool reduct_rvsdg_region_is_ancestor_or_same ( reduct_rvsdg_region_t region,
reduct_rvsdg_region_t ancestor 
)

Check if a region is an ancestor of another, or if they are the same.

Parameters
regionThe region to start from.
ancestorThe potential ancestor region.
Returns
true if ancestor is an ancestor of (or the same as) region.

◆ reduct_rvsdg_edge_redirect()

REDUCT_API void reduct_rvsdg_edge_redirect ( reduct_rvsdg_edge_t edge,
reduct_rvsdg_origin_t newOrigin 
)

Redirect an existing edge from its current origin to a new origin.

Parameters
edgeThe edge to redirect.
newOriginThe new origin to connect the edge to.

◆ reduct_rvsdg_node_phi_wrap_lambda()

REDUCT_API void reduct_rvsdg_node_phi_wrap_lambda ( struct reduct *  reduct,
reduct_rvsdg_node_t lambda 
)

Wrap a lambda node in a phi node for recursive calls.

Parameters
reductPointer to the Reduct structure.
lambdaThe lambda node to wrap.

◆ reduct_rvsdg_node_is_inside_phi()

REDUCT_API bool reduct_rvsdg_node_is_inside_phi ( reduct_rvsdg_node_t node)

Check if a nodes grandparent is a phi node.

Parameters
nodeThe node to check.
Returns
true if the node is nested inside a phi node's region.

◆ reduct_rvsdg_node_new_call()

REDUCT_API reduct_rvsdg_node_t * reduct_rvsdg_node_new_call ( struct reduct *  reduct,
reduct_rvsdg_region_t region,
reduct_rvsdg_origin_t callable 
)

Create a CALL opcode node and connect a callable as its first input.

Parameters
reductPointer to the Reduct structure.
regionThe region to add the call node to.
callableThe origin representing the function to call.
Returns
The newly created call node.

◆ reduct_rvsdg_node_map_input_to_argument()

REDUCT_API bool reduct_rvsdg_node_map_input_to_argument ( reduct_rvsdg_node_t node,
struct reduct_rvsdg_region *  region,
uint16_t  inputIndex,
uint16_t *  outArgIndex 
)

Map a node input index to a region argument index.

Parameters
nodeThe parent node.
regionThe target region.
inputIndexThe input index on the node.
outArgIndexPointer to store the mapped argument index.
Returns
true if the input is mapped to an argument.

◆ reduct_rvsdg_node_map_argument_to_input()

REDUCT_API bool reduct_rvsdg_node_map_argument_to_input ( reduct_rvsdg_node_t node,
struct reduct_rvsdg_region *  region,
uint16_t  argIndex,
uint16_t *  outInputIndex 
)

Map a region argument index to an input index of the parent node.

Parameters
nodeThe parent node.
regionThe region containing the argument.
argIndexThe argument index within the region.
outInputIndexPointer to store the mapped input index.
Returns
true if the argument is mapped from an input.

◆ reduct_rvsdg_node_is_recur_origin()

REDUCT_API bool reduct_rvsdg_node_is_recur_origin ( reduct_rvsdg_node_t node,
struct reduct_rvsdg_origin *  origin 
)

Check if an origin is a recursion target for a given phi node.

Parameters
nodeThe phi node.
originThe origin to check.
Returns
true if the origin is a recursion target.

◆ reduct_rvsdg_region_new()

REDUCT_API reduct_rvsdg_region_t * reduct_rvsdg_region_new ( struct reduct *  reduct)

Allocate a new IR region.

Parameters
reductPointer to the Reduct structure.
Returns
The newly allocated region.

◆ reduct_rvsdg_user_new()

REDUCT_API reduct_rvsdg_user_t * reduct_rvsdg_user_new ( struct reduct *  reduct)

Allocate a new IR user port.

Parameters
reductPointer to the Reduct structure.
Returns
The newly allocated user port.

◆ reduct_rvsdg_origin_new()

REDUCT_API reduct_rvsdg_origin_t * reduct_rvsdg_origin_new ( struct reduct *  reduct)

Allocate a new IR origin port.

Parameters
reductPointer to the Reduct structure.
Returns
The newly allocated origin port.

◆ reduct_rvsdg_node_add_input()

REDUCT_API reduct_rvsdg_user_t * reduct_rvsdg_node_add_input ( struct reduct *  reduct,
reduct_rvsdg_node_t node 
)

Add a new input port to a node.

Parameters
reductPointer to the Reduct structure.
nodeThe node to add the input to.
Returns
The newly created user port.

◆ reduct_rvsdg_node_add_region()

REDUCT_API reduct_rvsdg_region_t * reduct_rvsdg_node_add_region ( struct reduct *  reduct,
reduct_rvsdg_node_t node 
)

Add a new region to a node.

Parameters
reductPointer to the Reduct structure.
nodeThe node to add the region to.
Returns
The newly created region.

◆ reduct_rvsdg_region_add_argument()

REDUCT_API reduct_rvsdg_origin_t * reduct_rvsdg_region_add_argument ( struct reduct *  reduct,
reduct_rvsdg_region_t region 
)

Add a new argument port to a region.

Parameters
reductPointer to the Reduct structure.
regionThe region to add the argument to.
Returns
The newly created origin port.

◆ reduct_rvsdg_region_add_node()

REDUCT_API void reduct_rvsdg_region_add_node ( reduct_rvsdg_region_t region,
reduct_rvsdg_node_t node 
)

Adds a node to a region.

Parameters
regionPointer to the region to add the node to.
nodePointer to the node to add.

◆ reduct_rvsdg_region_remove_node()

REDUCT_API void reduct_rvsdg_region_remove_node ( reduct_rvsdg_node_t node)

Removes a node from its region.

Parameters
nodePointer to the node to remove.

◆ reduct_rvsdg_node_delete()

REDUCT_API void reduct_rvsdg_node_delete ( struct reduct *  reduct,
reduct_rvsdg_node_t node 
)

Removes from the region and disconnects from any connections a node and any nodes connected to its input.

Parameters
reductPointer to the Reduct structure.
nodePointer to the node to delete.

◆ reduct_rvsdg_node_is_identical()

REDUCT_API bool reduct_rvsdg_node_is_identical ( struct reduct *  reduct,
reduct_rvsdg_node_t nodeA,
reduct_rvsdg_node_t nodeB 
)

Check if two nodes are structurally identical.

Parameters
reductPointer to the Reduct structure.
nodeAFirst node.
nodeBSecond node.
Returns
true if the nodes are identical, false otherwise.

◆ reduct_rvsdg_region_lift_origin()

REDUCT_API reduct_rvsdg_origin_t * reduct_rvsdg_region_lift_origin ( struct reduct *  reduct,
reduct_rvsdg_region_t region,
reduct_rvsdg_origin_t outerValue 
)

Lift an origin from an outer region to an inner region, creating a new argument in the inner region and connecting it to the outer origin.

Parameters
reductPointer to the Reduct structure.
regionThe inner region to lift the origin into.
outerValueThe origin in the outer region to lift.
Returns
The new origin in the inner region representing the lifted value.

◆ reduct_rvsdg_node_copy()

REDUCT_API struct reduct_rvsdg_node * reduct_rvsdg_node_copy ( struct reduct *  reduct,
reduct_rvsdg_region_t region,
struct reduct_rvsdg_node *  node 
)

Recursively copy a node.

Parameters
reductPointer to the Reduct structure.
regionThe region to add the copy to, or NULL.
nodeThe node to copy.
Returns
The newly copied node.