# HG changeset patch # User Josef Eisl # Date 1396357630 -7200 # Node ID bcef7320c70761f22cd1408713a0cb856639e165 # Parent ea57ed7085cff1bd7c03c545f97fc50dfe4db192 Remove more duplicate methods from NodeLIRBuilder and LIRGenerator. diff -r ea57ed7085cf -r bcef7320c707 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 Tue Apr 01 15:05:26 2014 +0200 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXNodeLIRBuilder.java Tue Apr 01 15:07:10 2014 +0200 @@ -33,7 +33,6 @@ import com.oracle.graal.lir.*; import com.oracle.graal.lir.ptx.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.java.*; /** @@ -107,49 +106,6 @@ } @Override - protected > void emitPrologue(ResolvedJavaMethod method, BytecodeParser parser) { - // Need to emit .param directives based on incoming arguments and return value - CallingConvention incomingArguments = gen.getCallingConvention(); - Object returnObject = incomingArguments.getReturn(); - AllocatableValue[] params = incomingArguments.getArguments(); - int argCount = incomingArguments.getArgumentCount(); - - if (returnObject.equals(Value.ILLEGAL)) { - params = incomingArguments.getArguments(); - append(new PTXParameterOp(params, false)); - } else { - argCount = incomingArguments.getArgumentCount(); - params = new Variable[argCount + 1]; - for (int i = 0; i < argCount; i++) { - params[i] = incomingArguments.getArgument(i); - } - params[argCount] = (Variable) returnObject; - append(new PTXParameterOp(params, true)); - } - - Signature sig = method.getSignature(); - boolean isStatic = Modifier.isStatic(method.getModifiers()); - - for (int i = 0; i < sig.getParameterCount(!isStatic); i++) { - Value paramValue = params[i]; - int parameterIndex = i; - if (!isStatic) { - parameterIndex--; - } - Warp warpAnnotation = parameterIndex >= 0 ? MetaUtil.getParameterAnnotation(Warp.class, parameterIndex, method) : null; - if (warpAnnotation != null) { - // setResult(param, emitWarpParam(paramValue.getKind().getStackKind(), - // warpAnnotation)); - parser.setParameter(i, getGen().emitWarpParam(paramValue.getKind().getStackKind(), warpAnnotation)); - } else { - // setResult(param, emitLoadParam(paramValue.getKind().getStackKind(), paramValue, - // null)); - parser.setParameter(i, getGen().emitLoadParam(paramValue.getKind().getStackKind(), paramValue, null)); - } - } - } - - @Override protected boolean peephole(ValueNode valueNode) { // No peephole optimizations for now return false; diff -r ea57ed7085cf -r bcef7320c707 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Tue Apr 01 15:05:26 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Tue Apr 01 15:07:10 2014 +0200 @@ -376,7 +376,7 @@ protected abstract void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info); - protected static AllocatableValue toStackKind(AllocatableValue value) { + public static AllocatableValue toStackKind(AllocatableValue value) { if (value.getKind().getStackKind() != value.getKind()) { // We only have stack-kinds in the LIR, so convert the operand kind for values from the // calling convention. diff -r ea57ed7085cf -r bcef7320c707 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 Tue Apr 01 15:05:26 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Tue Apr 01 15:07:10 2014 +0200 @@ -27,7 +27,6 @@ import static com.oracle.graal.lir.LIR.*; import static com.oracle.graal.nodes.ConstantNode.*; -import java.lang.reflect.*; import java.util.*; import java.util.Map.Entry; @@ -41,7 +40,6 @@ import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.BlockEndOp; import com.oracle.graal.lir.StandardOp.JumpOp; -import com.oracle.graal.lir.StandardOp.LabelOp; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.calc.*; @@ -425,7 +423,7 @@ Value[] params = new Value[incomingArguments.getArgumentCount()]; for (int i = 0; i < params.length; i++) { - params[i] = toStackKind(incomingArguments.getArgument(i)); + params[i] = LIRGenerator.toStackKind(incomingArguments.getArgument(i)); if (ValueUtil.isStackSlot(params[i])) { StackSlot slot = ValueUtil.asStackSlot(params[i]); if (slot.isInCallerFrame() && !gen.getResult().getLIR().hasArgInCallerFrame()) { @@ -434,7 +432,7 @@ } } - emitIncomingValues(params); + gen.emitIncomingValues(params); for (ParameterNode param : graph.getNodes(ParameterNode.class)) { Value paramValue = params[param.index()]; @@ -443,38 +441,6 @@ } } - protected > void emitPrologue(ResolvedJavaMethod method, BytecodeParser parser) { - CallingConvention incomingArguments = gen.getCallingConvention(); - - Value[] params = new Value[incomingArguments.getArgumentCount()]; - for (int i = 0; i < params.length; i++) { - params[i] = toStackKind(incomingArguments.getArgument(i)); - if (ValueUtil.isStackSlot(params[i])) { - StackSlot slot = ValueUtil.asStackSlot(params[i]); - if (slot.isInCallerFrame() && !gen.getResult().getLIR().hasArgInCallerFrame()) { - gen.getResult().getLIR().setHasArgInCallerFrame(); - } - } - } - - emitIncomingValues(params); - - Signature sig = method.getSignature(); - boolean isStatic = Modifier.isStatic(method.getModifiers()); - for (int i = 0; i < sig.getParameterCount(!isStatic); i++) { - Value paramValue = params[i]; - assert paramValue.getKind() == sig.getParameterKind(i).getStackKind(); - // TODO setResult(param, emitMove(paramValue)); - parser.setParameter(i, gen.emitMove(paramValue)); - } - - // return arguments; - } - - public void emitIncomingValues(Value[] params) { - ((LabelOp) gen.getResult().getLIR().getLIRforBlock(gen.getCurrentBlock()).get(0)).setIncomingValues(params); - } - @Override public void visitReturn(ReturnNode x) { AllocatableValue operand = ILLEGAL; @@ -631,21 +597,6 @@ protected abstract void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState); - protected static AllocatableValue toStackKind(AllocatableValue value) { - if (value.getKind().getStackKind() != value.getKind()) { - // We only have stack-kinds in the LIR, so convert the operand kind for values from the - // calling convention. - if (isRegister(value)) { - return asRegister(value).asValue(value.getKind().getStackKind()); - } else if (isStackSlot(value)) { - return StackSlot.get(value.getKind().getStackKind(), asStackSlot(value).getRawOffset(), asStackSlot(value).getRawAddFrameSize()); - } else { - throw GraalInternalError.shouldNotReachHere(); - } - } - return value; - } - @Override public Value[] visitInvokeArguments(CallingConvention invokeCc, Collection arguments) { // for each argument, load it into the correct location @@ -653,7 +604,7 @@ int j = 0; for (ValueNode arg : arguments) { if (arg != null) { - AllocatableValue operand = toStackKind(invokeCc.getArgument(j)); + AllocatableValue operand = LIRGenerator.toStackKind(invokeCc.getArgument(j)); gen.emitMove(operand, operand(arg)); result[j] = operand; j++; diff -r ea57ed7085cf -r bcef7320c707 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 Tue Apr 01 15:05:26 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Tue Apr 01 15:07:10 2014 +0200 @@ -87,7 +87,7 @@ Value[] params = new Value[incomingArguments.getArgumentCount() + 1]; for (int i = 0; i < params.length - 1; i++) { - params[i] = toStackKind(incomingArguments.getArgument(i)); + params[i] = LIRGenerator.toStackKind(incomingArguments.getArgument(i)); if (isStackSlot(params[i])) { StackSlot slot = ValueUtil.asStackSlot(params[i]); if (slot.isInCallerFrame() && !gen.getResult().getLIR().hasArgInCallerFrame()) { @@ -97,7 +97,7 @@ } params[params.length - 1] = rbp.asValue(Kind.Long); - emitIncomingValues(params); + gen.emitIncomingValues(params); setSaveRbp(((AMD64HotSpotLIRGenerator) gen).new SaveRbp(new NoOp(gen.getCurrentBlock(), gen.getResult().getLIR().getLIRforBlock(gen.getCurrentBlock()).size()))); append(getSaveRbp().placeholder);