# HG changeset patch # User Josef Eisl # Date 1396450367 -7200 # Node ID b650367980970c07a3be08c2ea799e237895436e # Parent bc72e5ed9752ec49c755ef315b9f38439de58d46 Remove visitReturn from NodeLIRBuilder. diff -r bc72e5ed9752 -r b65036798097 graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java --- 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; } } diff -r bc72e5ed9752 -r b65036798097 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- 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 diff -r bc72e5ed9752 -r b65036798097 graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java --- 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)); } /** diff -r bc72e5ed9752 -r b65036798097 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- 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() { diff -r bc72e5ed9752 -r b65036798097 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXNodeLIRBuilder.java --- 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(); - } } diff -r bc72e5ed9752 -r b65036798097 graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- 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 diff -r bc72e5ed9752 -r b65036798097 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java --- 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) { } diff -r bc72e5ed9752 -r b65036798097 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- 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 diff -r bc72e5ed9752 -r b65036798097 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java --- 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 diff -r bc72e5ed9752 -r b65036798097 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ReturnNode.java --- 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) { diff -r bc72e5ed9752 -r b65036798097 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 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); } diff -r bc72e5ed9752 -r b65036798097 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuiderTool.java --- 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);