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
24 package compiler.lib.ir_framework;
25
26 import compiler.lib.ir_framework.driver.irmatching.mapping.*;
27 import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo;
28 import compiler.lib.ir_framework.shared.CheckedTestFrameworkException;
29 import compiler.lib.ir_framework.shared.TestFormat;
30 import compiler.lib.ir_framework.shared.TestFormatException;
31 import jdk.test.lib.Platform;
32 import jdk.test.whitebox.WhiteBox;
33
34 import java.util.HashMap;
35 import java.util.Map;
36
37 /**
38 * This class specifies IR node placeholder strings (also referred to as just "IR nodes") with mappings to regexes
39 * depending on the selected compile phases. The mappings are stored in {@link #IR_NODE_MAPPINGS}. Each IR node
40 * placeholder string is mapped to a {@link IRNodeMapEntry} instance defined in
41 * {@link compiler.lib.ir_framework.driver.irmatching.mapping}.
42 *
43 * <p>
44 * IR node placeholder strings can be used in {@link IR#failOn()} and/or {@link IR#counts()} attributes to define IR
45 * constraints. They usually represent a single C2 IR node or a group of them.
46 *
47 * <p>
48 * Each IR node placeholder string is accompanied by a static block that defines an IR node placeholder to regex(es)
49 * mapping. The IR framework will automatically replace each IR node placeholder string in a user defined test with a
50 * regex depending on the selected compile phases in {@link IR#phase} and the provided mapping.
135 /**
136 * Map every vectorNode to a type string.
137 */
138 private static final Map<String, String> VECTOR_NODE_TYPE = new HashMap<>();
139
140 /*
141 * Start of IR placeholder string definitions followed by a static block defining the regex-for-compile-phase mapping.
142 * An IR node placeholder string must start with PREFIX for normal IR nodes or COMPOSITE_PREFIX for composite IR
143 * nodes, or VECTOR_PREFIX for vector nodes (see class description above).
144 *
145 * An IR node definition looks like this:
146 *
147 * public static final String IR_NODE = [PREFIX|COMPOSITE_PREFIX|VECTOR_PREFIX] + "IR_NODE" + POSTFIX;
148 * static {
149 * // Define IR_NODE to regex-for-compile-phase mapping. Create a new IRNodeMapEntry object and add it to
150 * // IR_NODE_MAPPINGS. This can be done by using the helper methods defined after all IR node placeholder string
151 * // definitions.
152 * }
153 */
154
155 public static final String ABS_D = PREFIX + "ABS_D" + POSTFIX;
156 static {
157 beforeMatchingNameRegex(ABS_D, "AbsD");
158 }
159
160 public static final String ABS_F = PREFIX + "ABS_F" + POSTFIX;
161 static {
162 beforeMatchingNameRegex(ABS_F, "AbsF");
163 }
164
165 public static final String ABS_I = PREFIX + "ABS_I" + POSTFIX;
166 static {
167 beforeMatchingNameRegex(ABS_I, "AbsI");
168 }
169
170 public static final String ABS_L = PREFIX + "ABS_L" + POSTFIX;
171 static {
172 beforeMatchingNameRegex(ABS_L, "AbsL");
173 }
174
259 superWordNodes(ADD_REDUCTION_VD, "AddReductionVD");
260 }
261
262 public static final String ADD_REDUCTION_VF = PREFIX + "ADD_REDUCTION_VF" + POSTFIX;
263 static {
264 superWordNodes(ADD_REDUCTION_VF, "AddReductionVF");
265 }
266
267 public static final String ADD_REDUCTION_VI = PREFIX + "ADD_REDUCTION_VI" + POSTFIX;
268 static {
269 superWordNodes(ADD_REDUCTION_VI, "AddReductionVI");
270 }
271
272 public static final String ADD_REDUCTION_VL = PREFIX + "ADD_REDUCTION_VL" + POSTFIX;
273 static {
274 superWordNodes(ADD_REDUCTION_VL, "AddReductionVL");
275 }
276
277 public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
278 static {
279 String optoRegex = "(.*precise .*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_instance" + END;
280 allocNodes(ALLOC, "Allocate", optoRegex);
281 }
282
283 public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
284 static {
285 String regex = "(.*precise .*" + IS_REPLACED + ":.*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_instance" + END;
286 optoOnly(ALLOC_OF, regex);
287 }
288
289 public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
290 static {
291 String optoRegex = "(.*precise \\[.*\\R((.*(?i:mov|mv|xor|nop|spill).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_array" + END;
292 allocNodes(ALLOC_ARRAY, "AllocateArray", optoRegex);
293 }
294
295 public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
296 static {
297 String regex = "(.*precise \\[.*" + IS_REPLACED + ":.*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_array" + END;
298 optoOnly(ALLOC_ARRAY_OF, regex);
299 }
300
301 public static final String OR = PREFIX + "OR" + POSTFIX;
302 static {
303 beforeMatchingNameRegex(OR, "Or(I|L)");
304 }
305
306 public static final String AND = PREFIX + "AND" + POSTFIX;
307 static {
308 beforeMatchingNameRegex(AND, "And(I|L)");
309 }
310
311 public static final String AND_I = PREFIX + "AND_I" + POSTFIX;
312 static {
313 beforeMatchingNameRegex(AND_I, "AndI");
314 }
315
316 public static final String AND_L = PREFIX + "AND_L" + POSTFIX;
317 static {
660 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
661 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
662 }
663
664 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
665 static {
666 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
667 }
668
669 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
670 static {
671 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
672 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
673 }
674
675 public static final String IF = PREFIX + "IF" + POSTFIX;
676 static {
677 beforeMatchingNameRegex(IF, "If\\b");
678 }
679
680 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
681 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
682 static {
683 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
684 }
685
686 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
687 static {
688 trapNodes(INTRINSIC_TRAP, "intrinsic");
689 }
690
691 // Is only supported on riscv64.
692 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
693 static {
694 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
695 }
696
697 // Is only supported on riscv64.
698 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
699 static {
1681 vectorNode(SUB_VI, "SubVI", TYPE_INT);
1682 }
1683
1684 public static final String SUB_VL = VECTOR_PREFIX + "SUB_VL" + POSTFIX;
1685 static {
1686 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
1687 }
1688
1689 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
1690 static {
1691 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
1692 }
1693
1694 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
1695 static {
1696 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
1697 }
1698
1699 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
1700 static {
1701 beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");
1702 }
1703
1704 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
1705 static {
1706 trapNodes(TRAP, "reason");
1707 }
1708
1709 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
1710 static {
1711 beforeMatchingNameRegex(UDIV_I, "UDivI");
1712 }
1713
1714 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
1715 static {
1716 beforeMatchingNameRegex(UDIV_L, "UDivL");
1717 }
1718
1719 public static final String UDIV_MOD_I = PREFIX + "UDIV_MOD_I" + POSTFIX;
1720 static {
1721 beforeMatchingNameRegex(UDIV_MOD_I, "UDivModI");
2366 }
2367
2368 public static final String X86_CMOVEL_IMM01U = PREFIX + "X86_CMOVEL_IMM01U" + POSTFIX;
2369 static {
2370 machOnlyNameRegex(X86_CMOVEL_IMM01U, "cmovL_imm_01U");
2371 }
2372
2373 public static final String X86_CMOVEL_IMM01UCF = PREFIX + "X86_CMOVEL_IMM01UCF" + POSTFIX;
2374 static {
2375 machOnlyNameRegex(X86_CMOVEL_IMM01UCF, "cmovL_imm_01UCF");
2376 }
2377
2378 /*
2379 * Utility methods to set up IR_NODE_MAPPINGS.
2380 */
2381
2382 /**
2383 * Apply {@code regex} on all machine independent ideal graph phases up to and including
2384 * {@link CompilePhase#BEFORE_MATCHING}.
2385 */
2386 private static void beforeMatching(String irNodePlaceholder, String regex) {
2387 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2388 }
2389
2390 /**
2391 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
2392 * including {@link CompilePhase#BEFORE_MATCHING}.
2393 */
2394 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
2395 String regex = START + irNodeRegex + MID + END;
2396 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2397 }
2398
2399 /**
2400 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
2401 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
2402 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
2403 */
2404 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
2405 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
2406 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
2412
2413 private static void allocNodes(String irNode, String irNodeName, String optoRegex) {
2414 String idealIndependentRegex = START + irNodeName + "\\b" + MID + END;
2415 Map<PhaseInterval, String> intervalToRegexMap = new HashMap<>();
2416 intervalToRegexMap.put(new PhaseInterval(CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.PHASEIDEALLOOP_ITERATIONS),
2417 idealIndependentRegex);
2418 intervalToRegexMap.put(new PhaseInterval(CompilePhase.PRINT_OPTO_ASSEMBLY), optoRegex);
2419 MultiPhaseRangeEntry entry = new MultiPhaseRangeEntry(CompilePhase.PRINT_OPTO_ASSEMBLY, intervalToRegexMap);
2420 IR_NODE_MAPPINGS.put(irNode, entry);
2421 }
2422
2423 private static void callOfNodes(String irNodePlaceholder, String callRegex) {
2424 String regex = START + callRegex + MID + IS_REPLACED + " " + END;
2425 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2426 }
2427
2428 /**
2429 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
2430 * {@link CompilePhase#MATCHING}.
2431 */
2432 private static void optoOnly(String irNodePlaceholder, String regex) {
2433 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
2434 }
2435
2436 private static void machOnly(String irNodePlaceholder, String regex) {
2437 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2438 }
2439
2440 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
2441 String regex = START + irNodeRegex + MID + END;
2442 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2443 }
2444
2445 /**
2446 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
2447 */
2448 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
2449 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2450 CompilePhase.AFTER_CLOOPS,
2451 CompilePhase.FINAL_CODE));
2452 }
2463 /**
2464 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#BEFORE_CLOOPS} up to and
2465 * including {@link CompilePhase#BEFORE_MATCHING}
2466 */
2467 private static void fromMacroToBeforeMatching(String irNodePlaceholder, String regex) {
2468 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2469 CompilePhase.AFTER_MACRO_EXPANSION,
2470 CompilePhase.BEFORE_MATCHING));
2471 }
2472
2473 /**
2474 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#BEFORE_CLOOPS} up to and
2475 * including {@link CompilePhase#BEFORE_MATCHING}
2476 */
2477 private static void afterBarrierExpansionToBeforeMatching(String irNodePlaceholder, String regex) {
2478 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2479 CompilePhase.OPTIMIZE_FINISHED,
2480 CompilePhase.BEFORE_MATCHING));
2481 }
2482
2483 private static void trapNodes(String irNodePlaceholder, String trapReason) {
2484 String regex = START + "CallStaticJava" + MID + "uncommon_trap.*" + trapReason + END;
2485 beforeMatching(irNodePlaceholder, regex);
2486 }
2487
2488 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
2489 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + LOAD_OF_CLASS_POSTFIX;
2490 beforeMatching(irNodePlaceholder, regex);
2491 }
2492
2493 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
2494 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + STORE_OF_CLASS_POSTFIX;
2495 beforeMatching(irNodePlaceholder, regex);
2496 }
2497
2498 /**
2499 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
2500 * first phase that could contain vector nodes from super word.
2501 */
2502 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
|
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
24 package compiler.lib.ir_framework;
25
26 import compiler.lib.ir_framework.driver.irmatching.mapping.*;
27 import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo;
28 import compiler.lib.ir_framework.shared.CheckedTestFrameworkException;
29 import compiler.lib.ir_framework.shared.TestFormat;
30 import compiler.lib.ir_framework.shared.TestFormatException;
31 import compiler.valhalla.inlinetypes.InlineTypeIRNode;
32 import jdk.test.lib.Platform;
33 import jdk.test.whitebox.WhiteBox;
34
35 import java.util.HashMap;
36 import java.util.Map;
37
38 /**
39 * This class specifies IR node placeholder strings (also referred to as just "IR nodes") with mappings to regexes
40 * depending on the selected compile phases. The mappings are stored in {@link #IR_NODE_MAPPINGS}. Each IR node
41 * placeholder string is mapped to a {@link IRNodeMapEntry} instance defined in
42 * {@link compiler.lib.ir_framework.driver.irmatching.mapping}.
43 *
44 * <p>
45 * IR node placeholder strings can be used in {@link IR#failOn()} and/or {@link IR#counts()} attributes to define IR
46 * constraints. They usually represent a single C2 IR node or a group of them.
47 *
48 * <p>
49 * Each IR node placeholder string is accompanied by a static block that defines an IR node placeholder to regex(es)
50 * mapping. The IR framework will automatically replace each IR node placeholder string in a user defined test with a
51 * regex depending on the selected compile phases in {@link IR#phase} and the provided mapping.
136 /**
137 * Map every vectorNode to a type string.
138 */
139 private static final Map<String, String> VECTOR_NODE_TYPE = new HashMap<>();
140
141 /*
142 * Start of IR placeholder string definitions followed by a static block defining the regex-for-compile-phase mapping.
143 * An IR node placeholder string must start with PREFIX for normal IR nodes or COMPOSITE_PREFIX for composite IR
144 * nodes, or VECTOR_PREFIX for vector nodes (see class description above).
145 *
146 * An IR node definition looks like this:
147 *
148 * public static final String IR_NODE = [PREFIX|COMPOSITE_PREFIX|VECTOR_PREFIX] + "IR_NODE" + POSTFIX;
149 * static {
150 * // Define IR_NODE to regex-for-compile-phase mapping. Create a new IRNodeMapEntry object and add it to
151 * // IR_NODE_MAPPINGS. This can be done by using the helper methods defined after all IR node placeholder string
152 * // definitions.
153 * }
154 */
155
156 // Valhalla: Make sure that all Valhalla specific IR nodes are also properly initialized. Doing it here also
157 // ensures that the Flag VM is able to pick up the correct compile phases.
158 static {
159 InlineTypeIRNode.forceStaticInitialization();
160 }
161
162 public static final String ABS_D = PREFIX + "ABS_D" + POSTFIX;
163 static {
164 beforeMatchingNameRegex(ABS_D, "AbsD");
165 }
166
167 public static final String ABS_F = PREFIX + "ABS_F" + POSTFIX;
168 static {
169 beforeMatchingNameRegex(ABS_F, "AbsF");
170 }
171
172 public static final String ABS_I = PREFIX + "ABS_I" + POSTFIX;
173 static {
174 beforeMatchingNameRegex(ABS_I, "AbsI");
175 }
176
177 public static final String ABS_L = PREFIX + "ABS_L" + POSTFIX;
178 static {
179 beforeMatchingNameRegex(ABS_L, "AbsL");
180 }
181
266 superWordNodes(ADD_REDUCTION_VD, "AddReductionVD");
267 }
268
269 public static final String ADD_REDUCTION_VF = PREFIX + "ADD_REDUCTION_VF" + POSTFIX;
270 static {
271 superWordNodes(ADD_REDUCTION_VF, "AddReductionVF");
272 }
273
274 public static final String ADD_REDUCTION_VI = PREFIX + "ADD_REDUCTION_VI" + POSTFIX;
275 static {
276 superWordNodes(ADD_REDUCTION_VI, "AddReductionVI");
277 }
278
279 public static final String ADD_REDUCTION_VL = PREFIX + "ADD_REDUCTION_VL" + POSTFIX;
280 static {
281 superWordNodes(ADD_REDUCTION_VL, "AddReductionVL");
282 }
283
284 public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
285 static {
286 String optoRegex = "(.*precise .*\\R((.*(?i:mov|mv|xorl|nop|spill|pushq|popq).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_instance" + END;
287 allocNodes(ALLOC, "Allocate", optoRegex);
288 }
289
290 public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
291 static {
292 String regex = "(.*precise .*" + IS_REPLACED + ":.*\\R((.*(?i:mov|mv|xorl|nop|spill|pushq|popq).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_instance" + END;
293 optoOnly(ALLOC_OF, regex);
294 }
295
296 public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
297 static {
298 String optoRegex = "(.*precise \\[.*\\R((.*(?i:mov|mv|xor|nop|spill|pushq|popq).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_array" + END;
299 allocNodes(ALLOC_ARRAY, "AllocateArray", optoRegex);
300 }
301
302 public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
303 static {
304 String regex = "(.*precise \\[.*" + IS_REPLACED + ":.*\\R((.*(?i:mov|mv|xorl|nop|spill|pushq|popq).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_array" + END;
305 optoOnly(ALLOC_ARRAY_OF, regex);
306 }
307
308 public static final String OR = PREFIX + "OR" + POSTFIX;
309 static {
310 beforeMatchingNameRegex(OR, "Or(I|L)");
311 }
312
313 public static final String AND = PREFIX + "AND" + POSTFIX;
314 static {
315 beforeMatchingNameRegex(AND, "And(I|L)");
316 }
317
318 public static final String AND_I = PREFIX + "AND_I" + POSTFIX;
319 static {
320 beforeMatchingNameRegex(AND_I, "AndI");
321 }
322
323 public static final String AND_L = PREFIX + "AND_L" + POSTFIX;
324 static {
667 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
668 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
669 }
670
671 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
672 static {
673 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
674 }
675
676 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
677 static {
678 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
679 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
680 }
681
682 public static final String IF = PREFIX + "IF" + POSTFIX;
683 static {
684 beforeMatchingNameRegex(IF, "If\\b");
685 }
686
687 public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;
688 static {
689 beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
690 }
691
692 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
693 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
694 static {
695 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
696 }
697
698 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
699 static {
700 trapNodes(INTRINSIC_TRAP, "intrinsic");
701 }
702
703 // Is only supported on riscv64.
704 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
705 static {
706 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
707 }
708
709 // Is only supported on riscv64.
710 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
711 static {
1693 vectorNode(SUB_VI, "SubVI", TYPE_INT);
1694 }
1695
1696 public static final String SUB_VL = VECTOR_PREFIX + "SUB_VL" + POSTFIX;
1697 static {
1698 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
1699 }
1700
1701 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
1702 static {
1703 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
1704 }
1705
1706 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
1707 static {
1708 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
1709 }
1710
1711 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
1712 static {
1713 macroNodes(SUBTYPE_CHECK, "SubTypeCheck");
1714 }
1715
1716 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
1717 static {
1718 trapNodes(TRAP, "reason");
1719 }
1720
1721 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
1722 static {
1723 beforeMatchingNameRegex(UDIV_I, "UDivI");
1724 }
1725
1726 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
1727 static {
1728 beforeMatchingNameRegex(UDIV_L, "UDivL");
1729 }
1730
1731 public static final String UDIV_MOD_I = PREFIX + "UDIV_MOD_I" + POSTFIX;
1732 static {
1733 beforeMatchingNameRegex(UDIV_MOD_I, "UDivModI");
2378 }
2379
2380 public static final String X86_CMOVEL_IMM01U = PREFIX + "X86_CMOVEL_IMM01U" + POSTFIX;
2381 static {
2382 machOnlyNameRegex(X86_CMOVEL_IMM01U, "cmovL_imm_01U");
2383 }
2384
2385 public static final String X86_CMOVEL_IMM01UCF = PREFIX + "X86_CMOVEL_IMM01UCF" + POSTFIX;
2386 static {
2387 machOnlyNameRegex(X86_CMOVEL_IMM01UCF, "cmovL_imm_01UCF");
2388 }
2389
2390 /*
2391 * Utility methods to set up IR_NODE_MAPPINGS.
2392 */
2393
2394 /**
2395 * Apply {@code regex} on all machine independent ideal graph phases up to and including
2396 * {@link CompilePhase#BEFORE_MATCHING}.
2397 */
2398 public static void beforeMatching(String irNodePlaceholder, String regex) {
2399 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2400 }
2401
2402 /**
2403 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
2404 * including {@link CompilePhase#BEFORE_MATCHING}.
2405 */
2406 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
2407 String regex = START + irNodeRegex + MID + END;
2408 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2409 }
2410
2411 /**
2412 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
2413 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
2414 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
2415 */
2416 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
2417 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
2418 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
2424
2425 private static void allocNodes(String irNode, String irNodeName, String optoRegex) {
2426 String idealIndependentRegex = START + irNodeName + "\\b" + MID + END;
2427 Map<PhaseInterval, String> intervalToRegexMap = new HashMap<>();
2428 intervalToRegexMap.put(new PhaseInterval(CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.PHASEIDEALLOOP_ITERATIONS),
2429 idealIndependentRegex);
2430 intervalToRegexMap.put(new PhaseInterval(CompilePhase.PRINT_OPTO_ASSEMBLY), optoRegex);
2431 MultiPhaseRangeEntry entry = new MultiPhaseRangeEntry(CompilePhase.PRINT_OPTO_ASSEMBLY, intervalToRegexMap);
2432 IR_NODE_MAPPINGS.put(irNode, entry);
2433 }
2434
2435 private static void callOfNodes(String irNodePlaceholder, String callRegex) {
2436 String regex = START + callRegex + MID + IS_REPLACED + " " + END;
2437 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2438 }
2439
2440 /**
2441 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
2442 * {@link CompilePhase#MATCHING}.
2443 */
2444 public static void optoOnly(String irNodePlaceholder, String regex) {
2445 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
2446 }
2447
2448 private static void machOnly(String irNodePlaceholder, String regex) {
2449 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2450 }
2451
2452 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
2453 String regex = START + irNodeRegex + MID + END;
2454 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2455 }
2456
2457 /**
2458 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
2459 */
2460 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
2461 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2462 CompilePhase.AFTER_CLOOPS,
2463 CompilePhase.FINAL_CODE));
2464 }
2475 /**
2476 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#BEFORE_CLOOPS} up to and
2477 * including {@link CompilePhase#BEFORE_MATCHING}
2478 */
2479 private static void fromMacroToBeforeMatching(String irNodePlaceholder, String regex) {
2480 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2481 CompilePhase.AFTER_MACRO_EXPANSION,
2482 CompilePhase.BEFORE_MATCHING));
2483 }
2484
2485 /**
2486 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#BEFORE_CLOOPS} up to and
2487 * including {@link CompilePhase#BEFORE_MATCHING}
2488 */
2489 private static void afterBarrierExpansionToBeforeMatching(String irNodePlaceholder, String regex) {
2490 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2491 CompilePhase.OPTIMIZE_FINISHED,
2492 CompilePhase.BEFORE_MATCHING));
2493 }
2494
2495 /**
2496 * Apply a regex that matches a macro node IR node name {@code macroNodeName} exactly on all machine independent
2497 * ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}. By default, we match on
2498 * {@link CompilePhase#BEFORE_MACRO_EXPANSION} when no {@link CompilePhase} is chosen.
2499 */
2500 private static void macroNodes(String irNodePlaceholder, String macroNodeName) {
2501 String macroNodeRegex = START + macroNodeName + "\\b" + MID + END;
2502 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION,
2503 macroNodeRegex,
2504 CompilePhase.BEFORE_STRINGOPTS,
2505 CompilePhase.BEFORE_MACRO_EXPANSION));
2506 }
2507
2508 private static void trapNodes(String irNodePlaceholder, String trapReason) {
2509 String regex = START + "CallStaticJava" + MID + "uncommon_trap.*" + trapReason + END;
2510 beforeMatching(irNodePlaceholder, regex);
2511 }
2512
2513 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
2514 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + LOAD_OF_CLASS_POSTFIX;
2515 beforeMatching(irNodePlaceholder, regex);
2516 }
2517
2518 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
2519 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + STORE_OF_CLASS_POSTFIX;
2520 beforeMatching(irNodePlaceholder, regex);
2521 }
2522
2523 /**
2524 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
2525 * first phase that could contain vector nodes from super word.
2526 */
2527 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
|