annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java @ 5402:80127e4a1742

remove Condition.OF and Condition.NOF
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 15 May 2012 14:22:01 +0200
parents 0ebd9cfdc11f
children 0364a2a874b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.nodes.calc;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
4199
aaac4894175c Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4142
diff changeset
25 import com.oracle.max.cri.ci.*;
aaac4894175c Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4142
diff changeset
26 import com.oracle.max.cri.ri.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
27 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
28 import com.oracle.graal.nodes.spi.*;
5083
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
29 import com.oracle.graal.nodes.spi.types.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
30 import com.oracle.graal.nodes.type.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
5056
2f2c6347fce4 comments cleanup/retagging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4550
diff changeset
32 /* TODO (thomaswue/gdub) For high-level optimization purpose the compare node should be a boolean *value* (it is currently only a helper node)
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 * But in the back-end the comparison should not always be materialized (for example in x86 the comparison result will not be in a register but in a flag)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 * Compare should probably be made a value (so that it can be canonicalized for example) and in later stages some Compare usage should be transformed
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 * into variants that do not materialize the value (CompareIf, CompareGuard...)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 */
5083
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
38 public final class CompareNode extends BooleanNode implements Canonicalizable, LIRLowerable, ConditionalTypeFeedbackProvider, TypeCanonicalizable {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 @Input private ValueNode x;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 @Input private ValueNode y;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42
5299
0ebd9cfdc11f removed @Data annotation
Lukas Stadler <lukas.stadler@jku.at>
parents: 5083
diff changeset
43 private final Condition condition;
0ebd9cfdc11f removed @Data annotation
Lukas Stadler <lukas.stadler@jku.at>
parents: 5083
diff changeset
44 private final boolean unorderedIsTrue;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 public ValueNode x() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 return x;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 public ValueNode y() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 return y;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 * Constructs a new Compare instruction.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 * @param x the instruction producing the first input to the instruction
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 * @param condition the condition (comparison operation)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 * @param y the instruction that produces the second input to this instruction
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 * @param graph
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 public CompareNode(ValueNode x, Condition condition, ValueNode y) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 this(x, condition, false, y);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 * Constructs a new Compare instruction.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 * @param x the instruction producing the first input to the instruction
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 * @param condition the condition (comparison operation)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 * @param y the instruction that produces the second input to this instruction
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 * @param graph
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 public CompareNode(ValueNode x, Condition condition, boolean unorderedIsTrue, ValueNode y) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 super(StampFactory.illegal());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76 assert (x == null && y == null) || x.kind() == y.kind();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 this.condition = condition;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 this.unorderedIsTrue = unorderedIsTrue;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 this.x = x;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 this.y = y;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 * Gets the condition (comparison operation) for this instruction.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 * @return the condition
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88 public Condition condition() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89 return condition;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
90 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
92 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93 * Checks whether unordered inputs mean true or false.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 * @return {@code true} if unordered inputs produce true
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
96 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 public boolean unorderedIsTrue() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98 return unorderedIsTrue;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
101 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102 public BooleanNode negate() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103 return graph().unique(new CompareNode(x(), condition.negate(), !unorderedIsTrue, y()));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 public void generate(LIRGeneratorTool gen) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 public String toString(Verbosity verbosity) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 if (verbosity == Verbosity.Name) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 return super.toString(Verbosity.Name) + " " + condition.operator;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115 return super.toString(verbosity);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118
4309
4a609a685fa4 changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents: 4199
diff changeset
119 private ValueNode optimizeMaterialize(CiConstant constant, MaterializeNode materializeNode, RiRuntime runtime) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120 CiConstant trueConstant = materializeNode.trueValue().asConstant();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 CiConstant falseConstant = materializeNode.falseValue().asConstant();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 if (falseConstant != null && trueConstant != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 Boolean trueResult = condition().foldCondition(trueConstant, constant, runtime, unorderedIsTrue());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 Boolean falseResult = condition().foldCondition(falseConstant, constant, runtime, unorderedIsTrue());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 if (trueResult != null && falseResult != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 boolean trueUnboxedResult = trueResult;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 boolean falseUnboxedResult = falseResult;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 if (trueUnboxedResult == falseUnboxedResult) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131 return ConstantNode.forBoolean(trueUnboxedResult, graph());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 if (trueUnboxedResult) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134 assert falseUnboxedResult == false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 return materializeNode.condition();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 assert falseUnboxedResult == true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 return materializeNode.condition().negate();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 return this;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146
4309
4a609a685fa4 changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents: 4199
diff changeset
147 private ValueNode optimizeNormalizeCmp(CiConstant constant, NormalizeCompareNode normalizeNode) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148 if (constant.kind == CiKind.Int && constant.asInt() == 0) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
149 Condition cond = condition();
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
150 boolean isLess = cond == Condition.LE || cond == Condition.LT || cond == Condition.BE || cond == Condition.BT;
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
151 boolean canonUnorderedIsTrue = cond != Condition.EQ && (cond == Condition.NE || !(isLess ^ normalizeNode.isUnorderedLess));
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
152 CompareNode result = graph().unique(new CompareNode(normalizeNode.x(), cond, canonUnorderedIsTrue, normalizeNode.y()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155 return this;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 @Override
4309
4a609a685fa4 changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents: 4199
diff changeset
159 public ValueNode canonical(CanonicalizerTool tool) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160 if (x().isConstant() && !y().isConstant()) { // move constants to the left (y)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
161 return graph().unique(new CompareNode(y(), condition.mirror(), unorderedIsTrue(), x()));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
162 } else if (x().isConstant() && y().isConstant()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 CiConstant constX = x().asConstant();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
164 CiConstant constY = y().asConstant();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
165 Boolean result = condition().foldCondition(constX, constY, tool.runtime(), unorderedIsTrue());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
166 if (result != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
167 return ConstantNode.forBoolean(result, graph());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 if (y().isConstant()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172 if (x() instanceof MaterializeNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173 return optimizeMaterialize(y().asConstant(), (MaterializeNode) x(), tool.runtime());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 } else if (x() instanceof NormalizeCompareNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 return optimizeNormalizeCmp(y().asConstant(), (NormalizeCompareNode) x());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 if (x() == y() && x().kind() != CiKind.Float && x().kind() != CiKind.Double) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180 return ConstantNode.forBoolean(condition().check(1, 1), graph());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
182 if ((condition == Condition.NE || condition == Condition.EQ) && x().kind() == CiKind.Object) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183 ValueNode object = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 if (x().isNullConstant()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 object = y();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 } else if (y().isNullConstant()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187 object = x();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
189 if (object != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 return graph().unique(new NullCheckNode(object, condition == Condition.EQ));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192 Stamp xStamp = x.stamp();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 Stamp yStamp = y.stamp();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194 if (xStamp.alwaysDistinct(yStamp)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195 return ConstantNode.forBoolean(condition == Condition.NE, graph());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
199 return this;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
200 }
5083
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
201
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
202 @Override
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
203 public void typeFeedback(TypeFeedbackTool tool) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
204 CiKind kind = x().kind();
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
205 assert y().kind() == kind;
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
206 if (kind == CiKind.Object) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
207 assert condition == Condition.EQ || condition == Condition.NE;
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
208 if (y().isConstant() && !x().isConstant()) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
209 tool.addObject(x()).constantBound(condition, y().asConstant());
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
210 } else if (x().isConstant() && !y().isConstant()) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
211 tool.addObject(y()).constantBound(condition.mirror(), x().asConstant());
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
212 } else if (!x().isConstant() && !y.isConstant()) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
213 tool.addObject(x()).valueBound(condition, y());
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
214 tool.addObject(y()).valueBound(condition.mirror(), x());
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
215 } else {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
216 // both are constant, this should be canonicalized...
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
217 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
218 } else if (kind == CiKind.Int || kind == CiKind.Long) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
219 if (y().isConstant() && !x().isConstant()) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
220 tool.addScalar(x()).constantBound(condition, y().asConstant());
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
221 } else if (x().isConstant() && !y().isConstant()) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
222 tool.addScalar(y()).constantBound(condition.mirror(), x().asConstant());
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
223 } else if (!x().isConstant() && !y.isConstant()) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
224 tool.addScalar(x()).valueBound(condition, y(), tool.queryScalar(y()));
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
225 tool.addScalar(y()).valueBound(condition.mirror(), x(), tool.queryScalar(x()));
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
226 } else {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
227 // both are constant, this should be canonicalized...
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
228 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
229 } else if (kind == CiKind.Float || kind == CiKind.Double) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
230 // nothing yet...
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
231 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
232 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
233
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
234 @Override
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
235 public Result canonical(TypeFeedbackTool tool) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
236 CiKind kind = x().kind();
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
237 if (kind == CiKind.Int || kind == CiKind.Long) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
238 ScalarTypeQuery queryX = tool.queryScalar(x());
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
239 if (y().isConstant() && !x().isConstant()) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
240 if (queryX.constantBound(condition, y().asConstant())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
241 return new Result(ConstantNode.forBoolean(true, graph()), queryX);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
242 } else if (queryX.constantBound(condition.negate(), y().asConstant())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
243 return new Result(ConstantNode.forBoolean(false, graph()), queryX);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
244 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
245 } else {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
246 ScalarTypeQuery queryY = tool.queryScalar(y());
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
247 if (x().isConstant() && !y().isConstant()) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
248 if (queryY.constantBound(condition.mirror(), x().asConstant())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
249 return new Result(ConstantNode.forBoolean(true, graph()), queryY);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
250 } else if (queryY.constantBound(condition.mirror().negate(), x().asConstant())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
251 return new Result(ConstantNode.forBoolean(false, graph()), queryY);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
252 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
253 } else if (!x().isConstant() && !y.isConstant()) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
254 if (condition == Condition.BT || condition == Condition.BE) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
255 if (queryY.constantBound(Condition.GE, new CiConstant(kind, 0))) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
256 if (queryX.constantBound(Condition.GE, new CiConstant(kind, 0))) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
257 if (queryX.valueBound(condition == Condition.BT ? Condition.LT : Condition.LE, y())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
258 return new Result(ConstantNode.forBoolean(true, graph()), queryX, queryY);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
259 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
260 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
261 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
262 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
263
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
264 if (queryX.valueBound(condition, y())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
265 return new Result(ConstantNode.forBoolean(true, graph()), queryX);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
266 } else if (queryX.valueBound(condition.negate(), y())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
267 return new Result(ConstantNode.forBoolean(false, graph()), queryX);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
268 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
269 } else {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
270 // both are constant, this should be canonicalized...
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
271 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
272 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
273 } else if (kind == CiKind.Object) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
274 assert condition == Condition.EQ || condition == Condition.NE;
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
275 ObjectTypeQuery queryX = tool.queryObject(x());
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
276 if (y().isConstant() && !x().isConstant()) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
277 if (queryX.constantBound(condition, y().asConstant())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
278 return new Result(ConstantNode.forBoolean(true, graph()), queryX);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
279 } else if (queryX.constantBound(condition.negate(), y().asConstant())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
280 return new Result(ConstantNode.forBoolean(false, graph()), queryX);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
281 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
282 } else {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
283 ObjectTypeQuery queryY = tool.queryObject(y());
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
284 if (x().isConstant() && !y().isConstant()) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
285 if (queryY.constantBound(condition.mirror(), x().asConstant())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
286 return new Result(ConstantNode.forBoolean(true, graph()), queryY);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
287 } else if (queryY.constantBound(condition.mirror().negate(), x().asConstant())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
288 return new Result(ConstantNode.forBoolean(false, graph()), queryY);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
289 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
290 } else if (!x().isConstant() && !y.isConstant()) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
291 if (queryX.valueBound(condition, y())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
292 return new Result(ConstantNode.forBoolean(true, graph()), queryX);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
293 } else if (queryX.valueBound(condition.negate(), y())) {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
294 return new Result(ConstantNode.forBoolean(false, graph()), queryX);
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
295 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
296 } else {
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
297 // both are constant, this should be canonicalized...
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
298 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
299 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
300 }
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
301 return null;
1093243c09ad experimental type storage/query infrastructure, part 3:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
302 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
303 }