MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / setDef

Method setDef

chapter21/src/main/java/com/seaofnodes/simple/node/Node.java:165–184  ·  view source on GitHub ↗

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, N new_def )

Source from the content-addressed store, hash-verified

163 *
164 * @param new_def the new definition, appended to the end of existing definitions
165 * @return new_def for flow coding
166 */
167 public Node addDef(Node new_def) {
168 unlock();
169 // Add use->def edge
170 _inputs.add(new_def);
171 // If new def is not null, add the corresponding def->use edge
172 if( new_def != null )
173 new_def.addUse(this);
174 return new_def;
175 }
176
177 // Breaks the edge invariants, used temporarily
178 protected <N extends Node> void addUse(N n) { _outputs.add(n); }
179
180 // Remove node 'use' from 'def's (i.e. our) output list, by compressing the list in-place.
181 // Return true if the output list is empty afterward.
182 // Error is 'use' does not exist; ok for 'use' to be null.
183 protected boolean delUse( Node use ) {
184 _outputs.del(_outputs.find(use));
185 moveDepsToWorklist(); // User-count and anti-dependence queries can now change.
186 return _outputs.isEmpty();
187 }

Callers 15

parseBitwiseMethod · 0.95
parseShiftMethod · 0.95
parseAdditionMethod · 0.95
splitEmptyMaskByUseMethod · 0.95
setDefXMethod · 0.95
insertDefMethod · 0.95
setDefOrderedMethod · 0.95
widenMethod · 0.95
endLoopMethod · 0.95
parseFunctionBodyMethod · 0.45
parseComparisonMethod · 0.45

Calls 8

unlockMethod · 0.95
inMethod · 0.95
delUseMethod · 0.95
killMethod · 0.95
moveDepsToWorklistMethod · 0.95
addUseMethod · 0.45
setMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected