43972
|
1 |
/*
|
|
2 |
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
|
23 |
package org.graalvm.compiler.nodes.calc;
|
|
24 |
|
48861
|
25 |
import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_2;
|
|
26 |
|
|
27 |
import org.graalvm.compiler.core.common.calc.CanonicalCondition;
|
43972
|
28 |
import org.graalvm.compiler.core.common.type.FloatStamp;
|
|
29 |
import org.graalvm.compiler.core.common.type.IntegerStamp;
|
|
30 |
import org.graalvm.compiler.core.common.type.Stamp;
|
|
31 |
import org.graalvm.compiler.debug.GraalError;
|
46393
|
32 |
import org.graalvm.compiler.graph.Node;
|
43972
|
33 |
import org.graalvm.compiler.graph.NodeClass;
|
|
34 |
import org.graalvm.compiler.graph.spi.CanonicalizerTool;
|
|
35 |
import org.graalvm.compiler.nodeinfo.NodeInfo;
|
|
36 |
import org.graalvm.compiler.nodes.LogicConstantNode;
|
|
37 |
import org.graalvm.compiler.nodes.LogicNode;
|
48190
|
38 |
import org.graalvm.compiler.nodes.NodeView;
|
43972
|
39 |
import org.graalvm.compiler.nodes.ValueNode;
|
|
40 |
import org.graalvm.compiler.nodes.util.GraphUtil;
|
46393
|
41 |
import org.graalvm.compiler.options.OptionValues;
|
43972
|
42 |
|
48861
|
43 |
import jdk.vm.ci.meta.ConstantReflectionProvider;
|
|
44 |
import jdk.vm.ci.meta.MetaAccessProvider;
|
|
45 |
import jdk.vm.ci.meta.TriState;
|
43972
|
46 |
|
46393
|
47 |
@NodeInfo(shortName = "<", cycles = CYCLES_2)
|
43972
|
48 |
public final class FloatLessThanNode extends CompareNode {
|
|
49 |
public static final NodeClass<FloatLessThanNode> TYPE = NodeClass.create(FloatLessThanNode.class);
|
46393
|
50 |
private static final FloatLessThanOp OP = new FloatLessThanOp();
|
43972
|
51 |
|
|
52 |
public FloatLessThanNode(ValueNode x, ValueNode y, boolean unorderedIsTrue) {
|
48861
|
53 |
super(TYPE, CanonicalCondition.LT, unorderedIsTrue, x, y);
|
48190
|
54 |
assert x.stamp(NodeView.DEFAULT) instanceof FloatStamp && y.stamp(NodeView.DEFAULT) instanceof FloatStamp;
|
|
55 |
assert x.stamp(NodeView.DEFAULT).isCompatible(y.stamp(NodeView.DEFAULT));
|
43972
|
56 |
}
|
|
57 |
|
48190
|
58 |
public static LogicNode create(ValueNode x, ValueNode y, boolean unorderedIsTrue, NodeView view) {
|
48861
|
59 |
LogicNode result = CompareNode.tryConstantFoldPrimitive(CanonicalCondition.LT, x, y, unorderedIsTrue, view);
|
43972
|
60 |
if (result != null) {
|
|
61 |
return result;
|
|
62 |
}
|
46393
|
63 |
return new FloatLessThanNode(x, y, unorderedIsTrue);
|
|
64 |
}
|
|
65 |
|
|
66 |
public static LogicNode create(ConstantReflectionProvider constantReflection, MetaAccessProvider metaAccess, OptionValues options, Integer smallestCompareWidth,
|
48190
|
67 |
ValueNode x, ValueNode y, boolean unorderedIsTrue, NodeView view) {
|
48861
|
68 |
LogicNode result = OP.canonical(constantReflection, metaAccess, options, smallestCompareWidth, CanonicalCondition.LT, unorderedIsTrue, x, y, view);
|
46393
|
69 |
if (result != null) {
|
|
70 |
return result;
|
|
71 |
}
|
48190
|
72 |
return create(x, y, unorderedIsTrue, view);
|
43972
|
73 |
}
|
|
74 |
|
|
75 |
@Override
|
46393
|
76 |
public Node canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
|
48190
|
77 |
NodeView view = NodeView.from(tool);
|
48861
|
78 |
ValueNode value = OP.canonical(tool.getConstantReflection(), tool.getMetaAccess(), tool.getOptions(), tool.smallestCompareWidth(), CanonicalCondition.LT, unorderedIsTrue, forX, forY, view);
|
46393
|
79 |
if (value != null) {
|
|
80 |
return value;
|
43972
|
81 |
}
|
|
82 |
return this;
|
|
83 |
}
|
|
84 |
|
46393
|
85 |
public static class FloatLessThanOp extends CompareOp {
|
|
86 |
|
|
87 |
@Override
|
48861
|
88 |
public LogicNode canonical(ConstantReflectionProvider constantReflection, MetaAccessProvider metaAccess, OptionValues options, Integer smallestCompareWidth, CanonicalCondition condition,
|
48190
|
89 |
boolean unorderedIsTrue, ValueNode forX, ValueNode forY, NodeView view) {
|
|
90 |
LogicNode result = super.canonical(constantReflection, metaAccess, options, smallestCompareWidth, condition, unorderedIsTrue, forX, forY, view);
|
46393
|
91 |
if (result != null) {
|
|
92 |
return result;
|
|
93 |
}
|
|
94 |
if (GraphUtil.unproxify(forX) == GraphUtil.unproxify(forY) && !unorderedIsTrue) {
|
|
95 |
return LogicConstantNode.contradiction();
|
|
96 |
}
|
|
97 |
return null;
|
43972
|
98 |
}
|
46393
|
99 |
|
|
100 |
@Override
|
48190
|
101 |
protected CompareNode duplicateModified(ValueNode newX, ValueNode newY, boolean unorderedIsTrue, NodeView view) {
|
|
102 |
if (newX.stamp(NodeView.DEFAULT) instanceof FloatStamp && newY.stamp(NodeView.DEFAULT) instanceof FloatStamp) {
|
46393
|
103 |
return new FloatLessThanNode(newX, newY, unorderedIsTrue);
|
48190
|
104 |
} else if (newX.stamp(NodeView.DEFAULT) instanceof IntegerStamp && newY.stamp(NodeView.DEFAULT) instanceof IntegerStamp) {
|
46393
|
105 |
return new IntegerLessThanNode(newX, newY);
|
|
106 |
}
|
|
107 |
throw GraalError.shouldNotReachHere();
|
|
108 |
}
|
43972
|
109 |
}
|
|
110 |
|
|
111 |
@Override
|
46344
|
112 |
public Stamp getSucceedingStampForX(boolean negated, Stamp xStamp, Stamp yStamp) {
|
43972
|
113 |
return null;
|
|
114 |
}
|
|
115 |
|
|
116 |
@Override
|
46344
|
117 |
public Stamp getSucceedingStampForY(boolean negated, Stamp xStamp, Stamp yStamp) {
|
43972
|
118 |
return null;
|
|
119 |
}
|
|
120 |
|
|
121 |
@Override
|
|
122 |
public TriState tryFold(Stamp xStampGeneric, Stamp yStampGeneric) {
|
|
123 |
return TriState.UNKNOWN;
|
|
124 |
}
|
|
125 |
}
|