# HG changeset patch # User Roland Schatz # Date 1402650496 -7200 # Node ID 51ba6c5219223f1db88e4f044e1c8bcb1f0a0782 # Parent 69220322bc1434c7d856369d99a5996849b56056 Refactor LIRGeneratorTool methods. diff -r 69220322bc14 -r 51ba6c521922 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 Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Fri Jun 13 11:08:16 2014 +0200 @@ -991,26 +991,32 @@ } @Override - public void emitBitCount(Variable result, Value value) { + public Value emitBitCount(Value value) { + Variable result = newVariable(Kind.Int); if (value.getKind().getStackKind() == Kind.Int) { append(new AMD64BitManipulationOp(IPOPCNT, result, asAllocatable(value))); } else { append(new AMD64BitManipulationOp(LPOPCNT, result, asAllocatable(value))); } + return result; } @Override - public void emitBitScanForward(Variable result, Value value) { + public Value emitBitScanForward(Value value) { + Variable result = newVariable(Kind.Int); append(new AMD64BitManipulationOp(BSF, result, asAllocatable(value))); + return result; } @Override - public void emitBitScanReverse(Variable result, Value value) { + public Value emitBitScanReverse(Value value) { + Variable result = newVariable(Kind.Int); if (value.getKind().getStackKind() == Kind.Int) { append(new AMD64BitManipulationOp(IBSR, result, asAllocatable(value))); } else { append(new AMD64BitManipulationOp(LBSR, result, asAllocatable(value))); } + return result; } @Override @@ -1056,13 +1062,17 @@ } @Override - public void emitByteSwap(Variable result, Value input) { + public Value emitByteSwap(Value input) { + Variable result = newVariable(input.getPlatformKind()); append(new AMD64ByteSwapOp(result, input)); + return result; } @Override - public void emitArrayEquals(Kind kind, Variable result, Value array1, Value array2, Value length) { + public Value emitArrayEquals(Kind kind, Value array1, Value array2, Value length) { + Variable result = newVariable(Kind.Int); append(new AMD64ArrayEqualsOp(this, kind, result, array1, array2, asAllocatable(length))); + return result; } @Override diff -r 69220322bc14 -r 51ba6c521922 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 Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Fri Jun 13 11:08:16 2014 +0200 @@ -693,21 +693,23 @@ } @Override - public void emitBitCount(Variable result, Value value) { + public Value emitBitCount(Value value) { + Variable result = newVariable(Kind.Int); if (value.getKind().getStackKind() == Kind.Int) { append(new HSAILBitManipulationOp(IPOPCNT, result, value)); } else { append(new HSAILBitManipulationOp(LPOPCNT, result, value)); } + return result; } @Override - public void emitBitScanForward(Variable result, Value value) { + public Value emitBitScanForward(Value value) { throw GraalInternalError.unimplemented(); } @Override - public void emitBitScanReverse(Variable result, Value value) { + public Value emitBitScanReverse(Value value) { throw GraalInternalError.unimplemented(); } @@ -794,12 +796,12 @@ } @Override - public void emitByteSwap(Variable result, Value input) { + public Value emitByteSwap(Value input) { throw GraalInternalError.unimplemented(); } @Override - public void emitArrayEquals(Kind kind, Variable result, Value array1, Value array2, Value length) { + public Value emitArrayEquals(Kind kind, Value array1, Value array2, Value length) { // TODO Auto-generated method stub throw GraalInternalError.unimplemented(); } diff -r 69220322bc14 -r 51ba6c521922 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 Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Fri Jun 13 11:08:16 2014 +0200 @@ -765,21 +765,23 @@ } @Override - public void emitBitCount(Variable result, Value value) { + public Value emitBitCount(Value value) { + Variable result = newVariable(Kind.Int); if (value.getKind().getStackKind() == Kind.Int) { append(new PTXBitManipulationOp(IPOPCNT, result, value)); } else { append(new PTXBitManipulationOp(LPOPCNT, result, value)); } + return result; } @Override - public void emitBitScanForward(Variable result, Value value) { + public Value emitBitScanForward(Value value) { throw GraalInternalError.unimplemented("PTXLIRGenerator.emitBitScanForward()"); } @Override - public void emitBitScanReverse(Variable result, Value value) { + public Value emitBitScanReverse(Value value) { throw GraalInternalError.unimplemented("PTXLIRGenerator.emitBitScanReverse()"); } @@ -814,12 +816,12 @@ } @Override - public void emitByteSwap(Variable result, Value input) { + public Value emitByteSwap(Value input) { throw GraalInternalError.unimplemented("PTXLIRGenerator.emitByteSwap()"); } @Override - public void emitArrayEquals(Kind kind, Variable result, Value array1, Value array2, Value length) { + public Value emitArrayEquals(Kind kind, Value array1, Value array2, Value length) { // TODO Auto-generated method stub throw GraalInternalError.unimplemented(); } diff -r 69220322bc14 -r 51ba6c521922 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 Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Fri Jun 13 11:08:16 2014 +0200 @@ -364,26 +364,32 @@ } @Override - public void emitBitCount(Variable result, Value operand) { + public Value emitBitCount(Value operand) { + Variable result = newVariable(Kind.Int); if (operand.getKind().getStackKind() == Kind.Int) { append(new SPARCBitManipulationOp(IPOPCNT, result, asAllocatable(operand), this)); } else { append(new SPARCBitManipulationOp(LPOPCNT, result, asAllocatable(operand), this)); } + return result; } @Override - public void emitBitScanForward(Variable result, Value operand) { + public Value emitBitScanForward(Value operand) { + Variable result = newVariable(Kind.Int); append(new SPARCBitManipulationOp(BSF, result, asAllocatable(operand), this)); + return result; } @Override - public void emitBitScanReverse(Variable result, Value operand) { + public Value emitBitScanReverse(Value operand) { + Variable result = newVariable(Kind.Int); if (operand.getKind().getStackKind() == Kind.Int) { append(new SPARCBitManipulationOp(IBSR, result, asAllocatable(operand), this)); } else { append(new SPARCBitManipulationOp(LBSR, result, asAllocatable(operand), this)); } + return result; } @Override @@ -429,12 +435,14 @@ } @Override - public void emitByteSwap(Variable result, Value input) { + public Value emitByteSwap(Value input) { + Variable result = newVariable(input.getPlatformKind()); append(new SPARCByteSwapOp(result, input)); + return result; } @Override - public void emitArrayEquals(Kind kind, Variable result, Value array1, Value array2, Value length) { + public Value emitArrayEquals(Kind kind, Value array1, Value array2, Value length) { // TODO Auto-generated method stub throw GraalInternalError.unimplemented(); } diff -r 69220322bc14 -r 51ba6c521922 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 Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Fri Jun 13 11:08:16 2014 +0200 @@ -601,26 +601,6 @@ gen.emitOverflowCheckBranch(getLIRBlock(overflowSuccessor), getLIRBlock(next), probability); } - public final void emitArrayEquals(Kind kind, Variable result, Value array1, Value array2, Value length) { - gen.emitArrayEquals(kind, result, array1, array2, length); - } - - public final Variable newVariable(Kind i) { - return gen.newVariable(i); - } - - public final void emitBitCount(Variable result, Value operand) { - gen.emitBitCount(result, operand); - } - - public final void emitBitScanForward(Variable result, Value operand) { - gen.emitBitScanForward(result, operand); - } - - final void emitBitScanReverse(Variable result, Value operand) { - gen.emitBitScanReverse(result, operand); - } - @Override public LIRGeneratorTool getLIRGeneratorTool() { return gen; diff -r 69220322bc14 -r 51ba6c521922 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Fri Jun 13 11:08:16 2014 +0200 @@ -218,7 +218,7 @@ gen.emitMove(raxLocal, expected); append(new CompareAndSwapOp(kind, raxLocal, address, raxLocal, newVal)); - Variable result = newVariable(x.getKind()); + Variable result = gen.newVariable(x.getKind()); gen.emitMove(result, raxLocal); setResult(x, result); } diff -r 69220322bc14 -r 51ba6c521922 graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java Fri Jun 13 11:08:16 2014 +0200 @@ -95,7 +95,7 @@ throw GraalInternalError.shouldNotReachHere("NYI"); } - Variable casResult = newVariable(kind); + Variable casResult = gen.newVariable(kind); append(new CompareAndSwapOp(kind, casResult, address, expected, newVal)); setResult(x, casResult); diff -r 69220322bc14 -r 51ba6c521922 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java Fri Jun 13 11:08:16 2014 +0200 @@ -78,7 +78,7 @@ if (ValueUtil.isConstant(offset)) { assert !gen.getCodeCache().needsDataPatch(asConstant(offset)); - Variable longAddress = newVariable(Kind.Long); + Variable longAddress = gen.newVariable(Kind.Long); gen.emitMove(longAddress, address); address = getGen().emitAdd(longAddress, asConstant(offset)); } else { @@ -89,7 +89,7 @@ append(new CompareAndSwapOp(address, cmpValue, newValue)); - Variable result = newVariable(x.getKind()); + Variable result = gen.newVariable(x.getKind()); gen.emitMove(result, newValue); setResult(x, result); } diff -r 69220322bc14 -r 51ba6c521922 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Fri Jun 13 11:08:16 2014 +0200 @@ -381,16 +381,6 @@ return Kind.Object; } - public abstract void emitBitCount(Variable result, Value operand); - - public abstract void emitBitScanForward(Variable result, Value operand); - - public abstract void emitBitScanReverse(Variable result, Value operand); - - public abstract void emitByteSwap(Variable result, Value operand); - - public abstract void emitArrayEquals(Kind kind, Variable result, Value array1, Value array2, Value length); - public AbstractBlock getCurrentBlock() { return currentBlock; } diff -r 69220322bc14 -r 51ba6c521922 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Fri Jun 13 11:08:16 2014 +0200 @@ -189,14 +189,14 @@ CallingConvention getCallingConvention(); - void emitBitCount(Variable result, Value operand); + Value emitBitCount(Value operand); - void emitBitScanForward(Variable result, Value operand); + Value emitBitScanForward(Value operand); - void emitBitScanReverse(Variable result, Value operand); + Value emitBitScanReverse(Value operand); - void emitByteSwap(Variable result, Value operand); + Value emitByteSwap(Value operand); - void emitArrayEquals(Kind kind, Variable result, Value array1, Value array2, Value length); + Value emitArrayEquals(Kind kind, Value array1, Value array2, Value length); } diff -r 69220322bc14 -r 51ba6c521922 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuilderTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuilderTool.java Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuilderTool.java Fri Jun 13 11:08:16 2014 +0200 @@ -68,13 +68,5 @@ Value[] visitInvokeArguments(CallingConvention cc, Collection arguments); - Variable newVariable(Kind kind); - - void emitArrayEquals(Kind kind, Variable result, Value array1, Value array2, Value length); - - void emitBitCount(Variable result, Value operand); - - void emitBitScanForward(Variable result, Value operand); - void doBlock(Block block, StructuredGraph graph, BlockMap> blockMap); } diff -r 69220322bc14 -r 51ba6c521922 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ArrayEqualsNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ArrayEqualsNode.java Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ArrayEqualsNode.java Fri Jun 13 11:08:16 2014 +0200 @@ -26,7 +26,6 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; -import com.oracle.graal.lir.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.util.*; @@ -130,8 +129,7 @@ @Override public void generate(NodeLIRBuilderTool gen) { - Variable result = gen.newVariable(Kind.Int); - gen.emitArrayEquals(kind, result, gen.operand(array1), gen.operand(array2), gen.operand(length)); + Value result = gen.getLIRGeneratorTool().emitArrayEquals(kind, gen.operand(array1), gen.operand(array2), gen.operand(length)); gen.setResult(this, result); } } diff -r 69220322bc14 -r 51ba6c521922 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitCountNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitCountNode.java Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitCountNode.java Fri Jun 13 11:08:16 2014 +0200 @@ -26,7 +26,6 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; -import com.oracle.graal.lir.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; @@ -65,8 +64,7 @@ @Override public void generate(NodeLIRBuilderTool gen) { - Variable result = gen.newVariable(Kind.Int); - gen.emitBitCount(result, gen.operand(value)); + Value result = gen.getLIRGeneratorTool().emitBitCount(gen.operand(value)); gen.setResult(this, result); } } diff -r 69220322bc14 -r 51ba6c521922 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitScanForwardNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitScanForwardNode.java Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitScanForwardNode.java Fri Jun 13 11:08:16 2014 +0200 @@ -26,7 +26,6 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; -import com.oracle.graal.lir.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; @@ -72,8 +71,7 @@ @Override public void generate(NodeLIRBuilderTool gen) { - Variable result = gen.newVariable(Kind.Int); - gen.emitBitScanForward(result, gen.operand(value)); + Value result = gen.getLIRGeneratorTool().emitBitScanForward(gen.operand(value)); gen.setResult(this, result); } } diff -r 69220322bc14 -r 51ba6c521922 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitScanReverseNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitScanReverseNode.java Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitScanReverseNode.java Fri Jun 13 11:08:16 2014 +0200 @@ -26,7 +26,6 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; -import com.oracle.graal.lir.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; @@ -79,8 +78,7 @@ @Override public void generate(NodeLIRBuilderTool gen) { - Variable result = gen.newVariable(Kind.Int); - gen.getLIRGeneratorTool().emitBitScanReverse(result, gen.operand(value)); + Value result = gen.getLIRGeneratorTool().emitBitScanReverse(gen.operand(value)); gen.setResult(this, result); } diff -r 69220322bc14 -r 51ba6c521922 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ReverseBytesNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ReverseBytesNode.java Fri Jun 13 11:31:17 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ReverseBytesNode.java Fri Jun 13 11:08:16 2014 +0200 @@ -26,7 +26,6 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; -import com.oracle.graal.lir.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; @@ -66,8 +65,7 @@ @Override public void generate(NodeLIRBuilderTool gen) { - Variable result = gen.newVariable(value.getKind()); - gen.getLIRGeneratorTool().emitByteSwap(result, gen.operand(value)); + Value result = gen.getLIRGeneratorTool().emitByteSwap(gen.operand(value)); gen.setResult(this, result); } }