Change a def into a Node. Keeps the edges correct, by removing the corresponding use->def edge. This may make the original def go dead. This function is co-recursive with #kill. This method is the normal path for altering a Node, because it does the proper d
(int idx, Node new_def )
| 135 | * @return new_def for flow coding |
| 136 | */ |
| 137 | Node setDef(int idx, Node new_def ) { |
| 138 | Node old_def = in(idx); |
| 139 | if( old_def == new_def ) return this; // No change |
| 140 | // If new def is not null, add the corresponding def->use edge |
| 141 | // This needs to happen before removing the old node's def->use edge as |
| 142 | // the new_def might get killed if the old node kills it recursively. |
| 143 | if( new_def != null ) |
| 144 | new_def.addUse(this); |
| 145 | if( old_def != null && // If the old def exists, remove a def->use edge |
| 146 | old_def.delUse(this) ) // If we removed the last use, the old def is now dead |
| 147 | old_def.kill(); // Kill old def |
| 148 | // Set the new_def over the old (killed) edge |
| 149 | _inputs.set(idx,new_def); |
| 150 | // Return self for easy flow-coding |
| 151 | return new_def; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Add a new def to an existing Node. Keep the edges correct by |