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.
70 * Using this IR node expects another user provided string in the constraint list of
71 * {@link IR#failOn()} and {@link IR#counts()}. They cannot be used as normal IR nodes.
72 * Trying to do so will result in a format violation error.</li>
73 * <li><p>Vector IR nodes: The IR node placeholder string contains an additional {@link #VECTOR_PREFIX}.
74 * Using this IR node, one can check for the type and size of a vector. The type must
75 * be directly specified in {@link #vectorNode}. The size can be specified directly with
76 * an additional argument using {@link #VECTOR_SIZE}, followed by a size tag or a comma
77 * separated list of sizes. If the size argument is not given, then a default size of
78 * {@link #VECTOR_SIZE_MAX} is taken, which is the number of elements that can fit in a
79 * vector of the specified type (depends on the VM flag MaxVectorSize and CPU features).
80 * However, when using {@link IR#failOn} or {@link IR#counts()} with comparison {@code <},
81 * or {@code <=} or {@code =0}, the default size is {@link #VECTOR_SIZE_ANY}, allowing any
82 * size. The motivation for these default values is that in most cases one wants to have
83 * vectorization with maximal vector width, or no vectorization of any vector width.
84 * </ul>
85 */
86 public class IRNode {
87 /**
88 * Prefix for normal IR nodes.
89 */
90 private static final String PREFIX = "_#";
91 /**
92 * Prefix for composite IR nodes.
93 */
94 private static final String COMPOSITE_PREFIX = PREFIX + "C#";
95 /**
96 * Prefix for vector IR nodes.
97 */
98 private static final String VECTOR_PREFIX = PREFIX + "V#";
99
100 private static final String POSTFIX = "#_";
101
102 public static final String START = "(\\d+(\\s){2}(";
103 public static final String MID = ".*)+(\\s){2}===.*";
104 public static final String END = ")";
105
106 public static final String IS_REPLACED = "#IS_REPLACED#"; // Is replaced by an additional user-defined string.
107
108 public static final String VECTOR_SIZE = "_@";
109 public static final String VECTOR_SIZE_TAG_ANY = "any";
110 public static final String VECTOR_SIZE_TAG_MAX = "max_for_type";
133 /**
134 * Map every vectorNode to a type string.
135 */
136 private static final Map<String, String> VECTOR_NODE_TYPE = new HashMap<>();
137
138 /*
139 * Start of IR placeholder string definitions followed by a static block defining the regex-for-compile-phase mapping.
140 * An IR node placeholder string must start with PREFIX for normal IR nodes or COMPOSITE_PREFIX for composite IR
141 * nodes, or VECTOR_PREFIX for vector nodes (see class description above).
142 *
143 * An IR node definition looks like this:
144 *
145 * public static final String IR_NODE = [PREFIX|COMPOSITE_PREFIX|VECTOR_PREFIX] + "IR_NODE" + POSTFIX;
146 * static {
147 * // Define IR_NODE to regex-for-compile-phase mapping. Create a new IRNodeMapEntry object and add it to
148 * // IR_NODE_MAPPINGS. This can be done by using the helper methods defined after all IR node placeholder string
149 * // definitions.
150 * }
151 */
152
153 public static final String ABS_D = PREFIX + "ABS_D" + POSTFIX;
154 static {
155 beforeMatchingNameRegex(ABS_D, "AbsD");
156 }
157
158 public static final String ABS_F = PREFIX + "ABS_F" + POSTFIX;
159 static {
160 beforeMatchingNameRegex(ABS_F, "AbsF");
161 }
162
163 public static final String ABS_I = PREFIX + "ABS_I" + POSTFIX;
164 static {
165 beforeMatchingNameRegex(ABS_I, "AbsI");
166 }
167
168 public static final String ABS_L = PREFIX + "ABS_L" + POSTFIX;
169 static {
170 beforeMatchingNameRegex(ABS_L, "AbsL");
171 }
172
364
365 public static final String REARRANGE_VD = VECTOR_PREFIX + "REARRANGE_VD" + POSTFIX;
366 static {
367 vectorNode(REARRANGE_VD, "VectorRearrange", TYPE_DOUBLE);
368 }
369
370 public static final String ADD_P_OF = COMPOSITE_PREFIX + "ADD_P_OF" + POSTFIX;
371 static {
372 String regex = START + "addP_" + IS_REPLACED + MID + ".*" + END;
373 machOnly(ADD_P_OF, regex);
374 }
375
376 public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
377 static {
378 String regex = START + "Allocate\\b" + MID + END;
379 macroNodes(ALLOC, regex);
380 }
381
382 public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
383 static {
384 String regex = START + "Allocate\\b" + MID + "allocationKlass:.*\\b" + IS_REPLACED + "\\s.*" + END;
385 macroNodes(ALLOC_OF, regex);
386 }
387
388 public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
389 static {
390 String regex = START + "AllocateArray\\b" + MID + END;
391 macroNodes(ALLOC_ARRAY, regex);
392 }
393
394 public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
395 static {
396 // Assuming we are looking for an array of "some/package/MyClass". The printout is
397 // [Lsome/package/MyClass;
398 // or, with more dimensions
399 // [[[Lsome/package/MyClass;
400
401 // Case where the searched string is a not fully qualified name (but maybe partially qualified):
402 // package/MyClass or MyClass
403 // The ".*\\b" will eat the "some/" and "some/package/" resp.
404 String partial_name_prefix = ".+\\b";
405
406 // The thing after "allocationKlass:" (the name of the allocated class) is a sequence of:
407 // - a non-empty sequence of "["
408 // - a single character ("L"),
409 // - maybe a non-empty sequence of characters ending on a word boundary
410 // this sequence is omitted if the given name is already fully qualified (exact match)
411 // but will eat the package path prefix in the cases described above
412 // - the name we are looking for
413 // - the final ";".
414 String name_part = "\\[+.(" + partial_name_prefix + ")?" + IS_REPLACED + ";";
415 String regex = START + "AllocateArray\\b" + MID + "allocationKlass:" + name_part + ".*" + END;
416 macroNodes(ALLOC_ARRAY_OF, regex);
417 }
418
419 public static final String OR = PREFIX + "OR" + POSTFIX;
420 static {
421 beforeMatchingNameRegex(OR, "Or(I|L)");
422 }
423
424 public static final String AND = PREFIX + "AND" + POSTFIX;
425 static {
426 beforeMatchingNameRegex(AND, "And(I|L)");
427 }
428
429 public static final String AND_I = PREFIX + "AND_I" + POSTFIX;
430 static {
431 beforeMatchingNameRegex(AND_I, "AndI");
432 }
433
434 public static final String AND_L = PREFIX + "AND_L" + POSTFIX;
435 static {
436 beforeMatchingNameRegex(AND_L, "AndL");
461 vectorNode(AND_VL, "AndV", TYPE_LONG);
462 }
463
464 public static final String AND_V_MASK = PREFIX + "AND_V_MASK" + POSTFIX;
465 static {
466 beforeMatchingNameRegex(AND_V_MASK, "AndVMask");
467 }
468
469 public static final String AND_REDUCTION_V = PREFIX + "AND_REDUCTION_V" + POSTFIX;
470 static {
471 superWordNodes(AND_REDUCTION_V, "AndReductionV");
472 }
473
474 public static final String CALL = PREFIX + "CALL" + POSTFIX;
475 static {
476 beforeMatchingNameRegex(CALL, "Call.*Java");
477 }
478
479 public static final String CALL_OF = COMPOSITE_PREFIX + "CALL_OF" + POSTFIX;
480 static {
481 callOfNodes(CALL_OF, "Call.*");
482 }
483
484 public static final String CALL_OF_METHOD = COMPOSITE_PREFIX + "CALL_OF_METHOD" + POSTFIX;
485 static {
486 callOfNodes(CALL_OF_METHOD, "Call.*Java");
487 }
488
489 public static final String STATIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "STATIC_CALL_OF_METHOD" + POSTFIX;
490 static {
491 callOfNodes(STATIC_CALL_OF_METHOD, "CallStaticJava");
492 }
493
494 public static final String CAST_II = PREFIX + "CAST_II" + POSTFIX;
495 static {
496 beforeMatchingNameRegex(CAST_II, "CastII");
497 }
498
499 public static final String CAST_LL = PREFIX + "CAST_LL" + POSTFIX;
500 static {
501 beforeMatchingNameRegex(CAST_LL, "CastLL");
502 }
503
504 public static final String CBNZW_HI = PREFIX + "CBNZW_HI" + POSTFIX;
505 static {
506 optoOnly(CBNZW_HI, "cbwhi");
507 }
508
509 public static final String CBZW_LS = PREFIX + "CBZW_LS" + POSTFIX;
510 static {
511 optoOnly(CBZW_LS, "cbwls");
742 beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
743 }
744
745 public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
746 static {
747 vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
748 }
749
750 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
751 static {
752 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
753 }
754
755 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
756 static {
757 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
758 }
759
760 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
761 static {
762 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava");
763 }
764
765 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
766 static {
767 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
768 }
769
770 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
771 static {
772 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
773 }
774
775 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
776 static {
777 String regex = START + "FastUnlock" + MID + END;
778 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
779 }
780
781 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
782 static {
878 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
879 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
880 }
881
882 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
883 static {
884 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
885 }
886
887 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
888 static {
889 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
890 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
891 }
892
893 public static final String IF = PREFIX + "IF" + POSTFIX;
894 static {
895 beforeMatchingNameRegex(IF, "If\\b");
896 }
897
898 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
899 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
900 static {
901 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
902 }
903
904 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
905 static {
906 trapNodes(INTRINSIC_TRAP, "intrinsic");
907 }
908
909 // Is only supported on riscv64.
910 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
911 static {
912 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
913 }
914
915 // Is only supported on riscv64.
916 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
917 static {
924 }
925
926 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
927 static {
928 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
929 }
930
931 // Only supported on x86.
932 public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
933 static {
934 machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
935 }
936
937 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
938 static {
939 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
940 }
941
942 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
943 static {
944 loadOfNodes(LOAD_OF_CLASS, "Load(B|UB|S|US|I|L|F|D|P|N)");
945 }
946
947 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
948 static {
949 beforeMatchingNameRegex(LOAD_B, "LoadB");
950 }
951
952 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
953 static {
954 loadOfNodes(LOAD_B_OF_CLASS, "LoadB");
955 }
956
957 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
958 static {
959 beforeMatchingNameRegex(LOAD_D, "LoadD");
960 }
961
962 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
963 static {
964 loadOfNodes(LOAD_D_OF_CLASS, "LoadD");
965 }
966
967 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
968 static {
969 beforeMatchingNameRegex(LOAD_F, "LoadF");
970 }
971
972 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
973 static {
974 loadOfNodes(LOAD_F_OF_CLASS, "LoadF");
975 }
976
977 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
978 static {
979 beforeMatchingNameRegex(LOAD_I, "LoadI");
980 }
981
982 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
983 static {
984 loadOfNodes(LOAD_I_OF_CLASS, "LoadI");
985 }
986
987 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
988 static {
989 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
990 }
991
992 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
993 static {
994 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
995 }
996
997 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
998 static {
999 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
1000 }
1001
1002 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
1003 static {
1004 beforeMatchingNameRegex(LOAD_L, "LoadL");
1005 }
1006
1007 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
1008 static {
1009 loadOfNodes(LOAD_L_OF_CLASS, "LoadL");
1010 }
1011
1012 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1013 static {
1014 beforeMatchingNameRegex(LOAD_N, "LoadN");
1015 }
1016
1017 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1018 static {
1019 loadOfNodes(LOAD_N_OF_CLASS, "LoadN");
1020 }
1021
1022 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1023 static {
1024 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1025 beforeMatching(LOAD_OF_FIELD, regex);
1026 }
1027
1028 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1029 static {
1030 beforeMatchingNameRegex(LOAD_P, "LoadP");
1031 }
1032
1033 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1034 static {
1035 loadOfNodes(LOAD_P_OF_CLASS, "LoadP");
1036 }
1037
1038 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1039 static {
1040 beforeMatchingNameRegex(LOAD_S, "LoadS");
1041 }
1042
1043 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1044 static {
1045 loadOfNodes(LOAD_S_OF_CLASS, "LoadS");
1046 }
1047
1048 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1049 static {
1050 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1051 }
1052
1053 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1054 static {
1055 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB");
1056 }
1057
1058 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1059 static {
1060 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1061 }
1062
1063 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1064 static {
1065 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS");
1066 }
1067
1068 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1069 static {
1070 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1071 }
1072
1073 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1074 static {
1075 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1076 }
1077
1078 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1079 static {
1080 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1081 }
1082
1083 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1084 static {
1085 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
1995 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
1996 }
1997
1998 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
1999 static {
2000 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
2001 }
2002
2003 public static final String STORE = PREFIX + "STORE" + POSTFIX;
2004 static {
2005 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
2006 }
2007
2008 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
2009 static {
2010 beforeMatchingNameRegex(STORE_B, "StoreB");
2011 }
2012
2013 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
2014 static {
2015 storeOfNodes(STORE_B_OF_CLASS, "StoreB");
2016 }
2017
2018 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
2019 static {
2020 beforeMatchingNameRegex(STORE_C, "StoreC");
2021 }
2022
2023 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
2024 static {
2025 storeOfNodes(STORE_C_OF_CLASS, "StoreC");
2026 }
2027
2028 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
2029 static {
2030 beforeMatchingNameRegex(STORE_D, "StoreD");
2031 }
2032
2033 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
2034 static {
2035 storeOfNodes(STORE_D_OF_CLASS, "StoreD");
2036 }
2037
2038 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2039 static {
2040 beforeMatchingNameRegex(STORE_F, "StoreF");
2041 }
2042
2043 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2044 static {
2045 storeOfNodes(STORE_F_OF_CLASS, "StoreF");
2046 }
2047
2048 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2049 static {
2050 beforeMatchingNameRegex(STORE_I, "StoreI");
2051 }
2052
2053 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2054 static {
2055 storeOfNodes(STORE_I_OF_CLASS, "StoreI");
2056 }
2057
2058 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2059 static {
2060 beforeMatchingNameRegex(STORE_L, "StoreL");
2061 }
2062
2063 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2064 static {
2065 storeOfNodes(STORE_L_OF_CLASS, "StoreL");
2066 }
2067
2068 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2069 static {
2070 beforeMatchingNameRegex(STORE_N, "StoreN");
2071 }
2072
2073 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2074 static {
2075 storeOfNodes(STORE_N_OF_CLASS, "StoreN");
2076 }
2077
2078 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2079 static {
2080 storeOfNodes(STORE_OF_CLASS, "Store(B|C|S|I|L|F|D|P|N)");
2081 }
2082
2083 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2084 static {
2085 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2086 beforeMatching(STORE_OF_FIELD, regex);
2087 }
2088
2089 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2090 static {
2091 beforeMatchingNameRegex(STORE_P, "StoreP");
2092 }
2093
2094 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2095 static {
2096 storeOfNodes(STORE_P_OF_CLASS, "StoreP");
2097 }
2098
2099 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2100 static {
2101 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2102 }
2103
2104 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2105 static {
2106 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2107 }
2108
2109 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2110 static {
2111 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2112 }
2113
2114 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2115 static {
2116 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2176 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2177 }
2178
2179 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2180 static {
2181 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2182 }
2183
2184 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2185 static {
2186 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2187 }
2188
2189 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2190 static {
2191 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2192 }
2193
2194 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2195 static {
2196 beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");
2197 }
2198
2199 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2200 static {
2201 trapNodes(TRAP, "reason");
2202 }
2203
2204 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2205 static {
2206 beforeMatchingNameRegex(DIV_HF, "DivHF");
2207 }
2208
2209 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2210 static {
2211 beforeMatchingNameRegex(UDIV_I, "UDivI");
2212 }
2213
2214 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2215 static {
2216 beforeMatchingNameRegex(UDIV_L, "UDivL");
3128 }
3129
3130 public static final String REPLICATE_HF = PREFIX + "REPLICATE_HF" + POSTFIX;
3131 static {
3132 machOnlyNameRegex(REPLICATE_HF, "replicateHF");
3133 }
3134
3135 public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3136 static {
3137 machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3138 }
3139
3140 /*
3141 * Utility methods to set up IR_NODE_MAPPINGS.
3142 */
3143
3144 /**
3145 * Apply {@code regex} on all machine independent ideal graph phases up to and including
3146 * {@link CompilePhase#BEFORE_MATCHING}.
3147 */
3148 private static void beforeMatching(String irNodePlaceholder, String regex) {
3149 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3150 }
3151
3152 /**
3153 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3154 * including {@link CompilePhase#BEFORE_MATCHING}.
3155 */
3156 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3157 String regex = START + irNodeRegex + MID + END;
3158 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3159 }
3160
3161 /**
3162 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3163 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3164 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3165 */
3166 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3167 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3168 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3169 // IS_REPLACED is later replaced with the specific type and size of the vector.
3170 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
3171 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3172 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3173 }
3174
3175 /**
3176 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3177 */
3178 private static void macroNodes(String irNodePlaceholder, String regex) {
3179 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3180 CompilePhase.BEFORE_STRINGOPTS,
3181 CompilePhase.BEFORE_MACRO_EXPANSION));
3182 }
3183
3184 private static void callOfNodes(String irNodePlaceholder, String callRegex) {
3185 String regex = START + callRegex + MID + IS_REPLACED + " " + END;
3186 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3187 }
3188
3189 /**
3190 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3191 * {@link CompilePhase#MATCHING}.
3192 */
3193 private static void optoOnly(String irNodePlaceholder, String regex) {
3194 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3195 }
3196
3197 private static void machOnly(String irNodePlaceholder, String regex) {
3198 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3199 }
3200
3201 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3202 String regex = START + irNodeRegex + MID + END;
3203 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3204 }
3205
3206 /**
3207 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3208 */
3209 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3210 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3211 CompilePhase.AFTER_CLOOPS,
3212 CompilePhase.FINAL_CODE));
3213 }
3267 // @ptrtype:fully/qualified/package/name/to/TheClass:ptrlattice+12
3268 // with ptrtype being the kind of the type such as instptr, aryptr, etc, and ptrlattice being
3269 // the kind of the value such as BotPTR, NotNull, etc.
3270 // And variation:
3271 // - after ptrtype, we can have "stable:" or other labels, with optional space after ':'
3272 // - the class can actually be a nested class, with $ separator (and it must be ok to give only the deepest one
3273 // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3274 // Worst case, it can be something like:
3275 // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24
3276
3277 // @ matches the start character of the pattern
3278 // (\w+: ?)+ tries to match the pattern 'ptrtype:' or 'stable:' with optional trailing whitespaces
3279 // [\\w/\\$] tries to match the pattern such as 'a/b/', 'a/b', or '/b' but also nested class such as '$c' or '$c$d'
3280 // \b asserts that the next character is a word character
3281 private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)+[\\w/\\$]*\\b";
3282 // ( \([^\)]+\))? tries to match the pattern ' (f/g,h/i/j)'
3283 // :\w+ tries to match the pattern ':NotNull'
3284 // .* tries to match the remaining of the pattern
3285 private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?:\\w+.*";
3286
3287 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
3288 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + IS_REPLACED + LOAD_STORE_SUFFIX + END;
3289 beforeMatching(irNodePlaceholder, regex);
3290 }
3291
3292 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
3293 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + IS_REPLACED + LOAD_STORE_SUFFIX + END;
3294 beforeMatching(irNodePlaceholder, regex);
3295 }
3296
3297 private static void safepointScalarobjectOfNodes(String irNodePlaceholder, String irNodeRegex) {
3298 String regex = START + irNodeRegex + MID + ".*" + IS_REPLACED + ".*" + END;
3299 beforeMatching(irNodePlaceholder, regex);
3300 }
3301
3302 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3303 String regex = START + irNodeRegex + MID + END;
3304 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3305 CompilePhase.BEFORE_REMOVEUSELESS,
3306 CompilePhase.FINAL_CODE));
3307 }
3308
3309 /**
3310 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3311 * first phase that could contain vector nodes from super word.
3312 */
3313 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.
71 * Using this IR node expects another user provided string in the constraint list of
72 * {@link IR#failOn()} and {@link IR#counts()}. They cannot be used as normal IR nodes.
73 * Trying to do so will result in a format violation error.</li>
74 * <li><p>Vector IR nodes: The IR node placeholder string contains an additional {@link #VECTOR_PREFIX}.
75 * Using this IR node, one can check for the type and size of a vector. The type must
76 * be directly specified in {@link #vectorNode}. The size can be specified directly with
77 * an additional argument using {@link #VECTOR_SIZE}, followed by a size tag or a comma
78 * separated list of sizes. If the size argument is not given, then a default size of
79 * {@link #VECTOR_SIZE_MAX} is taken, which is the number of elements that can fit in a
80 * vector of the specified type (depends on the VM flag MaxVectorSize and CPU features).
81 * However, when using {@link IR#failOn} or {@link IR#counts()} with comparison {@code <},
82 * or {@code <=} or {@code =0}, the default size is {@link #VECTOR_SIZE_ANY}, allowing any
83 * size. The motivation for these default values is that in most cases one wants to have
84 * vectorization with maximal vector width, or no vectorization of any vector width.
85 * </ul>
86 */
87 public class IRNode {
88 /**
89 * Prefix for normal IR nodes.
90 */
91 public static final String PREFIX = "_#";
92 /**
93 * Prefix for composite IR nodes.
94 */
95 private static final String COMPOSITE_PREFIX = PREFIX + "C#";
96 /**
97 * Prefix for vector IR nodes.
98 */
99 private static final String VECTOR_PREFIX = PREFIX + "V#";
100
101 private static final String POSTFIX = "#_";
102
103 public static final String START = "(\\d+(\\s){2}(";
104 public static final String MID = ".*)+(\\s){2}===.*";
105 public static final String END = ")";
106
107 public static final String IS_REPLACED = "#IS_REPLACED#"; // Is replaced by an additional user-defined string.
108
109 public static final String VECTOR_SIZE = "_@";
110 public static final String VECTOR_SIZE_TAG_ANY = "any";
111 public static final String VECTOR_SIZE_TAG_MAX = "max_for_type";
134 /**
135 * Map every vectorNode to a type string.
136 */
137 private static final Map<String, String> VECTOR_NODE_TYPE = new HashMap<>();
138
139 /*
140 * Start of IR placeholder string definitions followed by a static block defining the regex-for-compile-phase mapping.
141 * An IR node placeholder string must start with PREFIX for normal IR nodes or COMPOSITE_PREFIX for composite IR
142 * nodes, or VECTOR_PREFIX for vector nodes (see class description above).
143 *
144 * An IR node definition looks like this:
145 *
146 * public static final String IR_NODE = [PREFIX|COMPOSITE_PREFIX|VECTOR_PREFIX] + "IR_NODE" + POSTFIX;
147 * static {
148 * // Define IR_NODE to regex-for-compile-phase mapping. Create a new IRNodeMapEntry object and add it to
149 * // IR_NODE_MAPPINGS. This can be done by using the helper methods defined after all IR node placeholder string
150 * // definitions.
151 * }
152 */
153
154 // Valhalla: Make sure that all Valhalla specific IR nodes are also properly initialized. Doing it here also
155 // ensures that the Flag VM is able to pick up the correct compile phases.
156 static {
157 InlineTypeIRNode.forceStaticInitialization();
158 }
159
160 public static final String ABS_D = PREFIX + "ABS_D" + POSTFIX;
161 static {
162 beforeMatchingNameRegex(ABS_D, "AbsD");
163 }
164
165 public static final String ABS_F = PREFIX + "ABS_F" + POSTFIX;
166 static {
167 beforeMatchingNameRegex(ABS_F, "AbsF");
168 }
169
170 public static final String ABS_I = PREFIX + "ABS_I" + POSTFIX;
171 static {
172 beforeMatchingNameRegex(ABS_I, "AbsI");
173 }
174
175 public static final String ABS_L = PREFIX + "ABS_L" + POSTFIX;
176 static {
177 beforeMatchingNameRegex(ABS_L, "AbsL");
178 }
179
371
372 public static final String REARRANGE_VD = VECTOR_PREFIX + "REARRANGE_VD" + POSTFIX;
373 static {
374 vectorNode(REARRANGE_VD, "VectorRearrange", TYPE_DOUBLE);
375 }
376
377 public static final String ADD_P_OF = COMPOSITE_PREFIX + "ADD_P_OF" + POSTFIX;
378 static {
379 String regex = START + "addP_" + IS_REPLACED + MID + ".*" + END;
380 machOnly(ADD_P_OF, regex);
381 }
382
383 public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
384 static {
385 String regex = START + "Allocate\\b" + MID + END;
386 macroNodes(ALLOC, regex);
387 }
388
389 public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
390 static {
391 allocateOfNodes(ALLOC_OF, IS_REPLACED);
392 }
393
394 public static void allocateOfNodes(String irNodePlaceholder, String allocatee) {
395 String regex = START + "Allocate\\b" + MID + "allocationKlass:.*\\b" + allocatee + "\\s.*" + END;
396 macroNodes(irNodePlaceholder, regex);
397 }
398
399 public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
400 static {
401 String regex = START + "AllocateArray\\b" + MID + END;
402 macroNodes(ALLOC_ARRAY, regex);
403 }
404
405 public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
406 static {
407 allocateArrayOfNodes(ALLOC_ARRAY_OF, IS_REPLACED);
408 }
409
410 public static void allocateArrayOfNodes(String irNodePlaceholder, String allocatee) {
411 // Assuming we are looking for an array of "some/package/MyClass". The printout is
412 // [Lsome/package/MyClass;
413 // or, with more dimensions
414 // [[[Lsome/package/MyClass;
415
416 // Case where the searched string is a not fully qualified name (but maybe partially qualified):
417 // package/MyClass or MyClass
418 // The ".*\\b" will eat the "some/" and "some/package/" resp.
419 String partial_name_prefix = ".+\\b";
420
421 // The thing after "allocationKlass:" (the name of the allocated class) is a sequence of:
422 // - a non-empty sequence of "["
423 // - a single character ("L"),
424 // - maybe a non-empty sequence of characters ending on a word boundary
425 // this sequence is omitted if the given name is already fully qualified (exact match)
426 // but will eat the package path prefix in the cases described above
427 // - the name we are looking for
428 // - the final ";".
429 String name_part = "\\[+.(" + partial_name_prefix + ")?" + allocatee + ";";
430 String regex = START + "AllocateArray\\b" + MID + "allocationKlass:" + name_part + ".*" + END;
431 macroNodes(irNodePlaceholder, regex);
432 }
433
434 public static final String OR = PREFIX + "OR" + POSTFIX;
435 static {
436 beforeMatchingNameRegex(OR, "Or(I|L)");
437 }
438
439 public static final String AND = PREFIX + "AND" + POSTFIX;
440 static {
441 beforeMatchingNameRegex(AND, "And(I|L)");
442 }
443
444 public static final String AND_I = PREFIX + "AND_I" + POSTFIX;
445 static {
446 beforeMatchingNameRegex(AND_I, "AndI");
447 }
448
449 public static final String AND_L = PREFIX + "AND_L" + POSTFIX;
450 static {
451 beforeMatchingNameRegex(AND_L, "AndL");
476 vectorNode(AND_VL, "AndV", TYPE_LONG);
477 }
478
479 public static final String AND_V_MASK = PREFIX + "AND_V_MASK" + POSTFIX;
480 static {
481 beforeMatchingNameRegex(AND_V_MASK, "AndVMask");
482 }
483
484 public static final String AND_REDUCTION_V = PREFIX + "AND_REDUCTION_V" + POSTFIX;
485 static {
486 superWordNodes(AND_REDUCTION_V, "AndReductionV");
487 }
488
489 public static final String CALL = PREFIX + "CALL" + POSTFIX;
490 static {
491 beforeMatchingNameRegex(CALL, "Call.*Java");
492 }
493
494 public static final String CALL_OF = COMPOSITE_PREFIX + "CALL_OF" + POSTFIX;
495 static {
496 callOfNodes(CALL_OF, "Call.*", IS_REPLACED + " " );
497 }
498
499 public static final String CALL_OF_METHOD = COMPOSITE_PREFIX + "CALL_OF_METHOD" + POSTFIX;
500 static {
501 callOfNodes(CALL_OF_METHOD, "Call.*Java", IS_REPLACED + " ");
502 }
503
504 public static final String STATIC_CALL = PREFIX + "STATIC_CALL" + POSTFIX;
505 static {
506 beforeMatchingNameRegex(STATIC_CALL, "CallStaticJava");
507 }
508
509 public static final String STATIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "STATIC_CALL_OF_METHOD" + POSTFIX;
510 static {
511 staticCallOfMethodNodes(STATIC_CALL_OF_METHOD, IS_REPLACED + " ");
512 }
513
514 public static void staticCallOfMethodNodes(String irNodePlaceholder, String calleeRegex) {
515 callOfNodes(irNodePlaceholder, "CallStaticJava", calleeRegex);
516 }
517
518 public static final String CALL_LEAF_NO_FP = PREFIX + "CALL_LEAF_NO_FP" + POSTFIX;
519 static {
520 beforeMatchingNameRegex(CALL_LEAF_NO_FP, "CallLeafNoFP");
521 }
522
523 public static final String CALL_LEAF_NO_FP_OF_METHOD = COMPOSITE_PREFIX + "CALL_LEAF_NO_FP_OF_METHOD" + POSTFIX;
524 static {
525 callLeafNoFpOfMethodNodes(CALL_LEAF_NO_FP_OF_METHOD, IS_REPLACED);
526 }
527
528 public static void callLeafNoFpOfMethodNodes(String irNodePlaceholder, String calleeRegex) {
529 callOfNodes(irNodePlaceholder, "CallLeafNoFP", calleeRegex);
530 }
531
532 public static final String CAST_II = PREFIX + "CAST_II" + POSTFIX;
533 static {
534 beforeMatchingNameRegex(CAST_II, "CastII");
535 }
536
537 public static final String CAST_LL = PREFIX + "CAST_LL" + POSTFIX;
538 static {
539 beforeMatchingNameRegex(CAST_LL, "CastLL");
540 }
541
542 public static final String CBNZW_HI = PREFIX + "CBNZW_HI" + POSTFIX;
543 static {
544 optoOnly(CBNZW_HI, "cbwhi");
545 }
546
547 public static final String CBZW_LS = PREFIX + "CBZW_LS" + POSTFIX;
548 static {
549 optoOnly(CBZW_LS, "cbwls");
780 beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
781 }
782
783 public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
784 static {
785 vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
786 }
787
788 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
789 static {
790 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
791 }
792
793 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
794 static {
795 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
796 }
797
798 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
799 static {
800 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava", IS_REPLACED);
801 }
802
803 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
804 static {
805 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
806 }
807
808 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
809 static {
810 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
811 }
812
813 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
814 static {
815 String regex = START + "FastUnlock" + MID + END;
816 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
817 }
818
819 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
820 static {
916 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
917 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
918 }
919
920 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
921 static {
922 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
923 }
924
925 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
926 static {
927 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
928 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
929 }
930
931 public static final String IF = PREFIX + "IF" + POSTFIX;
932 static {
933 beforeMatchingNameRegex(IF, "If\\b");
934 }
935
936 public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;
937 static {
938 beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
939 }
940
941 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
942 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
943 static {
944 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
945 }
946
947 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
948 static {
949 trapNodes(INTRINSIC_TRAP, "intrinsic");
950 }
951
952 // Is only supported on riscv64.
953 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
954 static {
955 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
956 }
957
958 // Is only supported on riscv64.
959 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
960 static {
967 }
968
969 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
970 static {
971 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
972 }
973
974 // Only supported on x86.
975 public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
976 static {
977 machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
978 }
979
980 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
981 static {
982 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
983 }
984
985 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
986 static {
987 anyLoadOfNodes(LOAD_OF_CLASS, IS_REPLACED);
988 }
989
990 public static void anyLoadOfNodes(String irNodePlaceholder, String fieldHolder) {
991 loadOfNodes(irNodePlaceholder, "Load(B|UB|S|US|I|L|F|D|P|N)", fieldHolder);
992 }
993
994 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
995 static {
996 beforeMatchingNameRegex(LOAD_B, "LoadB");
997 }
998
999 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
1000 static {
1001 loadOfNodes(LOAD_B_OF_CLASS, "LoadB", IS_REPLACED);
1002 }
1003
1004 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
1005 static {
1006 beforeMatchingNameRegex(LOAD_D, "LoadD");
1007 }
1008
1009 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
1010 static {
1011 loadOfNodes(LOAD_D_OF_CLASS, "LoadD", IS_REPLACED);
1012 }
1013
1014 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
1015 static {
1016 beforeMatchingNameRegex(LOAD_F, "LoadF");
1017 }
1018
1019 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
1020 static {
1021 loadOfNodes(LOAD_F_OF_CLASS, "LoadF", IS_REPLACED);
1022 }
1023
1024 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
1025 static {
1026 beforeMatchingNameRegex(LOAD_I, "LoadI");
1027 }
1028
1029 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
1030 static {
1031 loadOfNodes(LOAD_I_OF_CLASS, "LoadI", IS_REPLACED);
1032 }
1033
1034 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
1035 static {
1036 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
1037 }
1038
1039 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
1040 static {
1041 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
1042 }
1043
1044 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
1045 static {
1046 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
1047 }
1048
1049 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
1050 static {
1051 beforeMatchingNameRegex(LOAD_L, "LoadL");
1052 }
1053
1054 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
1055 static {
1056 loadOfNodes(LOAD_L_OF_CLASS, "LoadL", IS_REPLACED);
1057 }
1058
1059 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1060 static {
1061 beforeMatchingNameRegex(LOAD_N, "LoadN");
1062 }
1063
1064 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1065 static {
1066 loadOfNodes(LOAD_N_OF_CLASS, "LoadN", IS_REPLACED);
1067 }
1068
1069 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1070 static {
1071 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1072 beforeMatching(LOAD_OF_FIELD, regex);
1073 }
1074
1075 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1076 static {
1077 beforeMatchingNameRegex(LOAD_P, "LoadP");
1078 }
1079
1080 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1081 static {
1082 loadOfNodes(LOAD_P_OF_CLASS, "LoadP", IS_REPLACED);
1083 }
1084
1085 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1086 static {
1087 beforeMatchingNameRegex(LOAD_S, "LoadS");
1088 }
1089
1090 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1091 static {
1092 loadOfNodes(LOAD_S_OF_CLASS, "LoadS", IS_REPLACED);
1093 }
1094
1095 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1096 static {
1097 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1098 }
1099
1100 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1101 static {
1102 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB", IS_REPLACED);
1103 }
1104
1105 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1106 static {
1107 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1108 }
1109
1110 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1111 static {
1112 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS", IS_REPLACED);
1113 }
1114
1115 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1116 static {
1117 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1118 }
1119
1120 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1121 static {
1122 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1123 }
1124
1125 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1126 static {
1127 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1128 }
1129
1130 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1131 static {
1132 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
2042 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
2043 }
2044
2045 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
2046 static {
2047 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
2048 }
2049
2050 public static final String STORE = PREFIX + "STORE" + POSTFIX;
2051 static {
2052 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
2053 }
2054
2055 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
2056 static {
2057 beforeMatchingNameRegex(STORE_B, "StoreB");
2058 }
2059
2060 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
2061 static {
2062 storeOfNodes(STORE_B_OF_CLASS, "StoreB", IS_REPLACED);
2063 }
2064
2065 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
2066 static {
2067 beforeMatchingNameRegex(STORE_C, "StoreC");
2068 }
2069
2070 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
2071 static {
2072 storeOfNodes(STORE_C_OF_CLASS, "StoreC", IS_REPLACED);
2073 }
2074
2075 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
2076 static {
2077 beforeMatchingNameRegex(STORE_D, "StoreD");
2078 }
2079
2080 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
2081 static {
2082 storeOfNodes(STORE_D_OF_CLASS, "StoreD", IS_REPLACED);
2083 }
2084
2085 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2086 static {
2087 beforeMatchingNameRegex(STORE_F, "StoreF");
2088 }
2089
2090 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2091 static {
2092 storeOfNodes(STORE_F_OF_CLASS, "StoreF", IS_REPLACED);
2093 }
2094
2095 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2096 static {
2097 beforeMatchingNameRegex(STORE_I, "StoreI");
2098 }
2099
2100 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2101 static {
2102 storeOfNodes(STORE_I_OF_CLASS, "StoreI", IS_REPLACED);
2103 }
2104
2105 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2106 static {
2107 beforeMatchingNameRegex(STORE_L, "StoreL");
2108 }
2109
2110 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2111 static {
2112 storeOfNodes(STORE_L_OF_CLASS, "StoreL", IS_REPLACED);
2113 }
2114
2115 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2116 static {
2117 beforeMatchingNameRegex(STORE_N, "StoreN");
2118 }
2119
2120 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2121 static {
2122 storeOfNodes(STORE_N_OF_CLASS, "StoreN", IS_REPLACED);
2123 }
2124
2125 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2126 static {
2127 anyStoreOfNodes(STORE_OF_CLASS, IS_REPLACED);
2128 }
2129
2130 public static void anyStoreOfNodes(String irNodePlaceholder, String fieldHolder) {
2131 storeOfNodes(irNodePlaceholder, "Store(B|C|S|I|L|F|D|P|N)", fieldHolder);
2132 }
2133
2134 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2135 static {
2136 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2137 beforeMatching(STORE_OF_FIELD, regex);
2138 }
2139
2140 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2141 static {
2142 beforeMatchingNameRegex(STORE_P, "StoreP");
2143 }
2144
2145 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2146 static {
2147 storeOfNodes(STORE_P_OF_CLASS, "StoreP", IS_REPLACED);
2148 }
2149
2150 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2151 static {
2152 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2153 }
2154
2155 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2156 static {
2157 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2158 }
2159
2160 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2161 static {
2162 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2163 }
2164
2165 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2166 static {
2167 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2227 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2228 }
2229
2230 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2231 static {
2232 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2233 }
2234
2235 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2236 static {
2237 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2238 }
2239
2240 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2241 static {
2242 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2243 }
2244
2245 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2246 static {
2247 String regex = START + "SubTypeCheck" + MID + END;
2248 macroNodes(SUBTYPE_CHECK, regex);
2249 }
2250
2251 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2252 static {
2253 trapNodes(TRAP, "reason");
2254 }
2255
2256 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2257 static {
2258 beforeMatchingNameRegex(DIV_HF, "DivHF");
2259 }
2260
2261 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2262 static {
2263 beforeMatchingNameRegex(UDIV_I, "UDivI");
2264 }
2265
2266 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2267 static {
2268 beforeMatchingNameRegex(UDIV_L, "UDivL");
3180 }
3181
3182 public static final String REPLICATE_HF = PREFIX + "REPLICATE_HF" + POSTFIX;
3183 static {
3184 machOnlyNameRegex(REPLICATE_HF, "replicateHF");
3185 }
3186
3187 public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3188 static {
3189 machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3190 }
3191
3192 /*
3193 * Utility methods to set up IR_NODE_MAPPINGS.
3194 */
3195
3196 /**
3197 * Apply {@code regex} on all machine independent ideal graph phases up to and including
3198 * {@link CompilePhase#BEFORE_MATCHING}.
3199 */
3200 public static void beforeMatching(String irNodePlaceholder, String regex) {
3201 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3202 }
3203
3204 /**
3205 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3206 * including {@link CompilePhase#BEFORE_MATCHING}.
3207 */
3208 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3209 String regex = START + irNodeRegex + MID + END;
3210 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3211 }
3212
3213 /**
3214 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3215 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3216 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3217 */
3218 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3219 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3220 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3221 // IS_REPLACED is later replaced with the specific type and size of the vector.
3222 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
3223 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3224 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3225 }
3226
3227 /**
3228 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3229 */
3230 private static void macroNodes(String irNodePlaceholder, String regex) {
3231 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3232 CompilePhase.BEFORE_STRINGOPTS,
3233 CompilePhase.BEFORE_MACRO_EXPANSION));
3234 }
3235
3236 private static void callOfNodes(String irNodePlaceholder, String callRegex, String calleeRegex) {
3237 String regex = START + callRegex + MID + calleeRegex + END;
3238 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3239 }
3240
3241 /**
3242 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3243 * {@link CompilePhase#MATCHING}.
3244 */
3245 public static void optoOnly(String irNodePlaceholder, String regex) {
3246 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3247 }
3248
3249 private static void machOnly(String irNodePlaceholder, String regex) {
3250 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3251 }
3252
3253 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3254 String regex = START + irNodeRegex + MID + END;
3255 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3256 }
3257
3258 /**
3259 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3260 */
3261 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3262 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3263 CompilePhase.AFTER_CLOOPS,
3264 CompilePhase.FINAL_CODE));
3265 }
3319 // @ptrtype:fully/qualified/package/name/to/TheClass:ptrlattice+12
3320 // with ptrtype being the kind of the type such as instptr, aryptr, etc, and ptrlattice being
3321 // the kind of the value such as BotPTR, NotNull, etc.
3322 // And variation:
3323 // - after ptrtype, we can have "stable:" or other labels, with optional space after ':'
3324 // - the class can actually be a nested class, with $ separator (and it must be ok to give only the deepest one
3325 // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3326 // Worst case, it can be something like:
3327 // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24
3328
3329 // @ matches the start character of the pattern
3330 // (\w+: ?)+ tries to match the pattern 'ptrtype:' or 'stable:' with optional trailing whitespaces
3331 // [\\w/\\$] tries to match the pattern such as 'a/b/', 'a/b', or '/b' but also nested class such as '$c' or '$c$d'
3332 // \b asserts that the next character is a word character
3333 private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)+[\\w/\\$]*\\b";
3334 // ( \([^\)]+\))? tries to match the pattern ' (f/g,h/i/j)'
3335 // :\w+ tries to match the pattern ':NotNull'
3336 // .* tries to match the remaining of the pattern
3337 private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?:\\w+.*";
3338
3339 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex, String loadee) {
3340 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + loadee + LOAD_STORE_SUFFIX + END;
3341 beforeMatching(irNodePlaceholder, regex);
3342 }
3343
3344 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex, String storee) {
3345 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + storee + LOAD_STORE_SUFFIX + END;
3346 beforeMatching(irNodePlaceholder, regex);
3347 }
3348
3349 private static void safepointScalarobjectOfNodes(String irNodePlaceholder, String irNodeRegex) {
3350 String regex = START + irNodeRegex + MID + ".*" + IS_REPLACED + ".*" + END;
3351 beforeMatching(irNodePlaceholder, regex);
3352 }
3353
3354 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3355 String regex = START + irNodeRegex + MID + END;
3356 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3357 CompilePhase.BEFORE_REMOVEUSELESS,
3358 CompilePhase.FINAL_CODE));
3359 }
3360
3361 /**
3362 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3363 * first phase that could contain vector nodes from super word.
3364 */
3365 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
|