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 )
| 145 | * @return new_def for flow coding |
| 146 | */ |
| 147 | Node setDef(int idx, Node new_def ) { |
| 148 | Node old_def = in(idx); |
| 149 | if( old_def == new_def ) return this; // No change |
| 150 | // If new def is not null, add the corresponding def->use edge |
| 151 | // This needs to happen before removing the old node's def->use edge as |
| 152 | // the new_def might get killed if the old node kills it recursively. |
| 153 | if( new_def != null ) |
| 154 | new_def.addUse(this); |
| 155 | if( old_def != null && // If the old def exists, remove a def->use edge |
| 156 | old_def.delUse(this) ) // If we removed the last use, the old def is now dead |
| 157 | old_def.kill(); // Kill old def |
| 158 | // Set the new_def over the old (killed) edge |
| 159 | _inputs.set(idx,new_def); |
| 160 | // Return self for easy flow-coding |
| 161 | return new_def; |
| 162 | } |
| 163 | |
| 164 | // Remove the numbered input, compressing the inputs in-place. This |
| 165 | // shuffles the order deterministically - which is suitable for Region and |