annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java @ 19403:7e2c87dae93e

Create static final NodeClass field named TYPE in Node subclasses.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 16 Feb 2015 15:43:03 +0100
parents f57d86eb036f
children 61d3cb8e1280
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 /*
18839
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18649
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.extended;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
16444
843e8efacd13 getDisplacementStamp on LocationNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16248
diff changeset
25 import com.oracle.graal.api.code.*;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5504
diff changeset
26 import com.oracle.graal.api.meta.*;
15261
882f4cb7cfcf Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15132
diff changeset
27 import com.oracle.graal.compiler.common.type.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
28 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
29 import com.oracle.graal.graph.spi.*;
15298
e4d6c613d552 Move LIRGeneratorTool to graal.lir (errors).
Josef Eisl <josef.eisl@jku.at>
parents: 15261
diff changeset
30 import com.oracle.graal.lir.gen.*;
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: 16811
diff changeset
31 import com.oracle.graal.nodeinfo.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
32 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
33 import com.oracle.graal.nodes.spi.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34
5466
af07e798947d lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents: 5416
diff changeset
35 /**
9203
f78437ffb8d3 Restructure class hierarchy of LocationNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 8892
diff changeset
36 * Location node that has a displacement and a scaled index. Can represent locations in the form of
f78437ffb8d3 Restructure class hierarchy of LocationNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 8892
diff changeset
37 * [base + index * scale + disp] where base and index are nodes and scale and disp are integer
f78437ffb8d3 Restructure class hierarchy of LocationNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 8892
diff changeset
38 * constants.
5466
af07e798947d lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents: 5416
diff changeset
39 */
9203
f78437ffb8d3 Restructure class hierarchy of LocationNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 8892
diff changeset
40 @NodeInfo(nameTemplate = "IdxLoc {p#locationIdentity/s}")
19403
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
41 public final class IndexedLocationNode extends LocationNode implements Canonicalizable {
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
42 public static final NodeClass TYPE = NodeClass.get(IndexedLocationNode.class);
5466
af07e798947d lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents: 5416
diff changeset
43
17328
c9bb0da795d4 Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents: 17327
diff changeset
44 protected final LocationIdentity locationIdentity;
c9bb0da795d4 Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents: 17327
diff changeset
45 protected final long displacement;
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
46 @Input ValueNode index;
17328
c9bb0da795d4 Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents: 17327
diff changeset
47 protected final int indexScaling;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48
5466
af07e798947d lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents: 5416
diff changeset
49 /**
af07e798947d lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents: 5416
diff changeset
50 * Gets the index or offset of this location.
af07e798947d lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents: 5416
diff changeset
51 */
9525
038fa65cbd8d Consistent naming of accessor methods in the LocationNode class hierarchy
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9524
diff changeset
52 public ValueNode getIndex() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 return index;
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
9525
038fa65cbd8d Consistent naming of accessor methods in the LocationNode class hierarchy
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9524
diff changeset
56 public long getDisplacement() {
9205
9adb07d6f07f AddLocationNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9204
diff changeset
57 return displacement;
9adb07d6f07f AddLocationNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9204
diff changeset
58 }
9adb07d6f07f AddLocationNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9204
diff changeset
59
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 /**
7827
961ad124cb21 Convert indexScalingEnabled boolean into an indexScaling integer value. This change removed the dependency on TargetDescription in large parts of the system.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
61 * @return Constant that is used to scale the index.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 */
9525
038fa65cbd8d Consistent naming of accessor methods in the LocationNode class hierarchy
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9524
diff changeset
63 public int getIndexScaling() {
7827
961ad124cb21 Convert indexScalingEnabled boolean into an indexScaling integer value. This change removed the dependency on TargetDescription in large parts of the system.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
64 return indexScaling;
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
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
67 public IndexedLocationNode(LocationIdentity identity, long displacement, ValueNode index, int indexScaling) {
19403
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
68 super(TYPE, StampFactory.forVoid());
16248
c5b2a3c22318 refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16237
diff changeset
69 assert index != null;
c5b2a3c22318 refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16237
diff changeset
70 assert indexScaling != 0;
9524
ff8d87eabda8 Refactor the LocationNode class hierarchy to allow a SnippetLocationNode, i.e., a LocationNode that can be used in snippets without requiring the individual components to be constants at the time the snippet is prepared
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9298
diff changeset
71 this.locationIdentity = identity;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 this.index = index;
9203
f78437ffb8d3 Restructure class hierarchy of LocationNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 8892
diff changeset
73 this.displacement = displacement;
7827
961ad124cb21 Convert indexScalingEnabled boolean into an indexScaling integer value. This change removed the dependency on TargetDescription in large parts of the system.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
74 this.indexScaling = indexScaling;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 @Override
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
78 public LocationIdentity getLocationIdentity() {
9524
ff8d87eabda8 Refactor the LocationNode class hierarchy to allow a SnippetLocationNode, i.e., a LocationNode that can be used in snippets without requiring the individual components to be constants at the time the snippet is prepared
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9298
diff changeset
79 return locationIdentity;
9205
9adb07d6f07f AddLocationNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9204
diff changeset
80 }
9adb07d6f07f AddLocationNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9204
diff changeset
81
9adb07d6f07f AddLocationNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9204
diff changeset
82 @Override
11880
9a747d8e0d0f broadened types in Canonicalizable interface so that it can be moved to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 10049
diff changeset
83 public Node canonical(CanonicalizerTool tool) {
16248
c5b2a3c22318 refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16237
diff changeset
84 if (index.isConstant()) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
85 return new ConstantLocationNode(getLocationIdentity(), index.asJavaConstant().asLong() * indexScaling + displacement);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 return this;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88 }
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7827
diff changeset
89
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7827
diff changeset
90 @Override
16444
843e8efacd13 getDisplacementStamp on LocationNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16248
diff changeset
91 public IntegerStamp getDisplacementStamp() {
843e8efacd13 getDisplacementStamp on LocationNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16248
diff changeset
92 assert indexScaling > 0 && CodeUtil.isPowerOf2(indexScaling);
843e8efacd13 getDisplacementStamp on LocationNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16248
diff changeset
93 int scale = CodeUtil.log2(indexScaling);
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16919
diff changeset
94 return (IntegerStamp) IntegerStamp.OPS.getAdd().foldStamp(StampFactory.forInteger(64, displacement, displacement),
18839
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18649
diff changeset
95 IntegerStamp.OPS.getSignExtend().foldStamp(32, 64, IntegerStamp.OPS.getShl().foldStamp(index.stamp(), StampFactory.forInteger(64, scale, scale))));
16444
843e8efacd13 getDisplacementStamp on LocationNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16248
diff changeset
96 }
843e8efacd13 getDisplacementStamp on LocationNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16248
diff changeset
97
843e8efacd13 getDisplacementStamp on LocationNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16248
diff changeset
98 @Override
15130
ec22234bde0d Pass more restricted interfaces to ArithmeticLIRLowerable and LocationNode in LIR generation.
Roland Schatz <roland.schatz@oracle.com>
parents: 14950
diff changeset
99 public Value generateAddress(NodeMappableLIRBuilder builder, LIRGeneratorTool gen, Value base) {
ec22234bde0d Pass more restricted interfaces to ArithmeticLIRLowerable and LocationNode in LIR generation.
Roland Schatz <roland.schatz@oracle.com>
parents: 14950
diff changeset
100 return gen.emitAddress(base, displacement, builder.operand(getIndex()), getIndexScaling());
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7827
diff changeset
101 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102 }