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.network.testvm.java.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";
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 public static final String ABS_D = PREFIX + "ABS_D" + POSTFIX;
155 static {
156 beforeMatchingNameRegex(ABS_D, "AbsD");
157 }
158
159 public static final String ABS_F = PREFIX + "ABS_F" + POSTFIX;
160 static {
161 beforeMatchingNameRegex(ABS_F, "AbsF");
162 }
163
164 public static final String ABS_I = PREFIX + "ABS_I" + POSTFIX;
165 static {
166 beforeMatchingNameRegex(ABS_I, "AbsI");
167 }
168
169 public static final String ABS_L = PREFIX + "ABS_L" + POSTFIX;
170 static {
171 beforeMatchingNameRegex(ABS_L, "AbsL");
172 }
173
375
376 public static final String REARRANGE_VD = VECTOR_PREFIX + "REARRANGE_VD" + POSTFIX;
377 static {
378 vectorNode(REARRANGE_VD, "VectorRearrange", TYPE_DOUBLE);
379 }
380
381 public static final String ADD_P_OF = COMPOSITE_PREFIX + "ADD_P_OF" + POSTFIX;
382 static {
383 String regex = START + "addP_" + IS_REPLACED + MID + ".*" + END;
384 machOnly(ADD_P_OF, regex);
385 }
386
387 public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
388 static {
389 String regex = START + "Allocate\\b" + MID + END;
390 macroNodes(ALLOC, regex);
391 }
392
393 public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
394 static {
395 String regex = START + "Allocate\\b" + MID + "allocationKlass:.*\\b" + IS_REPLACED + "\\s.*" + END;
396 macroNodes(ALLOC_OF, 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 // Assuming we are looking for an array of "some/package/MyClass". The printout is
408 // [Lsome/package/MyClass;
409 // or, with more dimensions
410 // [[[Lsome/package/MyClass;
411
412 // Case where the searched string is a not fully qualified name (but maybe partially qualified):
413 // package/MyClass or MyClass
414 // The ".*\\b" will eat the "some/" and "some/package/" resp.
415 String partial_name_prefix = ".+\\b";
416
417 // The thing after "allocationKlass:" (the name of the allocated class) is a sequence of:
418 // - a non-empty sequence of "["
419 // - a single character ("L"),
420 // - maybe a non-empty sequence of characters ending on a word boundary
421 // this sequence is omitted if the given name is already fully qualified (exact match)
422 // but will eat the package path prefix in the cases described above
423 // - the name we are looking for
424 // - the final ";".
425 String name_part = "\\[+.(" + partial_name_prefix + ")?" + IS_REPLACED + ";";
426 String regex = START + "AllocateArray\\b" + MID + "allocationKlass:" + name_part + ".*" + END;
427 macroNodes(ALLOC_ARRAY_OF, regex);
428 }
429
430 public static final String OR = PREFIX + "OR" + POSTFIX;
431 static {
432 beforeMatchingNameRegex(OR, "Or(I|L)");
433 }
434
435 public static final String AND = PREFIX + "AND" + POSTFIX;
436 static {
437 beforeMatchingNameRegex(AND, "And(I|L)");
438 }
439
440 public static final String AND_I = PREFIX + "AND_I" + POSTFIX;
441 static {
442 beforeMatchingNameRegex(AND_I, "AndI");
443 }
444
445 public static final String AND_L = PREFIX + "AND_L" + POSTFIX;
446 static {
447 beforeMatchingNameRegex(AND_L, "AndL");
472 vectorNode(AND_VL, "AndV", TYPE_LONG);
473 }
474
475 public static final String AND_V_MASK = PREFIX + "AND_V_MASK" + POSTFIX;
476 static {
477 beforeMatchingNameRegex(AND_V_MASK, "AndVMask");
478 }
479
480 public static final String AND_REDUCTION_V = PREFIX + "AND_REDUCTION_V" + POSTFIX;
481 static {
482 superWordNodes(AND_REDUCTION_V, "AndReductionV");
483 }
484
485 public static final String CALL = PREFIX + "CALL" + POSTFIX;
486 static {
487 beforeMatchingNameRegex(CALL, "Call.*Java");
488 }
489
490 public static final String CALL_OF = COMPOSITE_PREFIX + "CALL_OF" + POSTFIX;
491 static {
492 callOfNodes(CALL_OF, "Call.*");
493 }
494
495 public static final String CALL_OF_METHOD = COMPOSITE_PREFIX + "CALL_OF_METHOD" + POSTFIX;
496 static {
497 callOfNodes(CALL_OF_METHOD, "Call.*Java");
498 }
499
500 public static final String STATIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "STATIC_CALL_OF_METHOD" + POSTFIX;
501 static {
502 callOfNodes(STATIC_CALL_OF_METHOD, "CallStaticJava");
503 }
504
505 public static final String CAST_II = PREFIX + "CAST_II" + POSTFIX;
506 static {
507 beforeMatchingNameRegex(CAST_II, "CastII");
508 }
509
510 public static final String CAST_LL = PREFIX + "CAST_LL" + POSTFIX;
511 static {
512 beforeMatchingNameRegex(CAST_LL, "CastLL");
513 }
514
515 public static final String CBNZW_HI = PREFIX + "CBNZW_HI" + POSTFIX;
516 static {
517 optoOnly(CBNZW_HI, "cbwhi");
518 }
519
520 public static final String CBZW_LS = PREFIX + "CBZW_LS" + POSTFIX;
521 static {
522 optoOnly(CBZW_LS, "cbwls");
609 public static final String CMP_UL = PREFIX + "CMP_UL" + POSTFIX;
610 static {
611 beforeMatchingNameRegex(CMP_UL, "CmpUL");
612 }
613
614 public static final String CMP_UL3 = PREFIX + "CMP_UL3" + POSTFIX;
615 static {
616 beforeMatchingNameRegex(CMP_UL3, "CmpUL3");
617 }
618
619 public static final String CMP_P = PREFIX + "CMP_P" + POSTFIX;
620 static {
621 beforeMatchingNameRegex(CMP_P, "CmpP");
622 }
623
624 public static final String CMP_N = PREFIX + "CMP_N" + POSTFIX;
625 static {
626 beforeMatchingNameRegex(CMP_N, "CmpN");
627 }
628
629 public static final String CMP_LT_MASK = PREFIX + "CMP_LT_MASK" + POSTFIX;
630 static {
631 beforeMatchingNameRegex(CMP_LT_MASK, "CmpLTMask");
632 }
633
634 public static final String ROUND_F = PREFIX + "ROUND_F" + POSTFIX;
635 static {
636 beforeMatchingNameRegex(ROUND_F, "RoundF");
637 }
638
639 public static final String ROUND_D = PREFIX + "ROUND_D" + POSTFIX;
640 static {
641 beforeMatchingNameRegex(ROUND_D, "RoundD");
642 }
643
644 public static final String COMPRESS_BITS = PREFIX + "COMPRESS_BITS" + POSTFIX;
645 static {
646 beforeMatchingNameRegex(COMPRESS_BITS, "CompressBits");
647 }
648
773 beforeMatchingNameRegex(DIV_F, "DivF");
774 }
775
776 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
777 static {
778 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
779 }
780
781 public static final String DIV_D = PREFIX + "DIV_D" + POSTFIX;
782 static {
783 beforeMatchingNameRegex(DIV_D, "DivD");
784 }
785
786 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
787 static {
788 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
789 }
790
791 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
792 static {
793 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava");
794 }
795
796 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
797 static {
798 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
799 }
800
801 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
802 static {
803 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
804 }
805
806 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
807 static {
808 String regex = START + "FastUnlock" + MID + END;
809 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
810 }
811
812 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
813 static {
909 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
910 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
911 }
912
913 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
914 static {
915 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
916 }
917
918 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
919 static {
920 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
921 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
922 }
923
924 public static final String IF = PREFIX + "IF" + POSTFIX;
925 static {
926 beforeMatchingNameRegex(IF, "If\\b");
927 }
928
929 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
930 static {
931 trapNodes(INTRINSIC_TRAP, "intrinsic");
932 }
933
934 // Is only supported on riscv64.
935 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
936 static {
937 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
938 }
939
940 // Is only supported on riscv64.
941 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
942 static {
943 beforeMatchingNameRegex(IS_FINITE_F, "IsFiniteF");
944 }
945
946 public static final String IS_INFINITE_D = PREFIX + "IS_INFINITE_D" + POSTFIX;
947 static {
948 beforeMatchingNameRegex(IS_INFINITE_D, "IsInfiniteD");
949 }
950
951 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
952 static {
953 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
954 }
955
956 // Only supported on x86.
957 public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
958 static {
959 machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
960 }
961
962 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
963 static {
964 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
965 }
966
967 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
968 static {
969 loadOfNodes(LOAD_OF_CLASS, "Load(B|UB|S|US|I|L|F|D|P|N)");
970 }
971
972 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
973 static {
974 beforeMatchingNameRegex(LOAD_B, "LoadB");
975 }
976
977 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
978 static {
979 loadOfNodes(LOAD_B_OF_CLASS, "LoadB");
980 }
981
982 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
983 static {
984 beforeMatchingNameRegex(LOAD_D, "LoadD");
985 }
986
987 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
988 static {
989 loadOfNodes(LOAD_D_OF_CLASS, "LoadD");
990 }
991
992 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
993 static {
994 beforeMatchingNameRegex(LOAD_F, "LoadF");
995 }
996
997 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
998 static {
999 loadOfNodes(LOAD_F_OF_CLASS, "LoadF");
1000 }
1001
1002 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
1003 static {
1004 beforeMatchingNameRegex(LOAD_I, "LoadI");
1005 }
1006
1007 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
1008 static {
1009 loadOfNodes(LOAD_I_OF_CLASS, "LoadI");
1010 }
1011
1012 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
1013 static {
1014 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
1015 }
1016
1017 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
1018 static {
1019 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
1020 }
1021
1022 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
1023 static {
1024 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
1025 }
1026
1027 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
1028 static {
1029 beforeMatchingNameRegex(LOAD_L, "LoadL");
1030 }
1031
1032 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
1033 static {
1034 loadOfNodes(LOAD_L_OF_CLASS, "LoadL");
1035 }
1036
1037 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1038 static {
1039 beforeMatchingNameRegex(LOAD_N, "LoadN");
1040 }
1041
1042 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1043 static {
1044 loadOfNodes(LOAD_N_OF_CLASS, "LoadN");
1045 }
1046
1047 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1048 static {
1049 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1050 beforeMatching(LOAD_OF_FIELD, regex);
1051 }
1052
1053 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1054 static {
1055 beforeMatchingNameRegex(LOAD_P, "LoadP");
1056 }
1057
1058 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1059 static {
1060 loadOfNodes(LOAD_P_OF_CLASS, "LoadP");
1061 }
1062
1063 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1064 static {
1065 beforeMatchingNameRegex(LOAD_S, "LoadS");
1066 }
1067
1068 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1069 static {
1070 loadOfNodes(LOAD_S_OF_CLASS, "LoadS");
1071 }
1072
1073 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1074 static {
1075 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1076 }
1077
1078 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1079 static {
1080 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB");
1081 }
1082
1083 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1084 static {
1085 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1086 }
1087
1088 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1089 static {
1090 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS");
1091 }
1092
1093 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1094 static {
1095 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1096 }
1097
1098 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1099 static {
1100 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1101 }
1102
1103 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1104 static {
1105 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1106 }
1107
1108 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1109 static {
1110 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
2066 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
2067 }
2068
2069 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
2070 static {
2071 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
2072 }
2073
2074 public static final String STORE = PREFIX + "STORE" + POSTFIX;
2075 static {
2076 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
2077 }
2078
2079 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
2080 static {
2081 beforeMatchingNameRegex(STORE_B, "StoreB");
2082 }
2083
2084 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
2085 static {
2086 storeOfNodes(STORE_B_OF_CLASS, "StoreB");
2087 }
2088
2089 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
2090 static {
2091 beforeMatchingNameRegex(STORE_C, "StoreC");
2092 }
2093
2094 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
2095 static {
2096 storeOfNodes(STORE_C_OF_CLASS, "StoreC");
2097 }
2098
2099 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
2100 static {
2101 beforeMatchingNameRegex(STORE_D, "StoreD");
2102 }
2103
2104 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
2105 static {
2106 storeOfNodes(STORE_D_OF_CLASS, "StoreD");
2107 }
2108
2109 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2110 static {
2111 beforeMatchingNameRegex(STORE_F, "StoreF");
2112 }
2113
2114 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2115 static {
2116 storeOfNodes(STORE_F_OF_CLASS, "StoreF");
2117 }
2118
2119 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2120 static {
2121 beforeMatchingNameRegex(STORE_I, "StoreI");
2122 }
2123
2124 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2125 static {
2126 storeOfNodes(STORE_I_OF_CLASS, "StoreI");
2127 }
2128
2129 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2130 static {
2131 beforeMatchingNameRegex(STORE_L, "StoreL");
2132 }
2133
2134 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2135 static {
2136 storeOfNodes(STORE_L_OF_CLASS, "StoreL");
2137 }
2138
2139 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2140 static {
2141 beforeMatchingNameRegex(STORE_N, "StoreN");
2142 }
2143
2144 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2145 static {
2146 storeOfNodes(STORE_N_OF_CLASS, "StoreN");
2147 }
2148
2149 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2150 static {
2151 storeOfNodes(STORE_OF_CLASS, "Store(B|C|S|I|L|F|D|P|N)");
2152 }
2153
2154 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2155 static {
2156 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2157 beforeMatching(STORE_OF_FIELD, regex);
2158 }
2159
2160 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2161 static {
2162 beforeMatchingNameRegex(STORE_P, "StoreP");
2163 }
2164
2165 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2166 static {
2167 storeOfNodes(STORE_P_OF_CLASS, "StoreP");
2168 }
2169
2170 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2171 static {
2172 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2173 }
2174
2175 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2176 static {
2177 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2178 }
2179
2180 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2181 static {
2182 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2183 }
2184
2185 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2186 static {
2187 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2247 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2248 }
2249
2250 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2251 static {
2252 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2253 }
2254
2255 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2256 static {
2257 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2258 }
2259
2260 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2261 static {
2262 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2263 }
2264
2265 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2266 static {
2267 beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");
2268 }
2269
2270 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2271 static {
2272 trapNodes(TRAP, "reason");
2273 }
2274
2275 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2276 static {
2277 beforeMatchingNameRegex(DIV_HF, "DivHF");
2278 }
2279
2280 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2281 static {
2282 beforeMatchingNameRegex(UDIV_I, "UDivI");
2283 }
2284
2285 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2286 static {
2287 beforeMatchingNameRegex(UDIV_L, "UDivL");
3241 }
3242
3243 public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3244 static {
3245 machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3246 }
3247
3248 public static final String OPAQUE_CONSTANT_BOOL = PREFIX + "OPAQUE_CONSTANT_BOOL" + POSTFIX;
3249 static {
3250 beforeMatchingNameRegex(OPAQUE_CONSTANT_BOOL, "OpaqueConstantBool");
3251 }
3252
3253 /*
3254 * Utility methods to set up IR_NODE_MAPPINGS.
3255 */
3256
3257 /**
3258 * Apply {@code regex} on all machine independent ideal graph phases up to and including
3259 * {@link CompilePhase#BEFORE_MATCHING}.
3260 */
3261 private static void beforeMatching(String irNodePlaceholder, String regex) {
3262 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3263 }
3264
3265 /**
3266 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3267 * including {@link CompilePhase#BEFORE_MATCHING}.
3268 */
3269 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3270 String regex = START + irNodeRegex + MID + END;
3271 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3272 }
3273
3274 /**
3275 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3276 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3277 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3278 */
3279 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3280 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3281 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3282 // IS_REPLACED is later replaced with the specific type and size of the vector.
3283 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
3284 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3285 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3286 }
3287
3288 /**
3289 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3290 */
3291 private static void macroNodes(String irNodePlaceholder, String regex) {
3292 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3293 CompilePhase.BEFORE_STRINGOPTS,
3294 CompilePhase.BEFORE_MACRO_EXPANSION));
3295 }
3296
3297 private static void callOfNodes(String irNodePlaceholder, String callRegex) {
3298 String regex = START + callRegex + MID + IS_REPLACED + " " + END;
3299 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3300 }
3301
3302 /**
3303 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3304 * {@link CompilePhase#MATCHING}.
3305 */
3306 private static void optoOnly(String irNodePlaceholder, String regex) {
3307 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3308 }
3309
3310 private static void machOnly(String irNodePlaceholder, String regex) {
3311 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3312 }
3313
3314 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3315 String regex = START + irNodeRegex + MID + END;
3316 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3317 }
3318
3319 /**
3320 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3321 */
3322 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3323 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3324 CompilePhase.AFTER_CLOOPS,
3325 CompilePhase.FINAL_CODE));
3326 }
3380 // @ptrtype:fully/qualified/package/name/to/TheClass:ptrlattice+12
3381 // with ptrtype being the kind of the type such as instptr, aryptr, etc, and ptrlattice being
3382 // the kind of the value such as BotPTR, NotNull, etc.
3383 // And variation:
3384 // - after ptrtype, we can have "stable:" or other labels, with optional space after ':'
3385 // - the class can actually be a nested class, with $ separator (and it must be ok to give only the deepest one
3386 // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3387 // Worst case, it can be something like:
3388 // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24
3389
3390 // @ matches the start character of the pattern
3391 // (\w+: ?)+ tries to match the pattern 'ptrtype:' or 'stable:' with optional trailing whitespaces
3392 // [\\w/\\$] tries to match the pattern such as 'a/b/', 'a/b', or '/b' but also nested class such as '$c' or '$c$d'
3393 // \b asserts that the next character is a word character
3394 private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)+[\\w/\\$]*\\b";
3395 // ( \([^\)]+\))? tries to match the pattern ' (f/g,h/i/j)'
3396 // :\w+ tries to match the pattern ':NotNull'
3397 // .* tries to match the remaining of the pattern
3398 private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?:\\w+.*";
3399
3400 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
3401 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + IS_REPLACED + LOAD_STORE_SUFFIX + END;
3402 beforeMatching(irNodePlaceholder, regex);
3403 }
3404
3405 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
3406 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + IS_REPLACED + LOAD_STORE_SUFFIX + END;
3407 beforeMatching(irNodePlaceholder, regex);
3408 }
3409
3410 private static void safepointScalarobjectOfNodes(String irNodePlaceholder, String irNodeRegex) {
3411 String regex = START + irNodeRegex + MID + ".*" + IS_REPLACED + ".*" + END;
3412 beforeMatching(irNodePlaceholder, regex);
3413 }
3414
3415 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3416 String regex = START + irNodeRegex + MID + END;
3417 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3418 CompilePhase.BEFORE_REMOVEUSELESS,
3419 CompilePhase.FINAL_CODE));
3420 }
3421
3422 /**
3423 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3424 * first phase that could contain vector nodes from super word.
3425 */
3426 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.network.testvm.java.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";
135 /**
136 * Map every vectorNode to a type string.
137 */
138 private static final Map<String, String> VECTOR_NODE_TYPE = new HashMap<>();
139
140 /*
141 * Start of IR placeholder string definitions followed by a static block defining the regex-for-compile-phase mapping.
142 * An IR node placeholder string must start with PREFIX for normal IR nodes or COMPOSITE_PREFIX for composite IR
143 * nodes, or VECTOR_PREFIX for vector nodes (see class description above).
144 *
145 * An IR node definition looks like this:
146 *
147 * public static final String IR_NODE = [PREFIX|COMPOSITE_PREFIX|VECTOR_PREFIX] + "IR_NODE" + POSTFIX;
148 * static {
149 * // Define IR_NODE to regex-for-compile-phase mapping. Create a new IRNodeMapEntry object and add it to
150 * // IR_NODE_MAPPINGS. This can be done by using the helper methods defined after all IR node placeholder string
151 * // definitions.
152 * }
153 */
154
155 // Valhalla: Make sure that all Valhalla specific IR nodes are also properly initialized. Doing it here also
156 // ensures that the Flag VM is able to pick up the correct compile phases.
157 static {
158 InlineTypeIRNode.forceStaticInitialization();
159 }
160
161 public static final String ABS_D = PREFIX + "ABS_D" + POSTFIX;
162 static {
163 beforeMatchingNameRegex(ABS_D, "AbsD");
164 }
165
166 public static final String ABS_F = PREFIX + "ABS_F" + POSTFIX;
167 static {
168 beforeMatchingNameRegex(ABS_F, "AbsF");
169 }
170
171 public static final String ABS_I = PREFIX + "ABS_I" + POSTFIX;
172 static {
173 beforeMatchingNameRegex(ABS_I, "AbsI");
174 }
175
176 public static final String ABS_L = PREFIX + "ABS_L" + POSTFIX;
177 static {
178 beforeMatchingNameRegex(ABS_L, "AbsL");
179 }
180
382
383 public static final String REARRANGE_VD = VECTOR_PREFIX + "REARRANGE_VD" + POSTFIX;
384 static {
385 vectorNode(REARRANGE_VD, "VectorRearrange", TYPE_DOUBLE);
386 }
387
388 public static final String ADD_P_OF = COMPOSITE_PREFIX + "ADD_P_OF" + POSTFIX;
389 static {
390 String regex = START + "addP_" + IS_REPLACED + MID + ".*" + END;
391 machOnly(ADD_P_OF, regex);
392 }
393
394 public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
395 static {
396 String regex = START + "Allocate\\b" + MID + END;
397 macroNodes(ALLOC, regex);
398 }
399
400 public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
401 static {
402 allocateOfNodes(ALLOC_OF, IS_REPLACED);
403 }
404
405 public static void allocateOfNodes(String irNodePlaceholder, String allocatee) {
406 String regex = START + "Allocate\\b" + MID + "allocationKlass:.*\\b" + allocatee + "\\s.*" + END;
407 macroNodes(irNodePlaceholder, regex);
408 }
409
410 public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
411 static {
412 String regex = START + "AllocateArray\\b" + MID + END;
413 macroNodes(ALLOC_ARRAY, regex);
414 }
415
416 public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
417 static {
418 allocateArrayOfNodes(ALLOC_ARRAY_OF, IS_REPLACED);
419 }
420
421 public static void allocateArrayOfNodes(String irNodePlaceholder, String allocatee) {
422 // Assuming we are looking for an array of "some/package/MyClass". The printout is
423 // [Lsome/package/MyClass;
424 // or, with more dimensions
425 // [[[Lsome/package/MyClass;
426
427 // Case where the searched string is a not fully qualified name (but maybe partially qualified):
428 // package/MyClass or MyClass
429 // The ".*\\b" will eat the "some/" and "some/package/" resp.
430 String partial_name_prefix = ".+\\b";
431
432 // The thing after "allocationKlass:" (the name of the allocated class) is a sequence of:
433 // - a non-empty sequence of "["
434 // - a single character ("L"),
435 // - maybe a non-empty sequence of characters ending on a word boundary
436 // this sequence is omitted if the given name is already fully qualified (exact match)
437 // but will eat the package path prefix in the cases described above
438 // - the name we are looking for
439 // - the final ";".
440 String name_part = "\\[+.(" + partial_name_prefix + ")?" + allocatee + ";";
441 String regex = START + "AllocateArray\\b" + MID + "allocationKlass:" + name_part + ".*" + END;
442 macroNodes(irNodePlaceholder, regex);
443 }
444
445 public static final String OR = PREFIX + "OR" + POSTFIX;
446 static {
447 beforeMatchingNameRegex(OR, "Or(I|L)");
448 }
449
450 public static final String AND = PREFIX + "AND" + POSTFIX;
451 static {
452 beforeMatchingNameRegex(AND, "And(I|L)");
453 }
454
455 public static final String AND_I = PREFIX + "AND_I" + POSTFIX;
456 static {
457 beforeMatchingNameRegex(AND_I, "AndI");
458 }
459
460 public static final String AND_L = PREFIX + "AND_L" + POSTFIX;
461 static {
462 beforeMatchingNameRegex(AND_L, "AndL");
487 vectorNode(AND_VL, "AndV", TYPE_LONG);
488 }
489
490 public static final String AND_V_MASK = PREFIX + "AND_V_MASK" + POSTFIX;
491 static {
492 beforeMatchingNameRegex(AND_V_MASK, "AndVMask");
493 }
494
495 public static final String AND_REDUCTION_V = PREFIX + "AND_REDUCTION_V" + POSTFIX;
496 static {
497 superWordNodes(AND_REDUCTION_V, "AndReductionV");
498 }
499
500 public static final String CALL = PREFIX + "CALL" + POSTFIX;
501 static {
502 beforeMatchingNameRegex(CALL, "Call.*Java");
503 }
504
505 public static final String CALL_OF = COMPOSITE_PREFIX + "CALL_OF" + POSTFIX;
506 static {
507 callOfNodes(CALL_OF, "Call.*", IS_REPLACED + " " );
508 }
509
510 public static final String CALL_OF_METHOD = COMPOSITE_PREFIX + "CALL_OF_METHOD" + POSTFIX;
511 static {
512 callOfNodes(CALL_OF_METHOD, "Call.*Java", IS_REPLACED + " ");
513 }
514
515 public static final String STATIC_CALL = PREFIX + "STATIC_CALL" + POSTFIX;
516 static {
517 beforeMatchingNameRegex(STATIC_CALL, "CallStaticJava");
518 }
519
520 public static final String STATIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "STATIC_CALL_OF_METHOD" + POSTFIX;
521 static {
522 staticCallOfMethodNodes(STATIC_CALL_OF_METHOD, IS_REPLACED + " ");
523 }
524
525 public static void staticCallOfMethodNodes(String irNodePlaceholder, String calleeRegex) {
526 callOfNodes(irNodePlaceholder, "CallStaticJava", calleeRegex);
527 }
528
529 public static final String CALL_LEAF_NO_FP = PREFIX + "CALL_LEAF_NO_FP" + POSTFIX;
530 static {
531 beforeMatchingNameRegex(CALL_LEAF_NO_FP, "CallLeafNoFP");
532 }
533
534 public static final String CALL_LEAF_NO_FP_OF_METHOD = COMPOSITE_PREFIX + "CALL_LEAF_NO_FP_OF_METHOD" + POSTFIX;
535 static {
536 callLeafNoFpOfMethodNodes(CALL_LEAF_NO_FP_OF_METHOD, IS_REPLACED);
537 }
538
539 public static void callLeafNoFpOfMethodNodes(String irNodePlaceholder, String calleeRegex) {
540 callOfNodes(irNodePlaceholder, "CallLeafNoFP", calleeRegex);
541 }
542
543 public static final String CAST_II = PREFIX + "CAST_II" + POSTFIX;
544 static {
545 beforeMatchingNameRegex(CAST_II, "CastII");
546 }
547
548 public static final String CAST_LL = PREFIX + "CAST_LL" + POSTFIX;
549 static {
550 beforeMatchingNameRegex(CAST_LL, "CastLL");
551 }
552
553 public static final String CBNZW_HI = PREFIX + "CBNZW_HI" + POSTFIX;
554 static {
555 optoOnly(CBNZW_HI, "cbwhi");
556 }
557
558 public static final String CBZW_LS = PREFIX + "CBZW_LS" + POSTFIX;
559 static {
560 optoOnly(CBZW_LS, "cbwls");
647 public static final String CMP_UL = PREFIX + "CMP_UL" + POSTFIX;
648 static {
649 beforeMatchingNameRegex(CMP_UL, "CmpUL");
650 }
651
652 public static final String CMP_UL3 = PREFIX + "CMP_UL3" + POSTFIX;
653 static {
654 beforeMatchingNameRegex(CMP_UL3, "CmpUL3");
655 }
656
657 public static final String CMP_P = PREFIX + "CMP_P" + POSTFIX;
658 static {
659 beforeMatchingNameRegex(CMP_P, "CmpP");
660 }
661
662 public static final String CMP_N = PREFIX + "CMP_N" + POSTFIX;
663 static {
664 beforeMatchingNameRegex(CMP_N, "CmpN");
665 }
666
667 public static final String CMP_P_OR_N = PREFIX + "CMP_P_OR_N" + POSTFIX;
668 static {
669 beforeMatchingNameRegex(CMP_P_OR_N, "Cmp(P|N)");
670 }
671
672 public static final String CMP_LT_MASK = PREFIX + "CMP_LT_MASK" + POSTFIX;
673 static {
674 beforeMatchingNameRegex(CMP_LT_MASK, "CmpLTMask");
675 }
676
677 public static final String ROUND_F = PREFIX + "ROUND_F" + POSTFIX;
678 static {
679 beforeMatchingNameRegex(ROUND_F, "RoundF");
680 }
681
682 public static final String ROUND_D = PREFIX + "ROUND_D" + POSTFIX;
683 static {
684 beforeMatchingNameRegex(ROUND_D, "RoundD");
685 }
686
687 public static final String COMPRESS_BITS = PREFIX + "COMPRESS_BITS" + POSTFIX;
688 static {
689 beforeMatchingNameRegex(COMPRESS_BITS, "CompressBits");
690 }
691
816 beforeMatchingNameRegex(DIV_F, "DivF");
817 }
818
819 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
820 static {
821 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
822 }
823
824 public static final String DIV_D = PREFIX + "DIV_D" + POSTFIX;
825 static {
826 beforeMatchingNameRegex(DIV_D, "DivD");
827 }
828
829 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
830 static {
831 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
832 }
833
834 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
835 static {
836 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava", IS_REPLACED);
837 }
838
839 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
840 static {
841 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
842 }
843
844 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
845 static {
846 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
847 }
848
849 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
850 static {
851 String regex = START + "FastUnlock" + MID + END;
852 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
853 }
854
855 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
856 static {
952 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
953 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
954 }
955
956 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
957 static {
958 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
959 }
960
961 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
962 static {
963 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
964 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
965 }
966
967 public static final String IF = PREFIX + "IF" + POSTFIX;
968 static {
969 beforeMatchingNameRegex(IF, "If\\b");
970 }
971
972 public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;
973 static {
974 beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
975 }
976
977 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
978 static {
979 trapNodes(INTRINSIC_TRAP, "intrinsic");
980 }
981
982 // Is only supported on riscv64.
983 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
984 static {
985 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
986 }
987
988 // Is only supported on riscv64.
989 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
990 static {
991 beforeMatchingNameRegex(IS_FINITE_F, "IsFiniteF");
992 }
993
994 public static final String IS_INFINITE_D = PREFIX + "IS_INFINITE_D" + POSTFIX;
995 static {
996 beforeMatchingNameRegex(IS_INFINITE_D, "IsInfiniteD");
997 }
998
999 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
1000 static {
1001 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
1002 }
1003
1004 // Only supported on x86.
1005 public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
1006 static {
1007 machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
1008 }
1009
1010 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
1011 static {
1012 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
1013 }
1014
1015 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
1016 static {
1017 anyLoadOfNodes(LOAD_OF_CLASS, IS_REPLACED);
1018 }
1019
1020 public static void anyLoadOfNodes(String irNodePlaceholder, String fieldHolder) {
1021 loadOfNodes(irNodePlaceholder, "Load(B|UB|S|US|I|L|F|D|P|N)", fieldHolder);
1022 }
1023
1024 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
1025 static {
1026 beforeMatchingNameRegex(LOAD_B, "LoadB");
1027 }
1028
1029 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
1030 static {
1031 loadOfNodes(LOAD_B_OF_CLASS, "LoadB", IS_REPLACED);
1032 }
1033
1034 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
1035 static {
1036 beforeMatchingNameRegex(LOAD_D, "LoadD");
1037 }
1038
1039 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
1040 static {
1041 loadOfNodes(LOAD_D_OF_CLASS, "LoadD", IS_REPLACED);
1042 }
1043
1044 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
1045 static {
1046 beforeMatchingNameRegex(LOAD_F, "LoadF");
1047 }
1048
1049 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
1050 static {
1051 loadOfNodes(LOAD_F_OF_CLASS, "LoadF", IS_REPLACED);
1052 }
1053
1054 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
1055 static {
1056 beforeMatchingNameRegex(LOAD_I, "LoadI");
1057 }
1058
1059 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
1060 static {
1061 loadOfNodes(LOAD_I_OF_CLASS, "LoadI", IS_REPLACED);
1062 }
1063
1064 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
1065 static {
1066 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
1067 }
1068
1069 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
1070 static {
1071 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
1072 }
1073
1074 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
1075 static {
1076 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
1077 }
1078
1079 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
1080 static {
1081 beforeMatchingNameRegex(LOAD_L, "LoadL");
1082 }
1083
1084 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
1085 static {
1086 loadOfNodes(LOAD_L_OF_CLASS, "LoadL", IS_REPLACED);
1087 }
1088
1089 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1090 static {
1091 beforeMatchingNameRegex(LOAD_N, "LoadN");
1092 }
1093
1094 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1095 static {
1096 loadOfNodes(LOAD_N_OF_CLASS, "LoadN", IS_REPLACED);
1097 }
1098
1099 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1100 static {
1101 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1102 beforeMatching(LOAD_OF_FIELD, regex);
1103 }
1104
1105 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1106 static {
1107 beforeMatchingNameRegex(LOAD_P, "LoadP");
1108 }
1109
1110 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1111 static {
1112 loadOfNodes(LOAD_P_OF_CLASS, "LoadP", IS_REPLACED);
1113 }
1114
1115 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1116 static {
1117 beforeMatchingNameRegex(LOAD_S, "LoadS");
1118 }
1119
1120 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1121 static {
1122 loadOfNodes(LOAD_S_OF_CLASS, "LoadS", IS_REPLACED);
1123 }
1124
1125 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1126 static {
1127 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1128 }
1129
1130 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1131 static {
1132 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB", IS_REPLACED);
1133 }
1134
1135 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1136 static {
1137 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1138 }
1139
1140 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1141 static {
1142 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS", IS_REPLACED);
1143 }
1144
1145 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1146 static {
1147 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1148 }
1149
1150 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1151 static {
1152 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1153 }
1154
1155 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1156 static {
1157 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1158 }
1159
1160 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1161 static {
1162 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
2118 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
2119 }
2120
2121 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
2122 static {
2123 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
2124 }
2125
2126 public static final String STORE = PREFIX + "STORE" + POSTFIX;
2127 static {
2128 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
2129 }
2130
2131 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
2132 static {
2133 beforeMatchingNameRegex(STORE_B, "StoreB");
2134 }
2135
2136 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
2137 static {
2138 storeOfNodes(STORE_B_OF_CLASS, "StoreB", IS_REPLACED);
2139 }
2140
2141 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
2142 static {
2143 beforeMatchingNameRegex(STORE_C, "StoreC");
2144 }
2145
2146 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
2147 static {
2148 storeOfNodes(STORE_C_OF_CLASS, "StoreC", IS_REPLACED);
2149 }
2150
2151 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
2152 static {
2153 beforeMatchingNameRegex(STORE_D, "StoreD");
2154 }
2155
2156 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
2157 static {
2158 storeOfNodes(STORE_D_OF_CLASS, "StoreD", IS_REPLACED);
2159 }
2160
2161 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2162 static {
2163 beforeMatchingNameRegex(STORE_F, "StoreF");
2164 }
2165
2166 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2167 static {
2168 storeOfNodes(STORE_F_OF_CLASS, "StoreF", IS_REPLACED);
2169 }
2170
2171 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2172 static {
2173 beforeMatchingNameRegex(STORE_I, "StoreI");
2174 }
2175
2176 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2177 static {
2178 storeOfNodes(STORE_I_OF_CLASS, "StoreI", IS_REPLACED);
2179 }
2180
2181 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2182 static {
2183 beforeMatchingNameRegex(STORE_L, "StoreL");
2184 }
2185
2186 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2187 static {
2188 storeOfNodes(STORE_L_OF_CLASS, "StoreL", IS_REPLACED);
2189 }
2190
2191 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2192 static {
2193 beforeMatchingNameRegex(STORE_N, "StoreN");
2194 }
2195
2196 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2197 static {
2198 storeOfNodes(STORE_N_OF_CLASS, "StoreN", IS_REPLACED);
2199 }
2200
2201 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2202 static {
2203 anyStoreOfNodes(STORE_OF_CLASS, IS_REPLACED);
2204 }
2205
2206 public static void anyStoreOfNodes(String irNodePlaceholder, String fieldHolder) {
2207 storeOfNodes(irNodePlaceholder, "Store(B|C|S|I|L|F|D|P|N)", fieldHolder);
2208 }
2209
2210 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2211 static {
2212 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2213 beforeMatching(STORE_OF_FIELD, regex);
2214 }
2215
2216 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2217 static {
2218 beforeMatchingNameRegex(STORE_P, "StoreP");
2219 }
2220
2221 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2222 static {
2223 storeOfNodes(STORE_P_OF_CLASS, "StoreP", IS_REPLACED);
2224 }
2225
2226 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2227 static {
2228 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2229 }
2230
2231 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2232 static {
2233 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2234 }
2235
2236 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2237 static {
2238 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2239 }
2240
2241 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2242 static {
2243 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2303 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2304 }
2305
2306 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2307 static {
2308 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2309 }
2310
2311 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2312 static {
2313 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2314 }
2315
2316 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2317 static {
2318 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2319 }
2320
2321 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2322 static {
2323 String regex = START + "SubTypeCheck" + MID + END;
2324 macroNodes(SUBTYPE_CHECK, regex);
2325 }
2326
2327 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2328 static {
2329 trapNodes(TRAP, "reason");
2330 }
2331
2332 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2333 static {
2334 beforeMatchingNameRegex(DIV_HF, "DivHF");
2335 }
2336
2337 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2338 static {
2339 beforeMatchingNameRegex(UDIV_I, "UDivI");
2340 }
2341
2342 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2343 static {
2344 beforeMatchingNameRegex(UDIV_L, "UDivL");
3298 }
3299
3300 public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3301 static {
3302 machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3303 }
3304
3305 public static final String OPAQUE_CONSTANT_BOOL = PREFIX + "OPAQUE_CONSTANT_BOOL" + POSTFIX;
3306 static {
3307 beforeMatchingNameRegex(OPAQUE_CONSTANT_BOOL, "OpaqueConstantBool");
3308 }
3309
3310 /*
3311 * Utility methods to set up IR_NODE_MAPPINGS.
3312 */
3313
3314 /**
3315 * Apply {@code regex} on all machine independent ideal graph phases up to and including
3316 * {@link CompilePhase#BEFORE_MATCHING}.
3317 */
3318 public static void beforeMatching(String irNodePlaceholder, String regex) {
3319 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3320 }
3321
3322 /**
3323 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3324 * including {@link CompilePhase#BEFORE_MATCHING}.
3325 */
3326 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3327 String regex = START + irNodeRegex + MID + END;
3328 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3329 }
3330
3331 /**
3332 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3333 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3334 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3335 */
3336 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3337 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3338 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3339 // IS_REPLACED is later replaced with the specific type and size of the vector.
3340 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
3341 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3342 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3343 }
3344
3345 /**
3346 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3347 */
3348 private static void macroNodes(String irNodePlaceholder, String regex) {
3349 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3350 CompilePhase.BEFORE_STRINGOPTS,
3351 CompilePhase.BEFORE_MACRO_EXPANSION));
3352 }
3353
3354 private static void callOfNodes(String irNodePlaceholder, String callRegex, String calleeRegex) {
3355 String regex = START + callRegex + MID + calleeRegex + END;
3356 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3357 }
3358
3359 /**
3360 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3361 * {@link CompilePhase#MATCHING}.
3362 */
3363 public static void optoOnly(String irNodePlaceholder, String regex) {
3364 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3365 }
3366
3367 private static void machOnly(String irNodePlaceholder, String regex) {
3368 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3369 }
3370
3371 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3372 String regex = START + irNodeRegex + MID + END;
3373 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3374 }
3375
3376 /**
3377 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3378 */
3379 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3380 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3381 CompilePhase.AFTER_CLOOPS,
3382 CompilePhase.FINAL_CODE));
3383 }
3437 // @ptrtype:fully/qualified/package/name/to/TheClass:ptrlattice+12
3438 // with ptrtype being the kind of the type such as instptr, aryptr, etc, and ptrlattice being
3439 // the kind of the value such as BotPTR, NotNull, etc.
3440 // And variation:
3441 // - after ptrtype, we can have "stable:" or other labels, with optional space after ':'
3442 // - the class can actually be a nested class, with $ separator (and it must be ok to give only the deepest one
3443 // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3444 // Worst case, it can be something like:
3445 // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24
3446
3447 // @ matches the start character of the pattern
3448 // (\w+: ?)+ tries to match the pattern 'ptrtype:' or 'stable:' with optional trailing whitespaces
3449 // [\\w/\\$] tries to match the pattern such as 'a/b/', 'a/b', or '/b' but also nested class such as '$c' or '$c$d'
3450 // \b asserts that the next character is a word character
3451 private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)+[\\w/\\$]*\\b";
3452 // ( \([^\)]+\))? tries to match the pattern ' (f/g,h/i/j)'
3453 // :\w+ tries to match the pattern ':NotNull'
3454 // .* tries to match the remaining of the pattern
3455 private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?:\\w+.*";
3456
3457 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex, String loadee) {
3458 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + loadee + LOAD_STORE_SUFFIX + END;
3459 beforeMatching(irNodePlaceholder, regex);
3460 }
3461
3462 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex, String storee) {
3463 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + storee + LOAD_STORE_SUFFIX + END;
3464 beforeMatching(irNodePlaceholder, regex);
3465 }
3466
3467 private static void safepointScalarobjectOfNodes(String irNodePlaceholder, String irNodeRegex) {
3468 String regex = START + irNodeRegex + MID + ".*" + IS_REPLACED + ".*" + END;
3469 beforeMatching(irNodePlaceholder, regex);
3470 }
3471
3472 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3473 String regex = START + irNodeRegex + MID + END;
3474 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3475 CompilePhase.BEFORE_REMOVEUSELESS,
3476 CompilePhase.FINAL_CODE));
3477 }
3478
3479 /**
3480 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3481 * first phase that could contain vector nodes from super word.
3482 */
3483 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
|