annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerRemNode.java @ 21387:3bf051bb2691

Remove final and abstract class restrictions
author Christian Wimmer <christian.wimmer@oracle.com>
date Thu, 14 May 2015 16:11:58 -0700
parents 8fc336a04d77
children 48c1ebd24120
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 /*
19403
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
3733
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
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents: 5540
diff changeset
25 import com.oracle.graal.api.code.*;
15198
2c0cfbf454b5 Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 14950
diff changeset
26 import com.oracle.graal.compiler.common.type.*;
19403
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
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: 16263
diff changeset
29 import com.oracle.graal.nodeinfo.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
30 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
31 import com.oracle.graal.nodes.spi.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 @NodeInfo(shortName = "%")
21387
3bf051bb2691 Remove final and abstract class restrictions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19529
diff changeset
34 public class IntegerRemNode extends FixedBinaryNode implements Lowerable, LIRLowerable {
19529
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19410
diff changeset
35 public static final NodeClass<IntegerRemNode> TYPE = NodeClass.create(IntegerRemNode.class);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
37 public IntegerRemNode(ValueNode x, ValueNode y) {
21387
3bf051bb2691 Remove final and abstract class restrictions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19529
diff changeset
38 this(TYPE, x, y);
3bf051bb2691 Remove final and abstract class restrictions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19529
diff changeset
39 }
3bf051bb2691 Remove final and abstract class restrictions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19529
diff changeset
40
3bf051bb2691 Remove final and abstract class restrictions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19529
diff changeset
41 protected IntegerRemNode(NodeClass<? extends IntegerRemNode> c, ValueNode x, ValueNode y) {
3bf051bb2691 Remove final and abstract class restrictions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19529
diff changeset
42 super(c, IntegerStamp.OPS.getRem().foldStamp(x.stamp(), y.stamp()), x, y);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45 @Override
15791
308cedd2aaa2 better stamps for IntegerRemNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15301
diff changeset
46 public boolean inferStamp() {
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16919
diff changeset
47 return updateStamp(IntegerStamp.OPS.getRem().foldStamp(getX().stamp(), getY().stamp()));
15791
308cedd2aaa2 better stamps for IntegerRemNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15301
diff changeset
48 }
308cedd2aaa2 better stamps for IntegerRemNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15301
diff changeset
49
308cedd2aaa2 better stamps for IntegerRemNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15301
diff changeset
50 @Override
16223
1434b835f0d3 implement Canonicalizable.Binary in the FixedBinaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16218
diff changeset
51 public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
1434b835f0d3 implement Canonicalizable.Binary in the FixedBinaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16218
diff changeset
52 if (forX.isConstant() && forY.isConstant()) {
16897
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
53 @SuppressWarnings("hiding")
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
54 long y = forY.asJavaConstant().asLong();
14024
34c07ef28bc9 Support integer arithmetic for arbitrary types.
Roland Schatz <roland.schatz@oracle.com>
parents: 12045
diff changeset
55 if (y == 0) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 return this; // this will trap, can not canonicalize
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 }
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
58 return ConstantNode.forIntegerStamp(stamp(), forX.asJavaConstant().asLong() % y);
16223
1434b835f0d3 implement Canonicalizable.Binary in the FixedBinaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16218
diff changeset
59 } else if (forY.isConstant()) {
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
60 long c = forY.asJavaConstant().asLong();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 if (c == 1 || c == -1) {
16217
561070049e73 implement Canonicalizable.Binary in the BinaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16215
diff changeset
62 return ConstantNode.forIntegerStamp(stamp(), 0);
16223
1434b835f0d3 implement Canonicalizable.Binary in the FixedBinaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16218
diff changeset
63 } else if (c > 0 && CodeUtil.isPowerOf2(c) && forX.stamp() instanceof IntegerStamp && ((IntegerStamp) forX.stamp()).isPositive()) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
64 return new AndNode(forX, ConstantNode.forIntegerStamp(stamp(), c - 1));
3733
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 return this;
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 @Override
11579
ae619d70bf4b Rename LoweringType to GuardsPhase and make it an attribute of StructuredGraphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11265
diff changeset
71 public void lower(LoweringTool tool) {
12045
0fc653a9e019 made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11959
diff changeset
72 tool.getLowerer().lower(this, tool);
7305
cd205ca515dd Make integer division and remainder nodes fixed so that they can be lowered via snippets to do exception checks
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6299
diff changeset
73 }
cd205ca515dd Make integer division and remainder nodes fixed so that they can be lowered via snippets to do exception checks
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6299
diff changeset
74
cd205ca515dd Make integer division and remainder nodes fixed so that they can be lowered via snippets to do exception checks
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6299
diff changeset
75 @Override
14950
d5a1206e1923 NodeLIRBuilderTool: fix typo in interface name.
Josef Eisl <josef.eisl@jku.at>
parents: 14888
diff changeset
76 public void generate(NodeLIRBuilderTool gen) {
16218
c3260b05fd26 rename x() to getX() and y() to getY() in FixedBinaryNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16217
diff changeset
77 gen.setResult(this, gen.getLIRGeneratorTool().emitRem(gen.operand(getX()), gen.operand(getY()), gen.state(this)));
8892
2c0c708a0ad6 Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7305
diff changeset
78 }
2c0c708a0ad6 Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7305
diff changeset
79
2c0c708a0ad6 Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7305
diff changeset
80 @Override
2c0c708a0ad6 Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7305
diff changeset
81 public boolean canDeoptimize() {
16218
c3260b05fd26 rename x() to getX() and y() to getY() in FixedBinaryNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16217
diff changeset
82 return !(getY().stamp() instanceof IntegerStamp) || ((IntegerStamp) getY().stamp()).contains(0);
3733
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 }