comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRemNode.java @ 16218:c3260b05fd26

rename x() to getX() and y() to getY() in FixedBinaryNode
author Lukas Stadler <lukas.stadler@oracle.com>
date Wed, 25 Jun 2014 16:55:00 +0200
parents 561070049e73
children 1434b835f0d3
comparison
equal deleted inserted replaced
16217:561070049e73 16218:c3260b05fd26
36 super(x.stamp().unrestricted(), x, y); 36 super(x.stamp().unrestricted(), x, y);
37 } 37 }
38 38
39 @Override 39 @Override
40 public Node canonical(CanonicalizerTool tool) { 40 public Node canonical(CanonicalizerTool tool) {
41 if (x().isConstant() && y().isConstant()) { 41 if (getX().isConstant() && getY().isConstant()) {
42 long yConst = y().asConstant().asLong(); 42 long yConst = getY().asConstant().asLong();
43 if (yConst == 0) { 43 if (yConst == 0) {
44 return this; // this will trap, cannot canonicalize 44 return this; // this will trap, cannot canonicalize
45 } 45 }
46 return ConstantNode.forIntegerStamp(stamp(), UnsignedMath.remainder(x().asConstant().asLong(), yConst), graph()); 46 return ConstantNode.forIntegerStamp(stamp(), UnsignedMath.remainder(getX().asConstant().asLong(), yConst), graph());
47 } else if (y().isConstant()) { 47 } else if (getY().isConstant()) {
48 long c = y().asConstant().asLong(); 48 long c = getY().asConstant().asLong();
49 if (c == 1) { 49 if (c == 1) {
50 return ConstantNode.forIntegerStamp(stamp(), 0); 50 return ConstantNode.forIntegerStamp(stamp(), 0);
51 } else if (CodeUtil.isPowerOf2(c)) { 51 } else if (CodeUtil.isPowerOf2(c)) {
52 return new AndNode(x(), ConstantNode.forIntegerStamp(stamp(), c - 1)); 52 return new AndNode(getX(), ConstantNode.forIntegerStamp(stamp(), c - 1));
53 } 53 }
54 } 54 }
55 return this; 55 return this;
56 } 56 }
57 57
60 tool.getLowerer().lower(this, tool); 60 tool.getLowerer().lower(this, tool);
61 } 61 }
62 62
63 @Override 63 @Override
64 public void generate(NodeLIRBuilderTool gen) { 64 public void generate(NodeLIRBuilderTool gen) {
65 gen.setResult(this, gen.getLIRGeneratorTool().emitURem(gen.operand(x()), gen.operand(y()), gen.state(this))); 65 gen.setResult(this, gen.getLIRGeneratorTool().emitURem(gen.operand(getX()), gen.operand(getY()), gen.state(this)));
66 } 66 }
67 67
68 @Override 68 @Override
69 public boolean canDeoptimize() { 69 public boolean canDeoptimize() {
70 return !(y().stamp() instanceof IntegerStamp) || ((IntegerStamp) y().stamp()).contains(0); 70 return !(getY().stamp() instanceof IntegerStamp) || ((IntegerStamp) getY().stamp()).contains(0);
71 } 71 }
72 72
73 @NodeIntrinsic 73 @NodeIntrinsic
74 public static native int unsignedRemainder(int a, int b); 74 public static native int unsignedRemainder(int a, int b);
75 75