# HG changeset patch # User Roland Schatz # Date 1413295744 -7200 # Node ID b0e8bc17af1b327c6016d556348308d9d61d6fe6 # Parent 2ea20d64ab5cfe328defc2a67e9875e730e43f63 Remove unused method from ArithmeticOperation interface. diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ArithmeticOperation.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ArithmeticOperation.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ArithmeticOperation.java Tue Oct 14 16:09:04 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -22,13 +22,9 @@ */ package com.oracle.graal.api.code; -import com.oracle.graal.api.meta.*; - /** * An {@code ArithmeticOperation} is an operation that does primitive value arithmetic without side * effect. */ public interface ArithmeticOperation { - - Constant evalConst(Constant... inputs); } diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -162,7 +162,7 @@ @Override public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) { if (forValue.isConstant()) { - return ConstantNode.forConstant(stamp(), evalConst(forValue.asConstant()), tool.getMetaAccess()); + return ConstantNode.forConstant(stamp(), convert(forValue.asConstant()), tool.getMetaAccess()); } else if (forValue instanceof CompressionNode) { CompressionNode other = (CompressionNode) forValue; if (op != other.op && encoding.equals(other.encoding)) { diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/NegateNodeCanonicalizationTest.java --- a/graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/NegateNodeCanonicalizationTest.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/NegateNodeCanonicalizationTest.java Tue Oct 14 16:09:04 2014 +0200 @@ -27,8 +27,8 @@ import org.junit.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; /** * This class tests that the canonicalization for constant negate nodes cover all cases. @@ -48,7 +48,7 @@ for (byte i : a) { ConstantNode node = ConstantNode.forByte(i, graph); Constant expected = Constant.forInt(-i); - assertEquals(expected, NegateNode.create(node).evalConst(node.asConstant())); + assertEquals(expected, ArithmeticOpTable.forStamp(node.stamp()).getNeg().foldConstant(node.asConstant())); } } @@ -58,7 +58,7 @@ for (char i : a) { ConstantNode node = ConstantNode.forChar(i, graph); Constant expected = Constant.forInt(-i); - assertEquals(expected, NegateNode.create(node).evalConst(node.asConstant())); + assertEquals(expected, ArithmeticOpTable.forStamp(node.stamp()).getNeg().foldConstant(node.asConstant())); } } @@ -68,7 +68,7 @@ for (short i : a) { ConstantNode node = ConstantNode.forShort(i, graph); Constant expected = Constant.forInt(-i); - assertEquals(expected, NegateNode.create(node).evalConst(node.asConstant())); + assertEquals(expected, ArithmeticOpTable.forStamp(node.stamp()).getNeg().foldConstant(node.asConstant())); } } @@ -78,7 +78,7 @@ for (int i : a) { ConstantNode node = ConstantNode.forInt(i, graph); Constant expected = Constant.forInt(-i); - assertEquals(expected, NegateNode.create(node).evalConst(node.asConstant())); + assertEquals(expected, ArithmeticOpTable.forStamp(node.stamp()).getNeg().foldConstant(node.asConstant())); } } @@ -88,7 +88,7 @@ for (long i : a) { ConstantNode node = ConstantNode.forLong(i, graph); Constant expected = Constant.forLong(-i); - assertEquals(expected, NegateNode.create(node).evalConst(node.asConstant())); + assertEquals(expected, ArithmeticOpTable.forStamp(node.stamp()).getNeg().foldConstant(node.asConstant())); } } @@ -98,7 +98,7 @@ for (float i : a) { ConstantNode node = ConstantNode.forFloat(i, graph); Constant expected = Constant.forFloat(-i); - assertEquals(expected, NegateNode.create(node).evalConst(node.asConstant())); + assertEquals(expected, ArithmeticOpTable.forStamp(node.stamp()).getNeg().foldConstant(node.asConstant())); } } @@ -108,7 +108,7 @@ for (double i : a) { ConstantNode node = ConstantNode.forDouble(i, graph); Constant expected = Constant.forDouble(-i); - assertEquals(expected, NegateNode.create(node).evalConst(node.asConstant())); + assertEquals(expected, ArithmeticOpTable.forStamp(node.stamp()).getNeg().foldConstant(node.asConstant())); } } diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BinaryArithmeticNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BinaryArithmeticNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BinaryArithmeticNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -56,12 +56,6 @@ } @Override - public Constant evalConst(Constant... inputs) { - assert inputs.length == 2; - return getOp(getX(), getY()).foldConstant(inputs[0], inputs[1]); - } - - @Override public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) { if (forX.isConstant() && forY.isConstant()) { Constant ret = getOp(forX, forY).foldConstant(forX.asConstant(), forY.asConstant()); diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -56,10 +56,5 @@ return isLossless(); } - default Constant evalConst(Constant... inputs) { - assert inputs.length == 1; - return convert(inputs[0]); - } - ValueNode asNode(); } diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/LeftShiftNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/LeftShiftNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/LeftShiftNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -46,14 +46,12 @@ return updateStamp(StampTool.leftShift(getX().stamp(), getY().stamp())); } - @Override - public Constant evalConst(Constant... inputs) { - assert inputs.length == 2; - if (getKind() == Kind.Int) { - return Constant.forInt(inputs[0].asInt() << inputs[1].asInt()); + private static Constant evalConst(Constant a, Constant b) { + if (a.getKind() == Kind.Int) { + return Constant.forInt(a.asInt() << b.asInt()); } else { - assert getKind() == Kind.Long; - return Constant.forLong(inputs[0].asLong() << inputs[1].asLong()); + assert a.getKind() == Kind.Long; + return Constant.forLong(a.asLong() << b.asLong()); } } diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ReinterpretNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ReinterpretNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ReinterpretNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -56,9 +56,7 @@ assert to instanceof PrimitiveStamp; } - public Constant evalConst(Constant... inputs) { - assert inputs.length == 1; - Constant c = inputs[0]; + private Constant evalConst(Constant c) { assert c.getKind().getBitCount() == ((PrimitiveStamp) stamp()).getBits(); switch (c.getKind()) { case Int: diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/RightShiftNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/RightShiftNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/RightShiftNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -47,14 +47,12 @@ return updateStamp(StampTool.rightShift(getX().stamp(), getY().stamp())); } - @Override - public Constant evalConst(Constant... inputs) { - assert inputs.length == 2; - if (getKind() == Kind.Int) { - return Constant.forInt(inputs[0].asInt() >> inputs[1].asInt()); + private static Constant evalConst(Constant a, Constant b) { + if (a.getKind() == Kind.Int) { + return Constant.forInt(a.asInt() >> b.asInt()); } else { - assert getKind() == Kind.Long; - return Constant.forLong(inputs[0].asLong() >> inputs[1].asLong()); + assert a.getKind() == Kind.Long; + return Constant.forLong(a.asLong() >> b.asLong()); } } diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnaryArithmeticNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnaryArithmeticNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnaryArithmeticNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -24,7 +24,6 @@ import java.util.function.*; -import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.compiler.common.type.ArithmeticOpTable.UnaryOp; import com.oracle.graal.graph.spi.*; @@ -46,11 +45,6 @@ return getOp.apply(ArithmeticOpTable.forStamp(forValue.stamp())); } - public Constant evalConst(Constant... inputs) { - assert inputs.length == 1; - return getOp(getValue()).foldConstant(inputs[0]); - } - @Override public boolean inferStamp() { return updateStamp(getOp(getValue()).foldStamp(getValue().stamp())); diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRightShiftNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRightShiftNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRightShiftNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -46,14 +46,12 @@ return updateStamp(StampTool.unsignedRightShift(getX().stamp(), getY().stamp())); } - @Override - public Constant evalConst(Constant... inputs) { - assert inputs.length == 2; - if (getKind() == Kind.Int) { - return Constant.forInt(inputs[0].asInt() >>> inputs[1].asInt()); + private static Constant evalConst(Constant a, Constant b) { + if (a.getKind() == Kind.Int) { + return Constant.forInt(a.asInt() >>> b.asInt()); } else { - assert getKind() == Kind.Long; - return Constant.forLong(inputs[0].asLong() >>> inputs[1].asLong()); + assert a.getKind() == Kind.Long; + return Constant.forLong(a.asLong() >>> b.asLong()); } } diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64FloatConvertNode.java --- a/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64FloatConvertNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64FloatConvertNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -22,8 +22,6 @@ */ package com.oracle.graal.replacements.amd64; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.common.type.ArithmeticOpTable.FloatConvertOp; import com.oracle.graal.graph.spi.*; @@ -53,12 +51,6 @@ } @Override - public Constant evalConst(Constant... inputs) { - // this node should never have been created if its input is constant - throw GraalInternalError.shouldNotReachHere(); - } - - @Override public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) { // nothing to do return this; diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathIntrinsicsNode.java --- a/graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathIntrinsicsNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathIntrinsicsNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -116,20 +116,13 @@ } /** - * Converts a constant to a boxed double. - */ - public Constant evalConst(Constant... inputs) { - assert inputs.length == 1; - return Constant.forDouble(compute(inputs[0].asDouble(), operation())); - } - - /** * Converts the result of the math operation to a boxed Double constant node. */ @Override public Node canonical(CanonicalizerTool tool) { if (getParameter().isConstant()) { - return ConstantNode.forPrimitive(evalConst(getParameter().asConstant())); + double ret = compute(getParameter().asConstant().asDouble(), operation()); + return ConstantNode.forDouble(ret); } return this; } diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MathIntrinsicNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MathIntrinsicNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MathIntrinsicNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -93,15 +93,11 @@ builder.setResult(this, result); } - public Constant evalConst(Constant... inputs) { - assert inputs.length == 1; - return Constant.forDouble(doCompute(inputs[0].asDouble(), operation())); - } - @Override public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) { if (forValue.isConstant()) { - return ConstantNode.forPrimitive(evalConst(forValue.asConstant())); + double ret = doCompute(forValue.asConstant().asDouble(), operation()); + return ConstantNode.forDouble(ret); } return this; } diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulHighNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulHighNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulHighNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -25,7 +25,6 @@ import java.util.function.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; @@ -54,19 +53,6 @@ super(stamp, x, y); } - @Override - public Constant evalConst(Constant... inputs) { - assert inputs.length == 2 && inputs[0].getKind() == inputs[1].getKind(); - switch (inputs[0].getKind()) { - case Int: - return Constant.forInt(ExactMath.multiplyHigh(inputs[0].asInt(), inputs[1].asInt())); - case Long: - return Constant.forLong(ExactMath.multiplyHigh(inputs[0].asLong(), inputs[1].asLong())); - default: - throw GraalInternalError.unimplemented(); - } - } - /** * Determines the minimum and maximum result of this node for the given inputs and returns the * result of the given BiFunction on the minimum and maximum values. diff -r 2ea20d64ab5c -r b0e8bc17af1b graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/UnsignedMulHighNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/UnsignedMulHighNode.java Tue Oct 14 14:11:32 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/UnsignedMulHighNode.java Tue Oct 14 16:09:04 2014 +0200 @@ -25,7 +25,6 @@ import java.util.function.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.lir.gen.*; @@ -54,19 +53,6 @@ super(stamp, x, y); } - @Override - public Constant evalConst(Constant... inputs) { - assert inputs.length == 2 && inputs[0].getKind() == inputs[1].getKind(); - switch (inputs[0].getKind()) { - case Int: - return Constant.forInt(ExactMath.multiplyHighUnsigned(inputs[0].asInt(), inputs[1].asInt())); - case Long: - return Constant.forLong(ExactMath.multiplyHighUnsigned(inputs[0].asLong(), inputs[1].asLong())); - default: - throw GraalInternalError.unimplemented(); - } - } - /** * Determines the minimum and maximum result of this node for the given inputs and returns the * result of the given BiFunction on the minimum and maximum values. Note that the minima and