Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/PureFunctionMacroNode.java @ 19471:880717e44675
Use typed NodeClass in node constructors.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Wed, 18 Feb 2015 12:12:26 +0100 |
parents | 61d3cb8e1280 |
children | 8fc336a04d77 |
rev | line source |
---|---|
11251 | 1 /* |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
16841
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
11251 | 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 com.oracle.graal.replacements.nodes; | |
24 | |
25 import com.oracle.graal.api.meta.*; | |
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:
11417
diff
changeset
|
26 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
|
27 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:
16811
diff
changeset
|
28 import com.oracle.graal.nodeinfo.*; |
11251 | 29 import com.oracle.graal.nodes.*; |
30 | |
31 /** | |
32 * This node class can be used to create {@link MacroNode}s for simple pure functions like | |
11417
98d96597a8e6
small JavaDoc fix in PureFunctionMacroNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
11251
diff
changeset
|
33 * {@link System#identityHashCode(Object)}. |
11251 | 34 */ |
16811
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16290
diff
changeset
|
35 @NodeInfo |
16290
e6622e77e8c7
split MacroNode into MacroNode and MacroStateSplitNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16248
diff
changeset
|
36 public abstract class PureFunctionMacroNode extends MacroStateSplitNode implements Canonicalizable { |
11251 | 37 |
19410
61d3cb8e1280
Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19403
diff
changeset
|
38 public static final NodeClass<PureFunctionMacroNode> TYPE = NodeClass.get(PureFunctionMacroNode.class); |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
39 |
19471
880717e44675
Use typed NodeClass in node constructors.
Roland Schatz <roland.schatz@oracle.com>
parents:
19410
diff
changeset
|
40 protected PureFunctionMacroNode(NodeClass<? extends PureFunctionMacroNode> c, Invoke invoke) { |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
41 super(c, invoke); |
11251 | 42 } |
43 | |
44 /** | |
45 * This method should return either a constant that represents the result of the function, or | |
46 * null if no such result could be determined. | |
47 */ | |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
16841
diff
changeset
|
48 protected abstract JavaConstant evaluate(JavaConstant param, MetaAccessProvider metaAccess); |
11251 | 49 |
11882
51059863da73
replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11881
diff
changeset
|
50 @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:
11417
diff
changeset
|
51 public Node canonical(CanonicalizerTool tool) { |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18187
diff
changeset
|
52 if (hasNoUsages()) { |
11251 | 53 return null; |
54 } else { | |
55 ValueNode param = arguments.get(0); | |
56 if (param.isConstant()) { | |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
16841
diff
changeset
|
57 JavaConstant constant = evaluate(param.asJavaConstant(), tool.getMetaAccess()); |
11251 | 58 if (constant != null) { |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
11959
diff
changeset
|
59 return ConstantNode.forConstant(constant, tool.getMetaAccess()); |
11251 | 60 } |
61 } | |
62 } | |
63 return this; | |
64 } | |
65 } |