# HG changeset patch # User Doug Simon # Date 1340132809 -7200 # Node ID 297f30d8d6105d1797d5a165759f27d8426764bc # Parent d71eb56d6bb039a66cf482afc3d12d9a46949ebd allowed RegisterNode to directly use a register not used by the register allocator diff -r d71eb56d6bb0 -r 297f30d8d610 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Tue Jun 19 20:03:06 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Tue Jun 19 21:06:49 2012 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.compiler.gen; import static com.oracle.graal.api.code.CallingConvention.Type.*; +import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.api.meta.Value.*; import static com.oracle.graal.lir.LIRValueUtil.*; @@ -206,9 +207,15 @@ } @Override + public RegisterAttributes attributes(Register register) { + return frameMap.registerConfig.getAttributesMap()[register.number]; + } + + @Override public Value setResult(ValueNode x, Value operand) { - assert (isVariable(operand) && x.kind() == operand.kind) || (isConstant(operand) && x.kind() == operand.kind.stackKind()) : operand.kind + " for node " + x; - + assert (isVariable(operand) && x.kind() == operand.kind) || + (isRegister(operand) && !attributes(asRegister(operand)).isAllocatable()) || + (isConstant(operand) && x.kind() == operand.kind.stackKind()) : operand.kind + " for node " + x; assert operand(x) == null : "operand cannot be set twice"; assert operand != null && isLegal(operand) : "operand must be legal"; assert operand.kind.stackKind() == x.kind(); diff -r d71eb56d6bb0 -r 297f30d8d610 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/RegisterNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/RegisterNode.java Tue Jun 19 20:03:06 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/RegisterNode.java Tue Jun 19 21:06:49 2012 +0200 @@ -44,8 +44,15 @@ @Override public void generate(LIRGeneratorTool generator) { - Value result = generator.newVariable(kind()); - generator.emitMove(register.asValue(kind()), result); + Value result; + if (generator.attributes(register).isAllocatable()) { + // The register allocator would prefer us not to tie up an allocatable + // register for the complete lifetime of this node. + result = generator.newVariable(kind()); + generator.emitMove(register.asValue(kind()), result); + } else { + result = register.asValue(kind()); + } generator.setResult(this, result); } diff -r d71eb56d6bb0 -r 297f30d8d610 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Tue Jun 19 20:03:06 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Tue Jun 19 21:06:49 2012 +0200 @@ -48,6 +48,8 @@ */ public abstract boolean canStoreConstant(Constant c); + public abstract RegisterAttributes attributes(Register register); + public abstract Value operand(ValueNode object); public abstract Value newVariable(Kind kind); public abstract Value setResult(ValueNode x, Value operand);