annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchRuleRegistry.java @ 21543:93c50cefb9e8

moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Mon, 25 May 2015 23:30:34 +0200
parents c1e2fdb5fea3
children b1530a6cce8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15370
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
1 /*
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
4 *
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
8 *
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
13 * accompanied this code).
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
14 *
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
18 *
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
21 * questions.
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
22 */
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.compiler.match;
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
24
15453
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
25 import static com.oracle.graal.compiler.GraalDebugConfig.*;
21538
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19824
diff changeset
26
15370
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
27 import java.util.*;
15453
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
28 import java.util.Map.Entry;
15370
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
29
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.compiler.gen.*;
15453
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
31 import com.oracle.graal.debug.*;
15521
76213c9350ad improve annotation error reporting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15456
diff changeset
32 import com.oracle.graal.debug.Debug.Scope;
15700
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
33 import com.oracle.graal.graph.*;
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21538
diff changeset
34 import com.oracle.jvmci.common.*;
21538
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19824
diff changeset
35 import com.oracle.jvmci.runtime.*;
15370
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
36
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
37 public class MatchRuleRegistry {
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
38
15700
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
39 /**
16899
6f245b6d2936 fixed eclipseformat issue
Doug Simon <doug.simon@oracle.com>
parents: 16897
diff changeset
40 * Convert a list of field names into {@link com.oracle.graal.graph.Position} objects that can
6f245b6d2936 fixed eclipseformat issue
Doug Simon <doug.simon@oracle.com>
parents: 16897
diff changeset
41 * be used to read them during a match. The names should already have been confirmed to exist in
6f245b6d2936 fixed eclipseformat issue
Doug Simon <doug.simon@oracle.com>
parents: 16897
diff changeset
42 * the type.
15700
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
43 *
19405
e6637891a870 Simplify NodeClass management.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
44 * @param nodeClass
15700
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
45 * @param names
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
46 * @return an array of Position objects corresponding to the named fields.
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
47 */
19824
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19543
diff changeset
48 public static Position[] findPositions(NodeClass<? extends Node> nodeClass, String[] names) {
16897
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16154
diff changeset
49 Position[] result = new Position[names.length];
15700
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
50 for (int i = 0; i < names.length; i++) {
19543
353669a84287 Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19405
diff changeset
51 Edges edges = nodeClass.getInputEdges();
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 16994
diff changeset
52 for (int e = 0; e < edges.getDirectCount(); e++) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 16994
diff changeset
53 if (names[i].equals(edges.getName(e))) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 16994
diff changeset
54 result[i] = new Position(edges, e, Node.NOT_ITERABLE);
15700
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
55 }
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
56 }
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
57 if (result[i] == null) {
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21538
diff changeset
58 throw new JVMCIError("unknown field \"%s\" in class %s", names[i], nodeClass);
15700
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
59 }
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
60 }
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
61 return result;
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
62 }
98423229008c allow overriding the NodeClass lookup when building MatchStatements
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15521
diff changeset
63
19824
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19543
diff changeset
64 private static final HashMap<Class<? extends NodeLIRBuilder>, Map<Class<? extends Node>, List<MatchStatement>>> registry = new HashMap<>();
15370
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
65
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
66 /**
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
67 * Collect all the {@link MatchStatement}s defined by the superclass chain of theClass.
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
68 *
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
69 * @param theClass
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
70 * @return the set of {@link MatchStatement}s applicable to theClass.
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
71 */
19824
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19543
diff changeset
72 public static synchronized Map<Class<? extends Node>, List<MatchStatement>> lookup(Class<? extends NodeLIRBuilder> theClass) {
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19543
diff changeset
73 Map<Class<? extends Node>, List<MatchStatement>> result = registry.get(theClass);
15370
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
74
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
75 if (result == null) {
19824
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19543
diff changeset
76 Map<Class<? extends Node>, List<MatchStatement>> rules = createRules(theClass);
15370
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
77 registry.put(theClass, rules);
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
78 assert registry.get(theClass) == rules;
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
79 result = rules;
15453
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
80
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
81 if (LogVerbose.getValue()) {
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
82 try (Scope s = Debug.scope("MatchComplexExpressions")) {
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
83 Debug.log("Match rules for %s", theClass.getSimpleName());
19824
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19543
diff changeset
84 for (Entry<Class<? extends Node>, List<MatchStatement>> entry : result.entrySet()) {
15453
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
85 Debug.log(" For node class: %s", entry.getKey());
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
86 for (MatchStatement statement : entry.getValue()) {
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
87 Debug.log(" %s", statement.getPattern());
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
88 }
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
89 }
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
90 }
100306ae985b switch MatchRule from class to method annotation and fix review feedback
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
91 }
15370
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
92 }
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
93
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
94 if (result.size() == 0) {
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
95 return null;
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
96 }
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
97 return result;
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
98 }
15826
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
99
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
100 /*
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
101 * This is a separate, public method so that external clients can create rules with a custom
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
102 * lookup and without the default caching behavior.
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
103 */
19824
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19543
diff changeset
104 public static Map<Class<? extends Node>, List<MatchStatement>> createRules(Class<? extends NodeLIRBuilder> theClass) {
15826
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
105 HashMap<Class<? extends NodeLIRBuilder>, MatchStatementSet> matchSets = new HashMap<>();
15966
27ff0792b048 made more services implement com.oracle.graal.api.runtime.Service for faster loading
Doug Simon <doug.simon@oracle.com>
parents: 15826
diff changeset
106 Iterable<MatchStatementSet> sl = Services.load(MatchStatementSet.class);
15826
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
107 for (MatchStatementSet rules : sl) {
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
108 matchSets.put(rules.forClass(), rules);
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
109 }
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
110
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
111 // Walk the class hierarchy collecting lists and merge them together. The subclass
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
112 // rules are first which gives them preference over earlier rules.
19824
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19543
diff changeset
113 Map<Class<? extends Node>, List<MatchStatement>> rules = new HashMap<>();
15826
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
114 Class<?> currentClass = theClass;
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
115 do {
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
116 MatchStatementSet matchSet = matchSets.get(currentClass);
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
117 if (matchSet != null) {
19405
e6637891a870 Simplify NodeClass management.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
118 List<MatchStatement> statements = matchSet.statements();
15826
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
119 for (MatchStatement statement : statements) {
19824
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19543
diff changeset
120 Class<? extends Node> nodeClass = statement.getPattern().nodeClass();
15826
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
121 List<MatchStatement> current = rules.get(nodeClass);
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
122 if (current == null) {
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
123 current = new ArrayList<>();
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
124 rules.put(nodeClass, current);
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
125 }
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
126 current.add(statement);
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
127 }
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
128 }
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
129 currentClass = currentClass.getSuperclass();
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
130 } while (currentClass != NodeLIRBuilder.class);
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
131 return rules;
1891bac562d8 Factor out rule creation in its own method
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15700
diff changeset
132 }
15370
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff changeset
133 }