Mercurial > hg > graal-compiler
comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/XorNode.java @ 16895:06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 18 Aug 2014 14:04:21 +0200 |
parents | cbd42807a31f |
children | 0fe4732e5181 |
comparison
equal
deleted
inserted
replaced
16894:cc7aaa92c27d | 16895:06c15e88d383 |
---|---|
33 import com.oracle.graal.nodes.util.*; | 33 import com.oracle.graal.nodes.util.*; |
34 | 34 |
35 @NodeInfo(shortName = "^") | 35 @NodeInfo(shortName = "^") |
36 public class XorNode extends BitLogicNode { | 36 public class XorNode extends BitLogicNode { |
37 | 37 |
38 public XorNode(ValueNode x, ValueNode y) { | 38 public static XorNode create(ValueNode x, ValueNode y) { |
39 return new XorNodeGen(x, y); | |
40 } | |
41 | |
42 public static Class<? extends XorNode> getGenClass() { | |
43 return XorNodeGen.class; | |
44 } | |
45 | |
46 protected XorNode(ValueNode x, ValueNode y) { | |
39 super(StampTool.xor(x.stamp(), y.stamp()), x, y); | 47 super(StampTool.xor(x.stamp(), y.stamp()), x, y); |
40 assert x.stamp().isCompatible(y.stamp()); | 48 assert x.stamp().isCompatible(y.stamp()); |
41 } | 49 } |
42 | 50 |
43 @Override | 51 @Override |
55 public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) { | 63 public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) { |
56 if (GraphUtil.unproxify(forX) == GraphUtil.unproxify(forY)) { | 64 if (GraphUtil.unproxify(forX) == GraphUtil.unproxify(forY)) { |
57 return ConstantNode.forIntegerStamp(stamp(), 0); | 65 return ConstantNode.forIntegerStamp(stamp(), 0); |
58 } | 66 } |
59 if (forX.isConstant() && !forY.isConstant()) { | 67 if (forX.isConstant() && !forY.isConstant()) { |
60 return new XorNode(forY, forX); | 68 return XorNode.create(forY, forX); |
61 } | 69 } |
62 if (forX.isConstant()) { | 70 if (forX.isConstant()) { |
63 return ConstantNode.forPrimitive(stamp(), evalConst(forX.asConstant(), forY.asConstant())); | 71 return ConstantNode.forPrimitive(stamp(), evalConst(forX.asConstant(), forY.asConstant())); |
64 } else if (forY.isConstant()) { | 72 } else if (forY.isConstant()) { |
65 long rawY = forY.asConstant().asLong(); | 73 long rawY = forY.asConstant().asLong(); |
66 long mask = IntegerStamp.defaultMask(PrimitiveStamp.getBits(stamp())); | 74 long mask = IntegerStamp.defaultMask(PrimitiveStamp.getBits(stamp())); |
67 if ((rawY & mask) == 0) { | 75 if ((rawY & mask) == 0) { |
68 return forX; | 76 return forX; |
69 } else if ((rawY & mask) == mask) { | 77 } else if ((rawY & mask) == mask) { |
70 return new NotNode(forX); | 78 return NotNode.create(forX); |
71 } | 79 } |
72 return BinaryNode.reassociate(this, ValueNode.isConstantPredicate(), forX, forY); | 80 return BinaryNode.reassociate(this, ValueNode.isConstantPredicate(), forX, forY); |
73 } | 81 } |
74 return this; | 82 return this; |
75 } | 83 } |