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

Method addDef

chapter03/src/main/java/com/seaofnodes/simple/node/Node.java:170–177  ·  view source on GitHub ↗

Add a new def to an existing Node. Keep the edges correct by adding the corresponding def->use edge. @param new_def the new definition, appended to the end of existing definitions @return new_def for flow coding

(Node new_def)

Source from the content-addressed store, hash-verified

168 * Try to peephole at this node and return a better replacement Node if
169 * possible. We compute a {@link Type} and then check and replace:
170 * <ul>
171 * <li>if the Type {@link Type#isConstant}, we replace with a {@link ConstantNode}</li>
172 * <li>in a future chapter we will look for a
173 * <a href="https://en.wikipedia.org/wiki/Common_subexpression_elimination">Common Subexpression</a>
174 * to eliminate.</li>
175 * <li>we ask the Node for a better replacement (again, none enabled in this chapter)</li>
176 * </ul>
177 */
178 public final Node peephole() {
179 var obs = Parser.PARSER == null ? null : Parser.PARSER._obs;
180 if( obs != null ) obs.before(this);

Callers 1

defineMethod · 0.45

Calls 2

addMethod · 0.45
addUseMethod · 0.45

Tested by

no test coverage detected