changeset 14949:b65036798097

Remove visitReturn from NodeLIRBuilder.
author Josef Eisl <josef.eisl@jku.at>
date Wed, 02 Apr 2014 16:52:47 +0200
parents bc72e5ed9752
children d5a1206e1923
files graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXNodeLIRBuilder.java graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ReturnNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuiderTool.java
diffstat 12 files changed, 59 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java	Wed Apr 02 10:08:00 2014 +0200
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java	Wed Apr 02 16:52:47 2014 +0200
@@ -523,10 +523,6 @@
 
     @Override
     protected void genReturn(Value x) {
-        if (x != null) {
-            AllocatableValue operand = gen.resultOperandFor(x.getKind());
-            gen.emitMove(operand, x);
-        }
         gen.emitReturn(x);
     }
 
@@ -639,10 +635,12 @@
 
             if (bci < endBCI) {
                 if (bci > block.endBci) {
-                    assert !block.getSuccessor(0).isExceptionEntry;
-                    assert block.numNormalSuccessors() == 1;
-                    // we fell through to the next block, add a goto and break
-                    appendGoto(createTarget(block.getSuccessor(0), frameState));
+                    if (block.numNormalSuccessors() == 1) {
+                        assert !block.getSuccessor(0).isExceptionEntry;
+                        // we fell through to the next block, add a goto and break
+                        LabelRef label = LabelRef.forSuccessor(lirGenRes.getLIR(), block.getSuccessor(0), 0);
+                        gen.emitJump(label);
+                    }
                     break;
                 }
             }
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Wed Apr 02 10:08:00 2014 +0200
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Wed Apr 02 16:52:47 2014 +0200
@@ -987,7 +987,12 @@
 
     @Override
     public void emitReturn(Value input) {
-        append(new ReturnOp(input));
+        AllocatableValue operand = Value.ILLEGAL;
+        if (input != null) {
+            operand = resultOperandFor(input.getKind());
+            emitMove(operand, input);
+        }
+        append(new ReturnOp(operand));
     }
 
     @Override
--- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java	Wed Apr 02 10:08:00 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java	Wed Apr 02 16:52:47 2014 +0200
@@ -806,7 +806,12 @@
 
     @Override
     public void emitReturn(Value input) {
-        append(new ReturnOp(input));
+        AllocatableValue operand = Value.ILLEGAL;
+        if (input != null) {
+            operand = resultOperandFor(input.getKind());
+            emitMove(operand, input);
+        }
+        append(new ReturnOp(operand));
     }
 
     /**
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Wed Apr 02 10:08:00 2014 +0200
+++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Wed Apr 02 16:52:47 2014 +0200
@@ -333,7 +333,7 @@
     /**
      * This method emits the compare instruction, and may reorder the operands. It returns true if
      * it did so.
-     * 
+     *
      * @param a the left operand of the comparison
      * @param b the right operand of the comparison
      * @return true if the left and right operands were switched, false otherwise
@@ -829,7 +829,15 @@
 
     @Override
     public void emitReturn(Value input) {
-        append(new ReturnOp(input));
+        AllocatableValue operand = Value.ILLEGAL;
+        if (input != null) {
+            operand = resultOperandFor(input.getKind());
+            // Load the global memory address from return parameter
+            Variable loadVar = emitLoadReturnAddress(operand.getKind(), operand, null);
+            // Store result in global memory whose location is loadVar
+            emitStoreReturnValue(operand.getKind(), loadVar, operand, null);
+        }
+        append(new ReturnOp(operand));
     }
 
     void emitReturnNoVal() {
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXNodeLIRBuilder.java	Wed Apr 02 10:08:00 2014 +0200
+++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXNodeLIRBuilder.java	Wed Apr 02 16:52:47 2014 +0200
@@ -148,17 +148,4 @@
     public void visitInfopointNode(InfopointNode i) {
         throw GraalInternalError.unimplemented("PTXLIRGenerator.visitInfopointNode()");
     }
-
-    @Override
-    public void visitReturn(ReturnNode x) {
-        AllocatableValue operand = Value.ILLEGAL;
-        if (x.result() != null) {
-            operand = gen.resultOperandFor(x.result().getKind());
-            // Load the global memory address from return parameter
-            Variable loadVar = getGen().emitLoadReturnAddress(operand.getKind(), operand, null);
-            // Store result in global memory whose location is loadVar
-            getGen().emitStoreReturnValue(operand.getKind(), loadVar, operand(x.result()), null);
-        }
-        getGen().emitReturnNoVal();
-    }
 }
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Wed Apr 02 10:08:00 2014 +0200
+++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Wed Apr 02 16:52:47 2014 +0200
@@ -219,7 +219,12 @@
 
     @Override
     public void emitReturn(Value input) {
-        append(new ReturnOp(input));
+        AllocatableValue operand = Value.ILLEGAL;
+        if (input != null) {
+            operand = resultOperandFor(input.getKind());
+            emitMove(operand, input);
+        }
+        append(new ReturnOp(operand));
     }
 
     @Override
@@ -297,7 +302,7 @@
     /**
      * This method emits the compare instruction, and may reorder the operands. It returns true if
      * it did so.
-     * 
+     *
      * @param a the left operand of the comparison
      * @param b the right operand of the comparison
      * @return true if the left and right operands were switched, false otherwise
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java	Wed Apr 02 10:08:00 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java	Wed Apr 02 16:52:47 2014 +0200
@@ -23,7 +23,6 @@
 package com.oracle.graal.compiler.gen;
 
 import static com.oracle.graal.api.code.ValueUtil.*;
-import static com.oracle.graal.api.meta.Value.*;
 import static com.oracle.graal.lir.LIR.*;
 import static com.oracle.graal.nodes.ConstantNode.*;
 
@@ -453,16 +452,6 @@
     }
 
     @Override
-    public void visitReturn(ReturnNode x) {
-        AllocatableValue operand = ILLEGAL;
-        if (x.result() != null) {
-            operand = gen.resultOperandFor(x.result().getKind());
-            gen.emitMove(operand, operand(x.result()));
-        }
-        gen.emitReturn(operand);
-    }
-
-    @Override
     public void visitMerge(MergeNode x) {
     }
 
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Wed Apr 02 10:08:00 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Wed Apr 02 16:52:47 2014 +0200
@@ -143,10 +143,15 @@
 
     @Override
     public void emitReturn(Value input) {
+        AllocatableValue operand = Value.ILLEGAL;
+        if (input != null) {
+            operand = resultOperandFor(input.getKind());
+            emitMove(operand, input);
+        }
         if (pollOnReturnScratchRegister == null) {
             pollOnReturnScratchRegister = findPollOnReturnScratchRegister();
         }
-        append(new AMD64HotSpotReturnOp(input, getStub() != null, pollOnReturnScratchRegister));
+        append(new AMD64HotSpotReturnOp(operand, getStub() != null, pollOnReturnScratchRegister));
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Wed Apr 02 10:08:00 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Wed Apr 02 16:52:47 2014 +0200
@@ -99,7 +99,12 @@
 
     @Override
     public void emitReturn(Value input) {
-        append(new SPARCHotSpotReturnOp(input, getStub() != null));
+        AllocatableValue operand = Value.ILLEGAL;
+        if (input != null) {
+            operand = resultOperandFor(input.getKind());
+            emitMove(operand, input);
+        }
+        append(new SPARCHotSpotReturnOp(operand, getStub() != null));
     }
 
     @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ReturnNode.java	Wed Apr 02 10:08:00 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ReturnNode.java	Wed Apr 02 16:52:47 2014 +0200
@@ -37,7 +37,7 @@
 
     /**
      * Constructs a new Return instruction.
-     * 
+     *
      * @param result the instruction producing the result for this return; {@code null} if this is a
      *            void return
      */
@@ -58,7 +58,11 @@
 
     @Override
     public void generate(NodeLIRBuiderTool gen) {
-        gen.visitReturn(this);
+        if (this.result() == null) {
+            gen.getLIRGeneratorTool().emitReturn(null);
+        } else {
+            gen.getLIRGeneratorTool().emitReturn(gen.operand(this.result()));
+        }
     }
 
     public void setMemoryMap(MemoryMapNode memoryMap) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java	Wed Apr 02 10:08:00 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java	Wed Apr 02 16:52:47 2014 +0200
@@ -48,7 +48,7 @@
     /**
      * Checks whether the supplied constant can be used without loading it into a register for most
      * operations, i.e., for commonly used arithmetic, logical, and comparison operations.
-     * 
+     *
      * @param c The constant to check.
      * @return True if the constant can be used directly, false if the constant needs to be in a
      *         register.
@@ -67,7 +67,7 @@
 
     /**
      * Emits an op that loads the address of some raw data.
-     * 
+     *
      * @param dst the variable into which the address is loaded
      * @param data the data to be installed with the generated code
      */
@@ -89,5 +89,9 @@
 
     void emitIncomingValues(Value[] params);
 
+    /**
+     * Emits a return instruction. Implementations need to insert a move if the input is not in the
+     * correct location.
+     */
     void emitReturn(Value input);
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuiderTool.java	Wed Apr 02 10:08:00 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuiderTool.java	Wed Apr 02 16:52:47 2014 +0200
@@ -54,8 +54,6 @@
 
     // These methods define the contract a runtime specific backend must provide.
 
-    void visitReturn(ReturnNode i);
-
     void visitSafepointNode(SafepointNode i);
 
     void visitBreakpointNode(BreakpointNode i);