fun attempt(live: LiveAnalysis, r1: Register, r2: Register): Boolean { if (isLiveAtDef(r2, r1, live)) return false if (isLiveAtDef(r1, r2, live)) return false if (split(r1, r2)) return false if (r1 === r2) return false live.merge(r1, r2) run { val e: Enumeration<RegisterOperand> = DefUse.defs(r2) while (e.hasMoreElements()) { val def: RegisterOperand = e.nextElement() DefUse.removeDef(def) def.setRegister(r1) DefUse.recordDef(def)} } val e: Enumeration<RegisterOperand> = DefUse.uses(r2) while (e.hasMoreElements()) { val use: RegisterOperand = e.nextElement() DefUse.removeUse(use) use.setRegister(r1) DefUse.recordUse(use) } return true}
Attempt to coalesce register r2 into register r1 . If this is legal , < ul > < li > rewrite all defs and uses of r2 as defs and uses of r1 < li > update the liveness information < li > update the def-use chains < /ul > < strong > PRECONDITION < /strong > def-use chains must be computed and valid .