Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatEqualsNode.java @ 19114:b1dbba1f3f03
Restructure CompareNode. Create constant fold utility, store condition as data field.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 04 Feb 2015 02:28:28 +0100 |
parents | f57d86eb036f |
children | 1d33f713897d |
rev | line source |
---|---|
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16006
diff
changeset
|
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
4 * |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
8 * |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
14 * |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
18 * |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
21 * questions. |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
22 */ |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.nodes.calc; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
24 |
15975
0ad889977080
CompareNode.canonicalizeSymmetricConstant can lead to float<->int changes so the right type of node needs to be created depending on the inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15961
diff
changeset
|
25 import com.oracle.graal.compiler.common.*; |
15200
97eed257999b
Move Condition to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
14024
diff
changeset
|
26 import com.oracle.graal.compiler.common.calc.*; |
15261
882f4cb7cfcf
Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15200
diff
changeset
|
27 import com.oracle.graal.compiler.common.type.*; |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16006
diff
changeset
|
28 import com.oracle.graal.graph.spi.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16822
diff
changeset
|
29 import com.oracle.graal.nodeinfo.*; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
30 import com.oracle.graal.nodes.*; |
15349
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
31 import com.oracle.graal.nodes.util.*; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
32 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 @NodeInfo(shortName = "==") |
16822
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16212
diff
changeset
|
34 public class FloatEqualsNode extends CompareNode { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
35 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
17450
diff
changeset
|
36 public FloatEqualsNode(ValueNode x, ValueNode y) { |
19114
b1dbba1f3f03
Restructure CompareNode. Create constant fold utility, store condition as data field.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
37 super(Condition.EQ, x, y); |
16006
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15975
diff
changeset
|
38 assert x.stamp() instanceof FloatStamp && y.stamp() instanceof FloatStamp : x.stamp() + " " + y.stamp(); |
14024
34c07ef28bc9
Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
39 assert x.stamp().isCompatible(y.stamp()); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
40 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
41 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 @Override |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
43 public boolean unorderedIsTrue() { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
44 return false; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
45 } |
15349
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
46 |
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
47 @Override |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16006
diff
changeset
|
48 public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) { |
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16006
diff
changeset
|
49 ValueNode result = super.canonical(tool, forX, forY); |
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16006
diff
changeset
|
50 if (result != this) { |
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16006
diff
changeset
|
51 return result; |
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16006
diff
changeset
|
52 } |
15349
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
53 if (forX.stamp() instanceof FloatStamp && forY.stamp() instanceof FloatStamp) { |
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
54 FloatStamp xStamp = (FloatStamp) forX.stamp(); |
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
55 FloatStamp yStamp = (FloatStamp) forY.stamp(); |
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
56 if (GraphUtil.unproxify(forX) == GraphUtil.unproxify(forY) && xStamp.isNonNaN() && yStamp.isNonNaN()) { |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16006
diff
changeset
|
57 return LogicConstantNode.tautology(); |
15349
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
58 } else if (xStamp.alwaysDistinct(yStamp)) { |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16006
diff
changeset
|
59 return LogicConstantNode.contradiction(); |
15349
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
60 } |
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
61 } |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16006
diff
changeset
|
62 return this; |
15349
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
63 } |
15961
d5b824a41530
CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15349
diff
changeset
|
64 |
d5b824a41530
CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15349
diff
changeset
|
65 @Override |
d5b824a41530
CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15349
diff
changeset
|
66 protected CompareNode duplicateModified(ValueNode newX, ValueNode newY) { |
15975
0ad889977080
CompareNode.canonicalizeSymmetricConstant can lead to float<->int changes so the right type of node needs to be created depending on the inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15961
diff
changeset
|
67 if (newX.stamp() instanceof FloatStamp && newY.stamp() instanceof FloatStamp) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
17450
diff
changeset
|
68 return new FloatEqualsNode(newX, newY); |
15975
0ad889977080
CompareNode.canonicalizeSymmetricConstant can lead to float<->int changes so the right type of node needs to be created depending on the inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15961
diff
changeset
|
69 } else if (newX.stamp() instanceof IntegerStamp && newY.stamp() instanceof IntegerStamp) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
17450
diff
changeset
|
70 return new IntegerEqualsNode(newX, newY); |
15975
0ad889977080
CompareNode.canonicalizeSymmetricConstant can lead to float<->int changes so the right type of node needs to be created depending on the inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15961
diff
changeset
|
71 } |
0ad889977080
CompareNode.canonicalizeSymmetricConstant can lead to float<->int changes so the right type of node needs to be created depending on the inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15961
diff
changeset
|
72 throw GraalInternalError.shouldNotReachHere(); |
15961
d5b824a41530
CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15349
diff
changeset
|
73 } |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
74 } |