Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/PointerEqualsNode.java @ 19526:8fc336a04d77
Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 20 Feb 2015 22:22:55 +0100 |
parents | 880717e44675 |
children | d5042bcd422f |
rev | line source |
---|---|
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
19151
f41186c896cd
More folding on creation for object equality node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19115
diff
changeset
|
2 * Copyright (c) 2011, 2015, 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 |
15200
97eed257999b
Move Condition to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
25 import com.oracle.graal.compiler.common.calc.*; |
18360
6a5dc0bbebe7
Introduce PointerEqualsNode for metaspace pointer comparison.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
26 import com.oracle.graal.compiler.common.type.*; |
19396
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19151
diff
changeset
|
27 import com.oracle.graal.graph.*; |
11881
da9db8331658
moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11880
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:
15260
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 = "==") |
18360
6a5dc0bbebe7
Introduce PointerEqualsNode for metaspace pointer comparison.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
34 public class PointerEqualsNode extends CompareNode { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
35 |
19526
8fc336a04d77
Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19471
diff
changeset
|
36 public static final NodeClass<PointerEqualsNode> TYPE = NodeClass.create(PointerEqualsNode.class); |
19396
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19151
diff
changeset
|
37 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18490
diff
changeset
|
38 public PointerEqualsNode(ValueNode x, ValueNode y) { |
19396
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19151
diff
changeset
|
39 this(TYPE, x, y); |
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19151
diff
changeset
|
40 } |
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19151
diff
changeset
|
41 |
19471
880717e44675
Use typed NodeClass in node constructors.
Roland Schatz <roland.schatz@oracle.com>
parents:
19403
diff
changeset
|
42 protected PointerEqualsNode(NodeClass<? extends PointerEqualsNode> c, ValueNode x, ValueNode y) { |
19396
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19151
diff
changeset
|
43 super(c, Condition.EQ, false, x, y); |
18360
6a5dc0bbebe7
Introduce PointerEqualsNode for metaspace pointer comparison.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
44 assert x.stamp() instanceof AbstractPointerStamp; |
6a5dc0bbebe7
Introduce PointerEqualsNode for metaspace pointer comparison.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
45 assert y.stamp() instanceof AbstractPointerStamp; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
46 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
47 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
48 @Override |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
49 public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) { |
19151
f41186c896cd
More folding on creation for object equality node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19115
diff
changeset
|
50 LogicNode result = findSynonym(forX, forY); |
f41186c896cd
More folding on creation for object equality node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19115
diff
changeset
|
51 if (result != null) { |
f41186c896cd
More folding on creation for object equality node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19115
diff
changeset
|
52 return result; |
f41186c896cd
More folding on creation for object equality node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19115
diff
changeset
|
53 } |
f41186c896cd
More folding on creation for object equality node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19115
diff
changeset
|
54 return super.canonical(tool, forX, forY); |
f41186c896cd
More folding on creation for object equality node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19115
diff
changeset
|
55 } |
f41186c896cd
More folding on creation for object equality node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19115
diff
changeset
|
56 |
f41186c896cd
More folding on creation for object equality node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19115
diff
changeset
|
57 public static LogicNode findSynonym(ValueNode forX, ValueNode forY) { |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
58 if (GraphUtil.unproxify(forX) == GraphUtil.unproxify(forY)) { |
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
59 return LogicConstantNode.tautology(); |
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
60 } else if (forX.stamp().alwaysDistinct(forY.stamp())) { |
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
61 return LogicConstantNode.contradiction(); |
18490
ca81508f2a19
Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18360
diff
changeset
|
62 } else if (((AbstractPointerStamp) forX.stamp()).alwaysNull()) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18490
diff
changeset
|
63 return new IsNullNode(forY); |
18490
ca81508f2a19
Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18360
diff
changeset
|
64 } else if (((AbstractPointerStamp) forY.stamp()).alwaysNull()) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18490
diff
changeset
|
65 return new IsNullNode(forX); |
19151
f41186c896cd
More folding on creation for object equality node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19115
diff
changeset
|
66 } else { |
f41186c896cd
More folding on creation for object equality node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19115
diff
changeset
|
67 return null; |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
68 } |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
5831
diff
changeset
|
69 } |
15961
d5b824a41530
CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15349
diff
changeset
|
70 |
d5b824a41530
CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15349
diff
changeset
|
71 @Override |
d5b824a41530
CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15349
diff
changeset
|
72 protected CompareNode duplicateModified(ValueNode newX, ValueNode newY) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18490
diff
changeset
|
73 return new PointerEqualsNode(newX, newY); |
15961
d5b824a41530
CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15349
diff
changeset
|
74 } |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
75 } |