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
264 superWordNodes(ADD_REDUCTION_VD, "AddReductionVD");
265 }
266
267 public static final String ADD_REDUCTION_VF = PREFIX + "ADD_REDUCTION_VF" + POSTFIX;
268 static {
269 superWordNodes(ADD_REDUCTION_VF, "AddReductionVF");
270 }
271
272 public static final String ADD_REDUCTION_VI = PREFIX + "ADD_REDUCTION_VI" + POSTFIX;
273 static {
274 superWordNodes(ADD_REDUCTION_VI, "AddReductionVI");
275 }
276
277 public static final String ADD_REDUCTION_VL = PREFIX + "ADD_REDUCTION_VL" + POSTFIX;
278 static {
279 superWordNodes(ADD_REDUCTION_VL, "AddReductionVL");
280 }
281
282 public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
283 static {
284 String optoRegex = "(.*precise .*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_instance" + END;
285 allocNodes(ALLOC, "Allocate", optoRegex);
286 }
287
288 public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
289 static {
290 String regex = "(.*precise .*" + IS_REPLACED + ":.*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_instance" + END;
291 optoOnly(ALLOC_OF, regex);
292 }
293
294 public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
295 static {
296 String optoRegex = "(.*precise \\[.*\\R((.*(?i:mov|mv|xor|nop|spill).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_array" + END;
297 allocNodes(ALLOC_ARRAY, "AllocateArray", optoRegex);
298 }
299
300 public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
301 static {
302 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;
303 optoOnly(ALLOC_ARRAY_OF, regex);
304 }
305
306 public static final String OR = PREFIX + "OR" + POSTFIX;
307 static {
308 beforeMatchingNameRegex(OR, "Or(I|L)");
309 }
310
311 public static final String AND = PREFIX + "AND" + POSTFIX;
312 static {
313 beforeMatchingNameRegex(AND, "And(I|L)");
314 }
315
316 public static final String AND_I = PREFIX + "AND_I" + POSTFIX;
317 static {
318 beforeMatchingNameRegex(AND_I, "AndI");
319 }
320
321 public static final String AND_L = PREFIX + "AND_L" + POSTFIX;
322 static {
665 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
666 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
667 }
668
669 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
670 static {
671 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
672 }
673
674 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
675 static {
676 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
677 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
678 }
679
680 public static final String IF = PREFIX + "IF" + POSTFIX;
681 static {
682 beforeMatchingNameRegex(IF, "If\\b");
683 }
684
685 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
686 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
687 static {
688 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
689 }
690
691 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
692 static {
693 trapNodes(INTRINSIC_TRAP, "intrinsic");
694 }
695
696 // Is only supported on riscv64.
697 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
698 static {
699 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
700 }
701
702 // Is only supported on riscv64.
703 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
704 static {
1686 vectorNode(SUB_VI, "SubVI", TYPE_INT);
1687 }
1688
1689 public static final String SUB_VL = VECTOR_PREFIX + "SUB_VL" + POSTFIX;
1690 static {
1691 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
1692 }
1693
1694 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
1695 static {
1696 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
1697 }
1698
1699 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
1700 static {
1701 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
1702 }
1703
1704 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
1705 static {
1706 beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");
1707 }
1708
1709 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
1710 static {
1711 trapNodes(TRAP, "reason");
1712 }
1713
1714 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
1715 static {
1716 beforeMatchingNameRegex(UDIV_I, "UDivI");
1717 }
1718
1719 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
1720 static {
1721 beforeMatchingNameRegex(UDIV_L, "UDivL");
1722 }
1723
1724 public static final String UDIV_MOD_I = PREFIX + "UDIV_MOD_I" + POSTFIX;
1725 static {
1726 beforeMatchingNameRegex(UDIV_MOD_I, "UDivModI");
2371 }
2372
2373 public static final String X86_CMOVEL_IMM01U = PREFIX + "X86_CMOVEL_IMM01U" + POSTFIX;
2374 static {
2375 machOnlyNameRegex(X86_CMOVEL_IMM01U, "cmovL_imm_01U");
2376 }
2377
2378 public static final String X86_CMOVEL_IMM01UCF = PREFIX + "X86_CMOVEL_IMM01UCF" + POSTFIX;
2379 static {
2380 machOnlyNameRegex(X86_CMOVEL_IMM01UCF, "cmovL_imm_01UCF");
2381 }
2382
2383 /*
2384 * Utility methods to set up IR_NODE_MAPPINGS.
2385 */
2386
2387 /**
2388 * Apply {@code regex} on all machine independent ideal graph phases up to and including
2389 * {@link CompilePhase#BEFORE_MATCHING}.
2390 */
2391 private static void beforeMatching(String irNodePlaceholder, String regex) {
2392 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2393 }
2394
2395 /**
2396 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
2397 * including {@link CompilePhase#BEFORE_MATCHING}.
2398 */
2399 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
2400 String regex = START + irNodeRegex + MID + END;
2401 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2402 }
2403
2404 /**
2405 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
2406 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
2407 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
2408 */
2409 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
2410 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
2411 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
2417
2418 private static void allocNodes(String irNode, String irNodeName, String optoRegex) {
2419 String idealIndependentRegex = START + irNodeName + "\\b" + MID + END;
2420 Map<PhaseInterval, String> intervalToRegexMap = new HashMap<>();
2421 intervalToRegexMap.put(new PhaseInterval(CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.PHASEIDEALLOOP_ITERATIONS),
2422 idealIndependentRegex);
2423 intervalToRegexMap.put(new PhaseInterval(CompilePhase.PRINT_OPTO_ASSEMBLY), optoRegex);
2424 MultiPhaseRangeEntry entry = new MultiPhaseRangeEntry(CompilePhase.PRINT_OPTO_ASSEMBLY, intervalToRegexMap);
2425 IR_NODE_MAPPINGS.put(irNode, entry);
2426 }
2427
2428 private static void callOfNodes(String irNodePlaceholder, String callRegex) {
2429 String regex = START + callRegex + MID + IS_REPLACED + " " + END;
2430 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2431 }
2432
2433 /**
2434 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
2435 * {@link CompilePhase#MATCHING}.
2436 */
2437 private static void optoOnly(String irNodePlaceholder, String regex) {
2438 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
2439 }
2440
2441 private static void machOnly(String irNodePlaceholder, String regex) {
2442 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2443 }
2444
2445 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
2446 String regex = START + irNodeRegex + MID + END;
2447 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2448 }
2449
2450 /**
2451 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
2452 */
2453 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
2454 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2455 CompilePhase.AFTER_CLOOPS,
2456 CompilePhase.FINAL_CODE));
2457 }
2468 /**
2469 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#BEFORE_CLOOPS} up to and
2470 * including {@link CompilePhase#BEFORE_MATCHING}
2471 */
2472 private static void fromMacroToBeforeMatching(String irNodePlaceholder, String regex) {
2473 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2474 CompilePhase.AFTER_MACRO_EXPANSION,
2475 CompilePhase.BEFORE_MATCHING));
2476 }
2477
2478 /**
2479 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#BEFORE_CLOOPS} up to and
2480 * including {@link CompilePhase#BEFORE_MATCHING}
2481 */
2482 private static void afterBarrierExpansionToBeforeMatching(String irNodePlaceholder, String regex) {
2483 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2484 CompilePhase.OPTIMIZE_FINISHED,
2485 CompilePhase.BEFORE_MATCHING));
2486 }
2487
2488 private static void trapNodes(String irNodePlaceholder, String trapReason) {
2489 String regex = START + "CallStaticJava" + MID + "uncommon_trap.*" + trapReason + END;
2490 beforeMatching(irNodePlaceholder, regex);
2491 }
2492
2493 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
2494 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + LOAD_OF_CLASS_POSTFIX;
2495 beforeMatching(irNodePlaceholder, regex);
2496 }
2497
2498 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
2499 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + STORE_OF_CLASS_POSTFIX;
2500 beforeMatching(irNodePlaceholder, regex);
2501 }
2502
2503 /**
2504 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
2505 * first phase that could contain vector nodes from super word.
2506 */
2507 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
271 superWordNodes(ADD_REDUCTION_VD, "AddReductionVD");
272 }
273
274 public static final String ADD_REDUCTION_VF = PREFIX + "ADD_REDUCTION_VF" + POSTFIX;
275 static {
276 superWordNodes(ADD_REDUCTION_VF, "AddReductionVF");
277 }
278
279 public static final String ADD_REDUCTION_VI = PREFIX + "ADD_REDUCTION_VI" + POSTFIX;
280 static {
281 superWordNodes(ADD_REDUCTION_VI, "AddReductionVI");
282 }
283
284 public static final String ADD_REDUCTION_VL = PREFIX + "ADD_REDUCTION_VL" + POSTFIX;
285 static {
286 superWordNodes(ADD_REDUCTION_VL, "AddReductionVL");
287 }
288
289 public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
290 static {
291 String optoRegex = "(.*precise .*\\R((.*(?i:mov|mv|xorl|nop|spill|pushq|popq).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_instance" + END;
292 allocNodes(ALLOC, "Allocate", optoRegex);
293 }
294
295 public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
296 static {
297 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;
298 optoOnly(ALLOC_OF, regex);
299 }
300
301 public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
302 static {
303 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;
304 allocNodes(ALLOC_ARRAY, "AllocateArray", optoRegex);
305 }
306
307 public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
308 static {
309 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;
310 optoOnly(ALLOC_ARRAY_OF, regex);
311 }
312
313 public static final String OR = PREFIX + "OR" + POSTFIX;
314 static {
315 beforeMatchingNameRegex(OR, "Or(I|L)");
316 }
317
318 public static final String AND = PREFIX + "AND" + POSTFIX;
319 static {
320 beforeMatchingNameRegex(AND, "And(I|L)");
321 }
322
323 public static final String AND_I = PREFIX + "AND_I" + POSTFIX;
324 static {
325 beforeMatchingNameRegex(AND_I, "AndI");
326 }
327
328 public static final String AND_L = PREFIX + "AND_L" + POSTFIX;
329 static {
672 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
673 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
674 }
675
676 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
677 static {
678 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
679 }
680
681 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
682 static {
683 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
684 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
685 }
686
687 public static final String IF = PREFIX + "IF" + POSTFIX;
688 static {
689 beforeMatchingNameRegex(IF, "If\\b");
690 }
691
692 public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;
693 static {
694 beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
695 }
696
697 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
698 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
699 static {
700 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
701 }
702
703 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
704 static {
705 trapNodes(INTRINSIC_TRAP, "intrinsic");
706 }
707
708 // Is only supported on riscv64.
709 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
710 static {
711 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
712 }
713
714 // Is only supported on riscv64.
715 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
716 static {
1698 vectorNode(SUB_VI, "SubVI", TYPE_INT);
1699 }
1700
1701 public static final String SUB_VL = VECTOR_PREFIX + "SUB_VL" + POSTFIX;
1702 static {
1703 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
1704 }
1705
1706 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
1707 static {
1708 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
1709 }
1710
1711 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
1712 static {
1713 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
1714 }
1715
1716 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
1717 static {
1718 macroNodes(SUBTYPE_CHECK, "SubTypeCheck");
1719 }
1720
1721 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
1722 static {
1723 trapNodes(TRAP, "reason");
1724 }
1725
1726 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
1727 static {
1728 beforeMatchingNameRegex(UDIV_I, "UDivI");
1729 }
1730
1731 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
1732 static {
1733 beforeMatchingNameRegex(UDIV_L, "UDivL");
1734 }
1735
1736 public static final String UDIV_MOD_I = PREFIX + "UDIV_MOD_I" + POSTFIX;
1737 static {
1738 beforeMatchingNameRegex(UDIV_MOD_I, "UDivModI");
2383 }
2384
2385 public static final String X86_CMOVEL_IMM01U = PREFIX + "X86_CMOVEL_IMM01U" + POSTFIX;
2386 static {
2387 machOnlyNameRegex(X86_CMOVEL_IMM01U, "cmovL_imm_01U");
2388 }
2389
2390 public static final String X86_CMOVEL_IMM01UCF = PREFIX + "X86_CMOVEL_IMM01UCF" + POSTFIX;
2391 static {
2392 machOnlyNameRegex(X86_CMOVEL_IMM01UCF, "cmovL_imm_01UCF");
2393 }
2394
2395 /*
2396 * Utility methods to set up IR_NODE_MAPPINGS.
2397 */
2398
2399 /**
2400 * Apply {@code regex} on all machine independent ideal graph phases up to and including
2401 * {@link CompilePhase#BEFORE_MATCHING}.
2402 */
2403 public static void beforeMatching(String irNodePlaceholder, String regex) {
2404 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2405 }
2406
2407 /**
2408 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
2409 * including {@link CompilePhase#BEFORE_MATCHING}.
2410 */
2411 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
2412 String regex = START + irNodeRegex + MID + END;
2413 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2414 }
2415
2416 /**
2417 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
2418 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
2419 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
2420 */
2421 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
2422 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
2423 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
2429
2430 private static void allocNodes(String irNode, String irNodeName, String optoRegex) {
2431 String idealIndependentRegex = START + irNodeName + "\\b" + MID + END;
2432 Map<PhaseInterval, String> intervalToRegexMap = new HashMap<>();
2433 intervalToRegexMap.put(new PhaseInterval(CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.PHASEIDEALLOOP_ITERATIONS),
2434 idealIndependentRegex);
2435 intervalToRegexMap.put(new PhaseInterval(CompilePhase.PRINT_OPTO_ASSEMBLY), optoRegex);
2436 MultiPhaseRangeEntry entry = new MultiPhaseRangeEntry(CompilePhase.PRINT_OPTO_ASSEMBLY, intervalToRegexMap);
2437 IR_NODE_MAPPINGS.put(irNode, entry);
2438 }
2439
2440 private static void callOfNodes(String irNodePlaceholder, String callRegex) {
2441 String regex = START + callRegex + MID + IS_REPLACED + " " + END;
2442 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2443 }
2444
2445 /**
2446 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
2447 * {@link CompilePhase#MATCHING}.
2448 */
2449 public static void optoOnly(String irNodePlaceholder, String regex) {
2450 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
2451 }
2452
2453 private static void machOnly(String irNodePlaceholder, String regex) {
2454 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2455 }
2456
2457 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
2458 String regex = START + irNodeRegex + MID + END;
2459 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2460 }
2461
2462 /**
2463 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
2464 */
2465 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
2466 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2467 CompilePhase.AFTER_CLOOPS,
2468 CompilePhase.FINAL_CODE));
2469 }
2480 /**
2481 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#BEFORE_CLOOPS} up to and
2482 * including {@link CompilePhase#BEFORE_MATCHING}
2483 */
2484 private static void fromMacroToBeforeMatching(String irNodePlaceholder, String regex) {
2485 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2486 CompilePhase.AFTER_MACRO_EXPANSION,
2487 CompilePhase.BEFORE_MATCHING));
2488 }
2489
2490 /**
2491 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#BEFORE_CLOOPS} up to and
2492 * including {@link CompilePhase#BEFORE_MATCHING}
2493 */
2494 private static void afterBarrierExpansionToBeforeMatching(String irNodePlaceholder, String regex) {
2495 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2496 CompilePhase.OPTIMIZE_FINISHED,
2497 CompilePhase.BEFORE_MATCHING));
2498 }
2499
2500 /**
2501 * Apply a regex that matches a macro node IR node name {@code macroNodeName} exactly on all machine independent
2502 * ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}. By default, we match on
2503 * {@link CompilePhase#BEFORE_MACRO_EXPANSION} when no {@link CompilePhase} is chosen.
2504 */
2505 private static void macroNodes(String irNodePlaceholder, String macroNodeName) {
2506 String macroNodeRegex = START + macroNodeName + "\\b" + MID + END;
2507 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION,
2508 macroNodeRegex,
2509 CompilePhase.BEFORE_STRINGOPTS,
2510 CompilePhase.BEFORE_MACRO_EXPANSION));
2511 }
2512
2513 private static void trapNodes(String irNodePlaceholder, String trapReason) {
2514 String regex = START + "CallStaticJava" + MID + "uncommon_trap.*" + trapReason + END;
2515 beforeMatching(irNodePlaceholder, regex);
2516 }
2517
2518 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
2519 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + LOAD_OF_CLASS_POSTFIX;
2520 beforeMatching(irNodePlaceholder, regex);
2521 }
2522
2523 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
2524 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + STORE_OF_CLASS_POSTFIX;
2525 beforeMatching(irNodePlaceholder, regex);
2526 }
2527
2528 /**
2529 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
2530 * first phase that could contain vector nodes from super word.
2531 */
2532 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
|