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");
752 beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
753 }
754
755 public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
756 static {
757 vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
758 }
759
760 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
761 static {
762 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
763 }
764
765 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
766 static {
767 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
768 }
769
770 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
771 static {
772 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava");
773 }
774
775 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
776 static {
777 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
778 }
779
780 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
781 static {
782 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
783 }
784
785 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
786 static {
787 String regex = START + "FastUnlock" + MID + END;
788 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
789 }
790
791 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
792 static {
888 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
889 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
890 }
891
892 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
893 static {
894 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
895 }
896
897 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
898 static {
899 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
900 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
901 }
902
903 public static final String IF = PREFIX + "IF" + POSTFIX;
904 static {
905 beforeMatchingNameRegex(IF, "If\\b");
906 }
907
908 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
909 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
910 static {
911 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
912 }
913
914 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
915 static {
916 trapNodes(INTRINSIC_TRAP, "intrinsic");
917 }
918
919 // Is only supported on riscv64.
920 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
921 static {
922 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
923 }
924
925 // Is only supported on riscv64.
926 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
927 static {
934 }
935
936 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
937 static {
938 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
939 }
940
941 // Only supported on x86.
942 public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
943 static {
944 machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
945 }
946
947 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
948 static {
949 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
950 }
951
952 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
953 static {
954 loadOfNodes(LOAD_OF_CLASS, "Load(B|UB|S|US|I|L|F|D|P|N)");
955 }
956
957 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
958 static {
959 beforeMatchingNameRegex(LOAD_B, "LoadB");
960 }
961
962 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
963 static {
964 loadOfNodes(LOAD_B_OF_CLASS, "LoadB");
965 }
966
967 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
968 static {
969 beforeMatchingNameRegex(LOAD_D, "LoadD");
970 }
971
972 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
973 static {
974 loadOfNodes(LOAD_D_OF_CLASS, "LoadD");
975 }
976
977 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
978 static {
979 beforeMatchingNameRegex(LOAD_F, "LoadF");
980 }
981
982 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
983 static {
984 loadOfNodes(LOAD_F_OF_CLASS, "LoadF");
985 }
986
987 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
988 static {
989 beforeMatchingNameRegex(LOAD_I, "LoadI");
990 }
991
992 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
993 static {
994 loadOfNodes(LOAD_I_OF_CLASS, "LoadI");
995 }
996
997 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
998 static {
999 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
1000 }
1001
1002 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
1003 static {
1004 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
1005 }
1006
1007 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
1008 static {
1009 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
1010 }
1011
1012 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
1013 static {
1014 beforeMatchingNameRegex(LOAD_L, "LoadL");
1015 }
1016
1017 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
1018 static {
1019 loadOfNodes(LOAD_L_OF_CLASS, "LoadL");
1020 }
1021
1022 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1023 static {
1024 beforeMatchingNameRegex(LOAD_N, "LoadN");
1025 }
1026
1027 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1028 static {
1029 loadOfNodes(LOAD_N_OF_CLASS, "LoadN");
1030 }
1031
1032 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1033 static {
1034 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1035 beforeMatching(LOAD_OF_FIELD, regex);
1036 }
1037
1038 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1039 static {
1040 beforeMatchingNameRegex(LOAD_P, "LoadP");
1041 }
1042
1043 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1044 static {
1045 loadOfNodes(LOAD_P_OF_CLASS, "LoadP");
1046 }
1047
1048 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1049 static {
1050 beforeMatchingNameRegex(LOAD_S, "LoadS");
1051 }
1052
1053 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1054 static {
1055 loadOfNodes(LOAD_S_OF_CLASS, "LoadS");
1056 }
1057
1058 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1059 static {
1060 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1061 }
1062
1063 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1064 static {
1065 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB");
1066 }
1067
1068 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1069 static {
1070 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1071 }
1072
1073 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1074 static {
1075 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS");
1076 }
1077
1078 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1079 static {
1080 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1081 }
1082
1083 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1084 static {
1085 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1086 }
1087
1088 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1089 static {
1090 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1091 }
1092
1093 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1094 static {
1095 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
2026 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
2027 }
2028
2029 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
2030 static {
2031 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
2032 }
2033
2034 public static final String STORE = PREFIX + "STORE" + POSTFIX;
2035 static {
2036 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
2037 }
2038
2039 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
2040 static {
2041 beforeMatchingNameRegex(STORE_B, "StoreB");
2042 }
2043
2044 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
2045 static {
2046 storeOfNodes(STORE_B_OF_CLASS, "StoreB");
2047 }
2048
2049 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
2050 static {
2051 beforeMatchingNameRegex(STORE_C, "StoreC");
2052 }
2053
2054 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
2055 static {
2056 storeOfNodes(STORE_C_OF_CLASS, "StoreC");
2057 }
2058
2059 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
2060 static {
2061 beforeMatchingNameRegex(STORE_D, "StoreD");
2062 }
2063
2064 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
2065 static {
2066 storeOfNodes(STORE_D_OF_CLASS, "StoreD");
2067 }
2068
2069 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2070 static {
2071 beforeMatchingNameRegex(STORE_F, "StoreF");
2072 }
2073
2074 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2075 static {
2076 storeOfNodes(STORE_F_OF_CLASS, "StoreF");
2077 }
2078
2079 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2080 static {
2081 beforeMatchingNameRegex(STORE_I, "StoreI");
2082 }
2083
2084 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2085 static {
2086 storeOfNodes(STORE_I_OF_CLASS, "StoreI");
2087 }
2088
2089 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2090 static {
2091 beforeMatchingNameRegex(STORE_L, "StoreL");
2092 }
2093
2094 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2095 static {
2096 storeOfNodes(STORE_L_OF_CLASS, "StoreL");
2097 }
2098
2099 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2100 static {
2101 beforeMatchingNameRegex(STORE_N, "StoreN");
2102 }
2103
2104 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2105 static {
2106 storeOfNodes(STORE_N_OF_CLASS, "StoreN");
2107 }
2108
2109 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2110 static {
2111 storeOfNodes(STORE_OF_CLASS, "Store(B|C|S|I|L|F|D|P|N)");
2112 }
2113
2114 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2115 static {
2116 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2117 beforeMatching(STORE_OF_FIELD, regex);
2118 }
2119
2120 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2121 static {
2122 beforeMatchingNameRegex(STORE_P, "StoreP");
2123 }
2124
2125 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2126 static {
2127 storeOfNodes(STORE_P_OF_CLASS, "StoreP");
2128 }
2129
2130 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2131 static {
2132 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2133 }
2134
2135 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2136 static {
2137 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2138 }
2139
2140 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2141 static {
2142 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2143 }
2144
2145 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2146 static {
2147 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2207 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2208 }
2209
2210 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2211 static {
2212 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2213 }
2214
2215 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2216 static {
2217 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2218 }
2219
2220 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2221 static {
2222 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2223 }
2224
2225 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2226 static {
2227 beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");
2228 }
2229
2230 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2231 static {
2232 trapNodes(TRAP, "reason");
2233 }
2234
2235 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2236 static {
2237 beforeMatchingNameRegex(DIV_HF, "DivHF");
2238 }
2239
2240 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2241 static {
2242 beforeMatchingNameRegex(UDIV_I, "UDivI");
2243 }
2244
2245 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2246 static {
2247 beforeMatchingNameRegex(UDIV_L, "UDivL");
3169 }
3170
3171 public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3172 static {
3173 machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3174 }
3175
3176 public static final String OPAQUE_CONSTANT_BOOL = PREFIX + "OPAQUE_CONSTANT_BOOL" + POSTFIX;
3177 static {
3178 beforeMatchingNameRegex(OPAQUE_CONSTANT_BOOL, "OpaqueConstantBool");
3179 }
3180
3181 /*
3182 * Utility methods to set up IR_NODE_MAPPINGS.
3183 */
3184
3185 /**
3186 * Apply {@code regex} on all machine independent ideal graph phases up to and including
3187 * {@link CompilePhase#BEFORE_MATCHING}.
3188 */
3189 private static void beforeMatching(String irNodePlaceholder, String regex) {
3190 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3191 }
3192
3193 /**
3194 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3195 * including {@link CompilePhase#BEFORE_MATCHING}.
3196 */
3197 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3198 String regex = START + irNodeRegex + MID + END;
3199 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3200 }
3201
3202 /**
3203 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3204 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3205 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3206 */
3207 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3208 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3209 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3210 // IS_REPLACED is later replaced with the specific type and size of the vector.
3211 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
3212 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3213 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3214 }
3215
3216 /**
3217 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3218 */
3219 private static void macroNodes(String irNodePlaceholder, String regex) {
3220 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3221 CompilePhase.BEFORE_STRINGOPTS,
3222 CompilePhase.BEFORE_MACRO_EXPANSION));
3223 }
3224
3225 private static void callOfNodes(String irNodePlaceholder, String callRegex) {
3226 String regex = START + callRegex + MID + IS_REPLACED + " " + END;
3227 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3228 }
3229
3230 /**
3231 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3232 * {@link CompilePhase#MATCHING}.
3233 */
3234 private static void optoOnly(String irNodePlaceholder, String regex) {
3235 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3236 }
3237
3238 private static void machOnly(String irNodePlaceholder, String regex) {
3239 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3240 }
3241
3242 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3243 String regex = START + irNodeRegex + MID + END;
3244 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3245 }
3246
3247 /**
3248 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3249 */
3250 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3251 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3252 CompilePhase.AFTER_CLOOPS,
3253 CompilePhase.FINAL_CODE));
3254 }
3308 // @ptrtype:fully/qualified/package/name/to/TheClass:ptrlattice+12
3309 // with ptrtype being the kind of the type such as instptr, aryptr, etc, and ptrlattice being
3310 // the kind of the value such as BotPTR, NotNull, etc.
3311 // And variation:
3312 // - after ptrtype, we can have "stable:" or other labels, with optional space after ':'
3313 // - the class can actually be a nested class, with $ separator (and it must be ok to give only the deepest one
3314 // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3315 // Worst case, it can be something like:
3316 // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24
3317
3318 // @ matches the start character of the pattern
3319 // (\w+: ?)+ tries to match the pattern 'ptrtype:' or 'stable:' with optional trailing whitespaces
3320 // [\\w/\\$] tries to match the pattern such as 'a/b/', 'a/b', or '/b' but also nested class such as '$c' or '$c$d'
3321 // \b asserts that the next character is a word character
3322 private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)+[\\w/\\$]*\\b";
3323 // ( \([^\)]+\))? tries to match the pattern ' (f/g,h/i/j)'
3324 // :\w+ tries to match the pattern ':NotNull'
3325 // .* tries to match the remaining of the pattern
3326 private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?:\\w+.*";
3327
3328 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
3329 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + IS_REPLACED + LOAD_STORE_SUFFIX + END;
3330 beforeMatching(irNodePlaceholder, regex);
3331 }
3332
3333 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
3334 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + IS_REPLACED + LOAD_STORE_SUFFIX + END;
3335 beforeMatching(irNodePlaceholder, regex);
3336 }
3337
3338 private static void safepointScalarobjectOfNodes(String irNodePlaceholder, String irNodeRegex) {
3339 String regex = START + irNodeRegex + MID + ".*" + IS_REPLACED + ".*" + END;
3340 beforeMatching(irNodePlaceholder, regex);
3341 }
3342
3343 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3344 String regex = START + irNodeRegex + MID + END;
3345 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3346 CompilePhase.BEFORE_REMOVEUSELESS,
3347 CompilePhase.FINAL_CODE));
3348 }
3349
3350 /**
3351 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3352 * first phase that could contain vector nodes from super word.
3353 */
3354 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");
790 beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
791 }
792
793 public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
794 static {
795 vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
796 }
797
798 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
799 static {
800 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
801 }
802
803 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
804 static {
805 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
806 }
807
808 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
809 static {
810 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava", IS_REPLACED);
811 }
812
813 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
814 static {
815 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
816 }
817
818 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
819 static {
820 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
821 }
822
823 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
824 static {
825 String regex = START + "FastUnlock" + MID + END;
826 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
827 }
828
829 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
830 static {
926 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
927 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
928 }
929
930 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
931 static {
932 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
933 }
934
935 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
936 static {
937 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
938 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
939 }
940
941 public static final String IF = PREFIX + "IF" + POSTFIX;
942 static {
943 beforeMatchingNameRegex(IF, "If\\b");
944 }
945
946 public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;
947 static {
948 beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
949 }
950
951 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
952 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
953 static {
954 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
955 }
956
957 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
958 static {
959 trapNodes(INTRINSIC_TRAP, "intrinsic");
960 }
961
962 // Is only supported on riscv64.
963 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
964 static {
965 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
966 }
967
968 // Is only supported on riscv64.
969 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
970 static {
977 }
978
979 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
980 static {
981 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
982 }
983
984 // Only supported on x86.
985 public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
986 static {
987 machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
988 }
989
990 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
991 static {
992 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
993 }
994
995 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
996 static {
997 anyLoadOfNodes(LOAD_OF_CLASS, IS_REPLACED);
998 }
999
1000 public static void anyLoadOfNodes(String irNodePlaceholder, String fieldHolder) {
1001 loadOfNodes(irNodePlaceholder, "Load(B|UB|S|US|I|L|F|D|P|N)", fieldHolder);
1002 }
1003
1004 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
1005 static {
1006 beforeMatchingNameRegex(LOAD_B, "LoadB");
1007 }
1008
1009 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
1010 static {
1011 loadOfNodes(LOAD_B_OF_CLASS, "LoadB", IS_REPLACED);
1012 }
1013
1014 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
1015 static {
1016 beforeMatchingNameRegex(LOAD_D, "LoadD");
1017 }
1018
1019 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
1020 static {
1021 loadOfNodes(LOAD_D_OF_CLASS, "LoadD", IS_REPLACED);
1022 }
1023
1024 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
1025 static {
1026 beforeMatchingNameRegex(LOAD_F, "LoadF");
1027 }
1028
1029 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
1030 static {
1031 loadOfNodes(LOAD_F_OF_CLASS, "LoadF", IS_REPLACED);
1032 }
1033
1034 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
1035 static {
1036 beforeMatchingNameRegex(LOAD_I, "LoadI");
1037 }
1038
1039 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
1040 static {
1041 loadOfNodes(LOAD_I_OF_CLASS, "LoadI", IS_REPLACED);
1042 }
1043
1044 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
1045 static {
1046 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
1047 }
1048
1049 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
1050 static {
1051 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
1052 }
1053
1054 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
1055 static {
1056 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
1057 }
1058
1059 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
1060 static {
1061 beforeMatchingNameRegex(LOAD_L, "LoadL");
1062 }
1063
1064 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
1065 static {
1066 loadOfNodes(LOAD_L_OF_CLASS, "LoadL", IS_REPLACED);
1067 }
1068
1069 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1070 static {
1071 beforeMatchingNameRegex(LOAD_N, "LoadN");
1072 }
1073
1074 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1075 static {
1076 loadOfNodes(LOAD_N_OF_CLASS, "LoadN", IS_REPLACED);
1077 }
1078
1079 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1080 static {
1081 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1082 beforeMatching(LOAD_OF_FIELD, regex);
1083 }
1084
1085 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1086 static {
1087 beforeMatchingNameRegex(LOAD_P, "LoadP");
1088 }
1089
1090 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1091 static {
1092 loadOfNodes(LOAD_P_OF_CLASS, "LoadP", IS_REPLACED);
1093 }
1094
1095 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1096 static {
1097 beforeMatchingNameRegex(LOAD_S, "LoadS");
1098 }
1099
1100 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1101 static {
1102 loadOfNodes(LOAD_S_OF_CLASS, "LoadS", IS_REPLACED);
1103 }
1104
1105 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1106 static {
1107 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1108 }
1109
1110 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1111 static {
1112 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB", IS_REPLACED);
1113 }
1114
1115 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1116 static {
1117 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1118 }
1119
1120 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1121 static {
1122 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS", IS_REPLACED);
1123 }
1124
1125 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1126 static {
1127 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1128 }
1129
1130 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1131 static {
1132 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1133 }
1134
1135 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1136 static {
1137 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1138 }
1139
1140 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1141 static {
1142 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
2073 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
2074 }
2075
2076 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
2077 static {
2078 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
2079 }
2080
2081 public static final String STORE = PREFIX + "STORE" + POSTFIX;
2082 static {
2083 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
2084 }
2085
2086 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
2087 static {
2088 beforeMatchingNameRegex(STORE_B, "StoreB");
2089 }
2090
2091 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
2092 static {
2093 storeOfNodes(STORE_B_OF_CLASS, "StoreB", IS_REPLACED);
2094 }
2095
2096 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
2097 static {
2098 beforeMatchingNameRegex(STORE_C, "StoreC");
2099 }
2100
2101 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
2102 static {
2103 storeOfNodes(STORE_C_OF_CLASS, "StoreC", IS_REPLACED);
2104 }
2105
2106 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
2107 static {
2108 beforeMatchingNameRegex(STORE_D, "StoreD");
2109 }
2110
2111 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
2112 static {
2113 storeOfNodes(STORE_D_OF_CLASS, "StoreD", IS_REPLACED);
2114 }
2115
2116 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2117 static {
2118 beforeMatchingNameRegex(STORE_F, "StoreF");
2119 }
2120
2121 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2122 static {
2123 storeOfNodes(STORE_F_OF_CLASS, "StoreF", IS_REPLACED);
2124 }
2125
2126 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2127 static {
2128 beforeMatchingNameRegex(STORE_I, "StoreI");
2129 }
2130
2131 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2132 static {
2133 storeOfNodes(STORE_I_OF_CLASS, "StoreI", IS_REPLACED);
2134 }
2135
2136 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2137 static {
2138 beforeMatchingNameRegex(STORE_L, "StoreL");
2139 }
2140
2141 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2142 static {
2143 storeOfNodes(STORE_L_OF_CLASS, "StoreL", IS_REPLACED);
2144 }
2145
2146 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2147 static {
2148 beforeMatchingNameRegex(STORE_N, "StoreN");
2149 }
2150
2151 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2152 static {
2153 storeOfNodes(STORE_N_OF_CLASS, "StoreN", IS_REPLACED);
2154 }
2155
2156 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2157 static {
2158 anyStoreOfNodes(STORE_OF_CLASS, IS_REPLACED);
2159 }
2160
2161 public static void anyStoreOfNodes(String irNodePlaceholder, String fieldHolder) {
2162 storeOfNodes(irNodePlaceholder, "Store(B|C|S|I|L|F|D|P|N)", fieldHolder);
2163 }
2164
2165 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2166 static {
2167 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2168 beforeMatching(STORE_OF_FIELD, regex);
2169 }
2170
2171 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2172 static {
2173 beforeMatchingNameRegex(STORE_P, "StoreP");
2174 }
2175
2176 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2177 static {
2178 storeOfNodes(STORE_P_OF_CLASS, "StoreP", IS_REPLACED);
2179 }
2180
2181 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2182 static {
2183 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2184 }
2185
2186 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2187 static {
2188 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2189 }
2190
2191 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2192 static {
2193 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2194 }
2195
2196 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2197 static {
2198 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2258 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2259 }
2260
2261 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2262 static {
2263 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2264 }
2265
2266 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2267 static {
2268 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2269 }
2270
2271 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2272 static {
2273 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2274 }
2275
2276 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2277 static {
2278 String regex = START + "SubTypeCheck" + MID + END;
2279 macroNodes(SUBTYPE_CHECK, regex);
2280 }
2281
2282 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2283 static {
2284 trapNodes(TRAP, "reason");
2285 }
2286
2287 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2288 static {
2289 beforeMatchingNameRegex(DIV_HF, "DivHF");
2290 }
2291
2292 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2293 static {
2294 beforeMatchingNameRegex(UDIV_I, "UDivI");
2295 }
2296
2297 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2298 static {
2299 beforeMatchingNameRegex(UDIV_L, "UDivL");
3221 }
3222
3223 public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3224 static {
3225 machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3226 }
3227
3228 public static final String OPAQUE_CONSTANT_BOOL = PREFIX + "OPAQUE_CONSTANT_BOOL" + POSTFIX;
3229 static {
3230 beforeMatchingNameRegex(OPAQUE_CONSTANT_BOOL, "OpaqueConstantBool");
3231 }
3232
3233 /*
3234 * Utility methods to set up IR_NODE_MAPPINGS.
3235 */
3236
3237 /**
3238 * Apply {@code regex} on all machine independent ideal graph phases up to and including
3239 * {@link CompilePhase#BEFORE_MATCHING}.
3240 */
3241 public static void beforeMatching(String irNodePlaceholder, String regex) {
3242 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3243 }
3244
3245 /**
3246 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3247 * including {@link CompilePhase#BEFORE_MATCHING}.
3248 */
3249 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3250 String regex = START + irNodeRegex + MID + END;
3251 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3252 }
3253
3254 /**
3255 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3256 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3257 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3258 */
3259 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3260 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3261 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3262 // IS_REPLACED is later replaced with the specific type and size of the vector.
3263 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
3264 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3265 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3266 }
3267
3268 /**
3269 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3270 */
3271 private static void macroNodes(String irNodePlaceholder, String regex) {
3272 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3273 CompilePhase.BEFORE_STRINGOPTS,
3274 CompilePhase.BEFORE_MACRO_EXPANSION));
3275 }
3276
3277 private static void callOfNodes(String irNodePlaceholder, String callRegex, String calleeRegex) {
3278 String regex = START + callRegex + MID + calleeRegex + END;
3279 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3280 }
3281
3282 /**
3283 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3284 * {@link CompilePhase#MATCHING}.
3285 */
3286 public static void optoOnly(String irNodePlaceholder, String regex) {
3287 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3288 }
3289
3290 private static void machOnly(String irNodePlaceholder, String regex) {
3291 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3292 }
3293
3294 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3295 String regex = START + irNodeRegex + MID + END;
3296 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3297 }
3298
3299 /**
3300 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3301 */
3302 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3303 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3304 CompilePhase.AFTER_CLOOPS,
3305 CompilePhase.FINAL_CODE));
3306 }
3360 // @ptrtype:fully/qualified/package/name/to/TheClass:ptrlattice+12
3361 // with ptrtype being the kind of the type such as instptr, aryptr, etc, and ptrlattice being
3362 // the kind of the value such as BotPTR, NotNull, etc.
3363 // And variation:
3364 // - after ptrtype, we can have "stable:" or other labels, with optional space after ':'
3365 // - the class can actually be a nested class, with $ separator (and it must be ok to give only the deepest one
3366 // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3367 // Worst case, it can be something like:
3368 // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24
3369
3370 // @ matches the start character of the pattern
3371 // (\w+: ?)+ tries to match the pattern 'ptrtype:' or 'stable:' with optional trailing whitespaces
3372 // [\\w/\\$] tries to match the pattern such as 'a/b/', 'a/b', or '/b' but also nested class such as '$c' or '$c$d'
3373 // \b asserts that the next character is a word character
3374 private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)+[\\w/\\$]*\\b";
3375 // ( \([^\)]+\))? tries to match the pattern ' (f/g,h/i/j)'
3376 // :\w+ tries to match the pattern ':NotNull'
3377 // .* tries to match the remaining of the pattern
3378 private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?:\\w+.*";
3379
3380 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex, String loadee) {
3381 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + loadee + LOAD_STORE_SUFFIX + END;
3382 beforeMatching(irNodePlaceholder, regex);
3383 }
3384
3385 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex, String storee) {
3386 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + storee + LOAD_STORE_SUFFIX + END;
3387 beforeMatching(irNodePlaceholder, regex);
3388 }
3389
3390 private static void safepointScalarobjectOfNodes(String irNodePlaceholder, String irNodeRegex) {
3391 String regex = START + irNodeRegex + MID + ".*" + IS_REPLACED + ".*" + END;
3392 beforeMatching(irNodePlaceholder, regex);
3393 }
3394
3395 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3396 String regex = START + irNodeRegex + MID + END;
3397 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3398 CompilePhase.BEFORE_REMOVEUSELESS,
3399 CompilePhase.FINAL_CODE));
3400 }
3401
3402 /**
3403 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3404 * first phase that could contain vector nodes from super word.
3405 */
3406 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
|