public static void CoalesceLoadsAndDeclarations(NodeGraph graph) { for (int i = 0; i < graph.numBlocks; i++) { NodeBlock block = graph[i]; for (NodeList.iterator iter = block.nodes.begin(); iter.more();) { DNode node = iter.node; if (node.type == NodeType.DeclareLocal) { // Peephole next = store(this, expr) DDeclareLocal local = (DDeclareLocal)node; if (node.next.type == NodeType.Store) { DStore store = (DStore)node.next; if (store.getOperand(0) == local) { local.replaceOperand(0, store.getOperand(1)); store.removeFromUseChains(); iter.next(); block.nodes.remove(iter); continue; } } } iter.next(); } } }
private void writeStore(DStore store) { string lhs = buildLoadStoreRef(store.getOperand(0)); string rhs = buildExpression(store.getOperand(1)); string eq = store.spop == SPOpcode.nop ? "=" : spop(store.spop) + "="; outputLine(lhs + " " + eq + " " + rhs + ";"); }
public override void visit(DStore store) { store.getOperand(0).setUsedAsReference(); }