Commit f6a4a7d0 authored by Michael Beck's avatar Michael Beck
Browse files

- implemented firm_clear_node_and_phi_links()

- fixed comments: collect_phiprojs() and part_block() use phi lists

[r23896]
parent 1eaf5821
......@@ -45,8 +45,8 @@ void exchange(ir_node *old, ir_node *nw);
*/
void turn_into_tuple(ir_node *node, int arity);
/** Walks over the passed ir graph and collects all Phi nodes as a
* list built with the link field in their corresponding block.
/** Walks over the passed IR graph and collects all Phi nodes as a
* list in their corresponding block (using get_Block_phis() API).
* Further it collects all Proj nodes in a list of the node producing
* the tuple. In case of nested tuples the Projs are collected in the
* node producing the outermost Tuple.
......@@ -61,9 +61,9 @@ void collect_phiprojs(ir_graph *irg);
* (old_block) of node. Moves node and its predecessors from old_block to
* new_block. Moves all Projs that depend on moved nodes and are in old_block
* to new_block. Moves all Phi nodes from old_block to new_block. To achieve
* this the routine assumes that all Phi nodes are in a list (using the link
* field) in the link field of old_block. Further it assumes that all Proj nodes
* are accessible by the link field of the nodes producing the Tuple. This
* this the routine assumes that all Phi nodes are in the Phi list (see get_Block_phis())
* of old_block. Further it assumes that all Proj nodes are accessible by the link field
* of the nodes producing the Tuple. This
* can be established by collect_phiprojs(). part_block conserves this property.
* Adds a Jmp node to new_block that jumps to old_block.
* Assumes that node is contained in current_ir_graph. Sets current_block in
......
......@@ -39,6 +39,16 @@ void firm_clear_link(ir_node *n, void *env) {
set_irn_link(n, NULL);
}
/* the famous clear_node_and_phi_links() implementation. */
void firm_clear_node_and_phi_links(ir_node *n, void *env) {
(void) env;
set_irn_link(n, NULL);
if (is_Block(n))
set_Block_phis(n, NULL);
else if (is_Phi(n))
set_Phi_next(n, NULL);
}
/*
* Copies a node to a new irg. The Ins of the new node point to
* the predecessors on the old irg. n->link points to the new node.
......
......@@ -68,10 +68,19 @@ void firm_pset_dump(pset *set);
/**
* The famous clear_link() walker-function.
* Do not implement it by yourself, use this one
* Sets all links fields of visited nodes to NULL.
* Do not implement it by yourself, use this one.
*/
void firm_clear_link(ir_node *n, void *env);
/**
* The famous clear_link_and_block_lists() walker-function.
* Sets all links fields of visited nodes to NULL.
* Additionally, clear all Phi-lists of visited blocks.
* Do not implement it by yourself, use this one
*/
void firm_clear_node_and_phi_links(ir_node *n, void *env);
/**
* Copies a node to a new irg. The Ins of the new node point to
* the predecessors on the old irg. n->link points to the new node.
......
......@@ -150,23 +150,10 @@ static void collect_phiprojs_walker(ir_node *n, void *env) {
}
}
/**
* clear all links, including the Phi list of blocks and Phi nodes.
*/
static void clear_node_and_phis_links(ir_node *n, void *env) {
(void) env;
set_irn_link(n, NULL);
if (is_Block(n))
set_Block_phis(n, NULL);
else if (is_Phi(n))
set_Phi_next(n, NULL);
}
void collect_phiprojs(ir_graph *irg) {
assert((ir_resources_reserved(irg) & (IR_RESOURCE_IRN_LINK|IR_RESOURCE_PHI_LIST)) ==
(IR_RESOURCE_IRN_LINK|IR_RESOURCE_PHI_LIST));
irg_walk_graph(irg, clear_node_and_phis_links, collect_phiprojs_walker, NULL);
irg_walk_graph(irg, firm_clear_node_and_phi_links, collect_phiprojs_walker, NULL);
}
/*--------------------------------------------------------------------*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment