Mercurial > hg > graal-compiler
comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerMulNode.java @ 5540:a891c53a295b
Renaming RiKind => Kind.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 08 Jun 2012 23:47:42 +0200 |
parents | bc647d8b0080 |
children | b6617d13ea44 |
comparison
equal
deleted
inserted
replaced
5539:bc647d8b0080 | 5540:a891c53a295b |
---|---|
29 import com.oracle.graal.nodes.spi.*; | 29 import com.oracle.graal.nodes.spi.*; |
30 | 30 |
31 @NodeInfo(shortName = "*") | 31 @NodeInfo(shortName = "*") |
32 public final class IntegerMulNode extends IntegerArithmeticNode implements Canonicalizable, LIRLowerable { | 32 public final class IntegerMulNode extends IntegerArithmeticNode implements Canonicalizable, LIRLowerable { |
33 | 33 |
34 public IntegerMulNode(RiKind kind, ValueNode x, ValueNode y) { | 34 public IntegerMulNode(Kind kind, ValueNode x, ValueNode y) { |
35 super(kind, x, y); | 35 super(kind, x, y); |
36 } | 36 } |
37 | 37 |
38 @Override | 38 @Override |
39 public ValueNode canonical(CanonicalizerTool tool) { | 39 public ValueNode canonical(CanonicalizerTool tool) { |
40 if (x().isConstant() && !y().isConstant()) { | 40 if (x().isConstant() && !y().isConstant()) { |
41 return graph().unique(new IntegerMulNode(kind(), y(), x())); | 41 return graph().unique(new IntegerMulNode(kind(), y(), x())); |
42 } | 42 } |
43 if (x().isConstant()) { | 43 if (x().isConstant()) { |
44 if (kind() == RiKind.Int) { | 44 if (kind() == Kind.Int) { |
45 return ConstantNode.forInt(x().asConstant().asInt() * y().asConstant().asInt(), graph()); | 45 return ConstantNode.forInt(x().asConstant().asInt() * y().asConstant().asInt(), graph()); |
46 } else { | 46 } else { |
47 assert kind() == RiKind.Long; | 47 assert kind() == Kind.Long; |
48 return ConstantNode.forLong(x().asConstant().asLong() * y().asConstant().asLong(), graph()); | 48 return ConstantNode.forLong(x().asConstant().asLong() * y().asConstant().asLong(), graph()); |
49 } | 49 } |
50 } else if (y().isConstant()) { | 50 } else if (y().isConstant()) { |
51 long c = y().asConstant().asLong(); | 51 long c = y().asConstant().asLong(); |
52 if (c == 1) { | 52 if (c == 1) { |
61 // canonicalize expressions like "(a * 1) * 2" | 61 // canonicalize expressions like "(a * 1) * 2" |
62 if (x() instanceof IntegerMulNode) { | 62 if (x() instanceof IntegerMulNode) { |
63 IntegerMulNode other = (IntegerMulNode) x(); | 63 IntegerMulNode other = (IntegerMulNode) x(); |
64 if (other.y().isConstant()) { | 64 if (other.y().isConstant()) { |
65 ConstantNode sum; | 65 ConstantNode sum; |
66 if (kind() == RiKind.Int) { | 66 if (kind() == Kind.Int) { |
67 sum = ConstantNode.forInt(y().asConstant().asInt() * other.y().asConstant().asInt(), graph()); | 67 sum = ConstantNode.forInt(y().asConstant().asInt() * other.y().asConstant().asInt(), graph()); |
68 } else { | 68 } else { |
69 assert kind() == RiKind.Long; | 69 assert kind() == Kind.Long; |
70 sum = ConstantNode.forLong(y().asConstant().asLong() * other.y().asConstant().asLong(), graph()); | 70 sum = ConstantNode.forLong(y().asConstant().asLong() * other.y().asConstant().asLong(), graph()); |
71 } | 71 } |
72 return graph().unique(new IntegerMulNode(kind(), other.x(), sum)); | 72 return graph().unique(new IntegerMulNode(kind(), other.x(), sum)); |
73 } | 73 } |
74 } | 74 } |