changeset 21197:50a21b1fe8b7

StackSlotAllocation: add support for hints.
author Josef Eisl <josef.eisl@jku.at>
date Mon, 27 Apr 2015 11:21:09 +0200
parents 00bbd2badfd3
children d2bae7605fe4
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/PhiResolver.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/FixPointIntervalBuilder.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/StackInterval.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java
diffstat 3 files changed, 40 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/FixPointIntervalBuilder.java	Wed Apr 29 09:28:58 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/FixPointIntervalBuilder.java	Mon Apr 27 11:21:09 2015 +0200
@@ -189,6 +189,7 @@
                 if (isVirtualStackSlot(operand)) {
                     VirtualStackSlot vslot = asVirtualStackSlot(operand);
                     addUse(vslot, inst, flags);
+                    addRegisterHint(inst, vslot, mode, flags, false);
                     usePos.add(inst);
                     Debug.log("set operand: %s", operand);
                     currentSet.set(vslot.getId());
@@ -201,6 +202,7 @@
                 if (isVirtualStackSlot(operand)) {
                     VirtualStackSlot vslot = asVirtualStackSlot(operand);
                     addDef(vslot, inst);
+                    addRegisterHint(inst, vslot, mode, flags, true);
                     usePos.add(inst);
                     Debug.log("clear operand: %s", operand);
                     currentSet.clear(vslot.getId());
@@ -229,6 +231,32 @@
             interval.addFrom(inst.id());
         }
 
+        void addRegisterHint(final LIRInstruction op, VirtualStackSlot targetValue, OperandMode mode, EnumSet<OperandFlag> flags, final boolean hintAtDef) {
+            if (flags.contains(OperandFlag.HINT)) {
+
+                op.forEachRegisterHint(targetValue, mode, (registerHint, valueMode, valueFlags) -> {
+                    if (isStackSlotValue(registerHint)) {
+                        assert isVirtualStackSlot(registerHint) : "Hint is not a VirtualStackSlot: " + registerHint;
+                        StackInterval from = getOrCreateInterval((VirtualStackSlot) registerHint);
+                        StackInterval to = getOrCreateInterval(targetValue);
+
+                        /* hints always point from def to use */
+                        if (hintAtDef) {
+                            to.setLocationHint(from);
+                        } else {
+                            from.setLocationHint(to);
+                        }
+                        if (Debug.isLogEnabled()) {
+                            Debug.log("operation %s at opId %d: added hint from interval %d to %d", op, op.id(), from, to);
+                        }
+
+                        return registerHint;
+                    }
+                    return null;
+                });
+            }
+        }
+
     }
 
     private StackInterval get(VirtualStackSlot stackSlot) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/StackInterval.java	Wed Apr 29 09:28:58 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/StackInterval.java	Mon Apr 27 11:21:09 2015 +0200
@@ -30,6 +30,7 @@
     private static final int INVALID_START = Integer.MAX_VALUE;
     private static final int INVALID_END = Integer.MIN_VALUE;
     private final VirtualStackSlot operand;
+    private StackInterval hint;
     private final LIRKind kind;
     private int from = INVALID_START;
     private int to = INVALID_END;
@@ -98,7 +99,15 @@
 
     @Override
     public String toString() {
-        return String.format("SI[%d-%d] k=%s o=%s l=%s", from, to, kind, operand, location);
+        return String.format("SI[%d-%d] k=%s o=%s l=%s h=%s", from, to, kind, operand, location, hint.getOperand());
+    }
+
+    public void setLocationHint(StackInterval locationHint) {
+        hint = locationHint;
+    }
+
+    public StackInterval locationHint() {
+        return hint;
     }
 
 }
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java	Wed Apr 29 09:28:58 2015 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java	Mon Apr 27 11:21:09 2015 +0200
@@ -576,7 +576,8 @@
             out.printf("\"[%s|%c]\"", interval.getOperand(), interval.getOperand().getKind().getTypeChar());
         }
 
-        out.printf("%s -1 ", interval.getOperand());
+        StackInterval hint = interval.locationHint();
+        out.printf("%s %s ", interval.getOperand(), hint != null ? hint.getOperand() : -1);
 
         out.printf("[%d, %d[", interval.from(), interval.to());