changeset 5658:297f30d8d610

allowed RegisterNode to directly use a register not used by the register allocator
author Doug Simon <doug.simon@oracle.com>
date Tue, 19 Jun 2012 21:06:49 +0200
parents d71eb56d6bb0
children 73124ee1ee37
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/RegisterNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java
diffstat 3 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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();
--- 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);
     }
 
--- 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);