Mercurial > hg > graal-jvmci-8
changeset 14846:43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Wed, 26 Mar 2014 15:59:59 +0100 |
parents | ba13350ee179 |
children | c132602c640e |
files | graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILNodeLIRGenerator.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRGenerator.java graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathIntrinsicsNode.java |
diffstat | 6 files changed, 237 insertions(+), 110 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Wed Mar 26 15:14:27 2014 +0100 +++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Wed Mar 26 15:59:59 2014 +0100 @@ -32,7 +32,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; import com.oracle.graal.compiler.gen.*; -import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.JumpOp; @@ -54,7 +53,6 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert; -import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.util.*; /** @@ -76,8 +74,8 @@ } } - public HSAILLIRGenerator(StructuredGraph graph, Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { - super(graph, providers, cc, lirGenRes); + public HSAILLIRGenerator(Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { + super(providers, cc, lirGenRes); lirGenRes.getLIR().setSpillMoveFactory(new HSAILSpillMoveFactory()); } @@ -115,7 +113,7 @@ } } - protected HSAILAddressValue asAddressValue(Value address) { + public HSAILAddressValue asAddressValue(Value address) { if (address instanceof HSAILAddressValue) { return (HSAILAddressValue) address; } else { @@ -173,7 +171,7 @@ append(new JumpOp(label)); } - protected static HSAILCompare mapKindToCompareOp(Kind kind) { + public static HSAILCompare mapKindToCompareOp(Kind kind) { switch (kind) { case Int: return ICMP; @@ -412,12 +410,6 @@ } @Override - protected boolean peephole(ValueNode valueNode) { - // No peephole optimizations for now. - return false; - } - - @Override public Value emitDiv(Value a, Value b, DeoptimizingNode deopting) { Variable result = newVariable(a.getKind()); switch (a.getKind()) { @@ -697,16 +689,6 @@ } @Override - protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { - throw GraalInternalError.unimplemented(); - } - - @Override - protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { - throw GraalInternalError.unimplemented(); - } - - @Override public void emitBitCount(Variable result, Value value) { if (value.getKind().getStackKind() == Kind.Int) { append(new HSAILBitManipulationOp(IPOPCNT, result, value)); @@ -819,7 +801,7 @@ } @Override - protected void emitReturn(Value input) { + public void emitReturn(Value input) { append(new ReturnOp(input)); } @@ -879,30 +861,8 @@ } @Override - public void visitBreakpointNode(BreakpointNode node) { - throw GraalInternalError.unimplemented(); - } - - @Override - public void visitSafepointNode(SafepointNode i) { - Debug.log("visitSafePointNode unimplemented"); - } - - @Override public void emitUnwind(Value operand) { throw GraalInternalError.unimplemented(); } - @Override - public void emitNullCheck(ValueNode v, DeoptimizingNode deopting) { - assert v.stamp() instanceof ObjectStamp; - Variable obj = newVariable(Kind.Object); - emitMove(obj, operand(v)); - append(new HSAILMove.NullCheckOp(obj, state(deopting))); - } - - @Override - public void visitInfopointNode(InfopointNode i) { - throw GraalInternalError.unimplemented(); - } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILNodeLIRGenerator.java Wed Mar 26 15:59:59 2014 +0100 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.oracle.graal.compiler.hsail; + +import static com.oracle.graal.lir.hsail.HSAILBitManipulationOp.IntrinsicOpcode.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.gen.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.lir.*; +import com.oracle.graal.lir.hsail.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.type.*; + +/** + * This class implements the HSAIL specific portion of the LIR generator. + */ +public abstract class HSAILNodeLIRGenerator extends NodeLIRGenerator { + + public HSAILNodeLIRGenerator(StructuredGraph graph, LIRGenerationResult lirGenRes, LIRGenerator lirGen) { + super(graph, lirGenRes, lirGen); + } + + @Override + protected boolean peephole(ValueNode valueNode) { + // No peephole optimizations for now. + return false; + } + + @Override + protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { + throw GraalInternalError.unimplemented(); + } + + @Override + protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { + throw GraalInternalError.unimplemented(); + } + + @Override + public void emitBitCount(Variable result, Value value) { + if (value.getKind().getStackKind() == Kind.Int) { + append(new HSAILBitManipulationOp(IPOPCNT, result, value)); + } else { + append(new HSAILBitManipulationOp(LPOPCNT, result, value)); + } + } + + @Override + public void emitBitScanForward(Variable result, Value value) { + throw GraalInternalError.unimplemented(); + } + + @Override + public void emitBitScanReverse(Variable result, Value value) { + throw GraalInternalError.unimplemented(); + } + + @Override + public void emitArrayEquals(Kind kind, Variable result, Value array1, Value array2, Value length) { + // TODO Auto-generated method stub + throw GraalInternalError.unimplemented(); + } + + @Override + public void visitBreakpointNode(BreakpointNode node) { + throw GraalInternalError.unimplemented(); + } + + @Override + public void visitSafepointNode(SafepointNode i) { + Debug.log("visitSafePointNode unimplemented"); + } + + @Override + public void emitNullCheck(ValueNode v, DeoptimizingNode deopting) { + assert v.stamp() instanceof ObjectStamp; + Variable obj = newVariable(Kind.Object); + gen.emitMove(obj, operand(v)); + append(new HSAILMove.NullCheckOp(obj, state(deopting))); + } + + @Override + public void visitInfopointNode(InfopointNode i) { + throw GraalInternalError.unimplemented(); + } +}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Wed Mar 26 15:14:27 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Wed Mar 26 15:59:59 2014 +0100 @@ -188,8 +188,8 @@ } @Override - public LIRGenerator newLIRGenerator(StructuredGraph graph, CallingConvention cc, LIRGenerationResult lirGenRes) { - return new HSAILHotSpotLIRGenerator(graph, getProviders(), getRuntime().getConfig(), cc, lirGenRes); + public LIRGenerator newLIRGenerator(CallingConvention cc, LIRGenerationResult lirGenRes) { + return new HSAILHotSpotLIRGenerator(getProviders(), getRuntime().getConfig(), cc, lirGenRes); } @Override @@ -197,6 +197,11 @@ return new LIRGenerationResultBase(lir, frameMap); } + @Override + public NodeLIRGenerator newNodeLIRGenerator(StructuredGraph graph, LIRGenerationResult lirGenRes, LIRGenerator lirGen) { + return new HSAILHotSpotNodeLIRGenerator(graph, lirGenRes, lirGen); + } + class HotSpotFrameContext implements FrameContext { public boolean hasFrame() {
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Wed Mar 26 15:14:27 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Wed Mar 26 15:59:59 2014 +0100 @@ -23,61 +23,61 @@ package com.oracle.graal.hotspot.hsail; -import sun.misc.*; +import static com.oracle.graal.api.code.ValueUtil.*; import com.oracle.graal.api.code.*; - -import static com.oracle.graal.api.code.ValueUtil.asConstant; -import static com.oracle.graal.api.code.ValueUtil.isConstant; - import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.hsail.*; +import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.hsail.*; -import com.oracle.graal.lir.hsail.HSAILControlFlow.*; -import com.oracle.graal.lir.hsail.HSAILMove.*; -import com.oracle.graal.phases.util.*; +import com.oracle.graal.lir.hsail.HSAILControlFlow.ForeignCall1ArgOp; +import com.oracle.graal.lir.hsail.HSAILControlFlow.ForeignCall2ArgOp; +import com.oracle.graal.lir.hsail.HSAILControlFlow.ForeignCallNoArgOp; +import com.oracle.graal.lir.hsail.HSAILMove.LoadCompressedPointer; +import com.oracle.graal.lir.hsail.HSAILMove.LoadOp; +import com.oracle.graal.lir.hsail.HSAILMove.StoreCompressedPointer; +import com.oracle.graal.lir.hsail.HSAILMove.StoreConstantOp; +import com.oracle.graal.lir.hsail.HSAILMove.StoreOp; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.java.*; -import com.oracle.graal.graph.*; +import com.oracle.graal.phases.util.*; /** * The HotSpot specific portion of the HSAIL LIR generator. */ public class HSAILHotSpotLIRGenerator extends HSAILLIRGenerator { - private final HotSpotVMConfig config; + final HotSpotVMConfig config; - public HSAILHotSpotLIRGenerator(StructuredGraph graph, Providers providers, HotSpotVMConfig config, CallingConvention cc, LIRGenerationResult lirGenRes) { - super(graph, providers, cc, lirGenRes); + public HSAILHotSpotLIRGenerator(Providers providers, HotSpotVMConfig config, CallingConvention cc, LIRGenerationResult lirGenRes) { + super(providers, cc, lirGenRes); this.config = config; } - private int getLogMinObjectAlignment() { + int getLogMinObjectAlignment() { return config.logMinObjAlignment(); } - private int getNarrowOopShift() { + int getNarrowOopShift() { return config.narrowOopShift; } - private long getNarrowOopBase() { + long getNarrowOopBase() { return config.narrowOopBase; } - private int getLogKlassAlignment() { + int getLogKlassAlignment() { return config.logKlassAlignment; } - private int getNarrowKlassShift() { + int getNarrowKlassShift() { return config.narrowKlassShift; } - private long getNarrowKlassBase() { + long getNarrowKlassBase() { return config.narrowKlassBase; } @@ -91,41 +91,6 @@ } /** - * Appends either a {@link CompareAndSwapOp} or a {@link CompareAndSwapCompressedOp} depending - * on whether the memory location of a given {@link LoweredCompareAndSwapNode} contains a - * compressed oop. For the {@link CompareAndSwapCompressedOp} case, allocates a number of - * scratch registers. The result {@link #operand(ValueNode) operand} for {@code node} complies - * with the API for {@link Unsafe#compareAndSwapInt(Object, long, int, int)}. - * - * @param address the memory location targeted by the operation - */ - @Override - public void visitCompareAndSwap(LoweredCompareAndSwapNode node, Value address) { - Kind kind = node.getNewValue().getKind(); - assert kind == node.getExpectedValue().getKind(); - Variable expected = load(operand(node.getExpectedValue())); - Variable newValue = load(operand(node.getNewValue())); - HSAILAddressValue addressValue = asAddressValue(address); - Variable casResult = newVariable(kind); - if (config.useCompressedOops && node.isCompressible()) { - // make 64-bit scratch variables for expected and new - Variable scratchExpected64 = newVariable(Kind.Long); - Variable scratchNewValue64 = newVariable(Kind.Long); - // make 32-bit scratch variables for expected and new and result - Variable scratchExpected32 = newVariable(Kind.Int); - Variable scratchNewValue32 = newVariable(Kind.Int); - Variable scratchCasResult32 = newVariable(Kind.Int); - append(new CompareAndSwapCompressedOp(casResult, addressValue, expected, newValue, scratchExpected64, scratchNewValue64, scratchExpected32, scratchNewValue32, scratchCasResult32, - getNarrowOopBase(), getNarrowOopShift(), getLogMinObjectAlignment())); - } else { - append(new CompareAndSwapOp(casResult, addressValue, expected, newValue)); - } - Variable nodeResult = newVariable(node.getKind()); - append(new CondMoveOp(mapKindToCompareOp(kind), casResult, expected, nodeResult, Condition.EQ, Constant.INT_1, Constant.INT_0)); - setResult(node, nodeResult); - } - - /** * Returns whether or not the input access should be (de)compressed. */ private boolean isCompressedOperation(Kind kind, Access access) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRGenerator.java Wed Mar 26 15:59:59 2014 +0100 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.oracle.graal.hotspot.hsail; + +import sun.misc.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.gen.*; +import com.oracle.graal.compiler.hsail.*; +import com.oracle.graal.lir.*; +import com.oracle.graal.lir.hsail.*; +import com.oracle.graal.lir.hsail.HSAILControlFlow.CondMoveOp; +import com.oracle.graal.lir.hsail.HSAILMove.CompareAndSwapCompressedOp; +import com.oracle.graal.lir.hsail.HSAILMove.CompareAndSwapOp; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.calc.*; +import com.oracle.graal.nodes.java.*; + +/** + * The HotSpot specific portion of the HSAIL LIR generator. + */ +public class HSAILHotSpotNodeLIRGenerator extends HSAILNodeLIRGenerator { + + public HSAILHotSpotNodeLIRGenerator(StructuredGraph graph, LIRGenerationResult lirGenRes, LIRGenerator lirGen) { + super(graph, lirGenRes, lirGen); + } + + private HSAILHotSpotLIRGenerator getGen() { + return (HSAILHotSpotLIRGenerator) gen; + } + + /** + * Appends either a {@link CompareAndSwapOp} or a {@link CompareAndSwapCompressedOp} depending + * on whether the memory location of a given {@link LoweredCompareAndSwapNode} contains a + * compressed oop. For the {@link CompareAndSwapCompressedOp} case, allocates a number of + * scratch registers. The result {@link #operand(ValueNode) operand} for {@code node} complies + * with the API for {@link Unsafe#compareAndSwapInt(Object, long, int, int)}. + * + * @param address the memory location targeted by the operation + */ + @Override + public void visitCompareAndSwap(LoweredCompareAndSwapNode node, Value address) { + Kind kind = node.getNewValue().getKind(); + assert kind == node.getExpectedValue().getKind(); + Variable expected = gen.load(operand(node.getExpectedValue())); + Variable newValue = gen.load(operand(node.getNewValue())); + HSAILAddressValue addressValue = getGen().asAddressValue(address); + Variable casResult = newVariable(kind); + if (getGen().config.useCompressedOops && node.isCompressible()) { + // make 64-bit scratch variables for expected and new + Variable scratchExpected64 = newVariable(Kind.Long); + Variable scratchNewValue64 = newVariable(Kind.Long); + // make 32-bit scratch variables for expected and new and result + Variable scratchExpected32 = newVariable(Kind.Int); + Variable scratchNewValue32 = newVariable(Kind.Int); + Variable scratchCasResult32 = newVariable(Kind.Int); + append(new CompareAndSwapCompressedOp(casResult, addressValue, expected, newValue, scratchExpected64, scratchNewValue64, scratchExpected32, scratchNewValue32, scratchCasResult32, + getGen().getNarrowOopBase(), getGen().getNarrowOopShift(), getGen().getLogMinObjectAlignment())); + } else { + append(new CompareAndSwapOp(casResult, addressValue, expected, newValue)); + } + Variable nodeResult = newVariable(node.getKind()); + append(new CondMoveOp(HSAILLIRGenerator.mapKindToCompareOp(kind), casResult, expected, nodeResult, Condition.EQ, Constant.INT_1, Constant.INT_0)); + setResult(node, nodeResult); + } + +}
--- a/graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathIntrinsicsNode.java Wed Mar 26 15:14:27 2014 +0100 +++ b/graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathIntrinsicsNode.java Wed Mar 26 15:59:59 2014 +0100 @@ -33,8 +33,7 @@ import com.oracle.graal.nodes.calc.FloatingNode; import com.oracle.graal.nodes.ConstantNode; import com.oracle.graal.nodes.ValueNode; -import com.oracle.graal.nodes.spi.NodeMappableArithmeticLIRGenerator; -import com.oracle.graal.nodes.spi.ArithmeticLIRLowerable; +import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.StampFactory; /** @@ -86,24 +85,24 @@ * Generates the LIR instructions for the math operation represented by this node. */ @Override - public void generate(NodeMappableArithmeticLIRGenerator gen) { + public void generate(NodeLIRGeneratorTool gen) { Value input = gen.operand(getParameter()); Value result; switch (operation()) { case ABS: - result = gen.emitMathAbs(input); + result = gen.getLIRGeneratorTool().emitMathAbs(input); break; case CEIL: - result = ((HSAILLIRGenerator) (gen)).emitMathCeil(input); + result = ((HSAILLIRGenerator) (gen.getLIRGeneratorTool())).emitMathCeil(input); break; case FLOOR: - result = ((HSAILLIRGenerator) (gen)).emitMathFloor(input); + result = ((HSAILLIRGenerator) (gen.getLIRGeneratorTool())).emitMathFloor(input); break; case RINT: - result = ((HSAILLIRGenerator) (gen)).emitMathRint(input); + result = ((HSAILLIRGenerator) (gen.getLIRGeneratorTool())).emitMathRint(input); break; case SQRT: - result = gen.emitMathSqrt(input); + result = gen.getLIRGeneratorTool().emitMathSqrt(input); break; default: @@ -175,4 +174,5 @@ */ @NodeIntrinsic public static native double compute(double value, @ConstantNodeParameter HSAILArithmetic op); + }