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");
568 public static final String CMP_U3 = PREFIX + "CMP_U3" + POSTFIX;
569 static {
570 beforeMatchingNameRegex(CMP_U3, "CmpU3");
571 }
572
573 public static final String CMP_UL = PREFIX + "CMP_UL" + POSTFIX;
574 static {
575 beforeMatchingNameRegex(CMP_UL, "CmpUL");
576 }
577
578 public static final String CMP_UL3 = PREFIX + "CMP_UL3" + POSTFIX;
579 static {
580 beforeMatchingNameRegex(CMP_UL3, "CmpUL3");
581 }
582
583 public static final String CMP_P = PREFIX + "CMP_P" + POSTFIX;
584 static {
585 beforeMatchingNameRegex(CMP_P, "CmpP");
586 }
587
588 public static final String CMP_LT_MASK = PREFIX + "CMP_LT_MASK" + POSTFIX;
589 static {
590 beforeMatchingNameRegex(CMP_LT_MASK, "CmpLTMask");
591 }
592
593 public static final String ROUND_F = PREFIX + "ROUND_F" + POSTFIX;
594 static {
595 beforeMatchingNameRegex(ROUND_F, "RoundF");
596 }
597
598 public static final String ROUND_D = PREFIX + "ROUND_D" + POSTFIX;
599 static {
600 beforeMatchingNameRegex(ROUND_D, "RoundD");
601 }
602
603 public static final String COMPRESS_BITS = PREFIX + "COMPRESS_BITS" + POSTFIX;
604 static {
605 beforeMatchingNameRegex(COMPRESS_BITS, "CompressBits");
606 }
607
722 beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
723 }
724
725 public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
726 static {
727 vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
728 }
729
730 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
731 static {
732 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
733 }
734
735 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
736 static {
737 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
738 }
739
740 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
741 static {
742 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava");
743 }
744
745 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
746 static {
747 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
748 }
749
750 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
751 static {
752 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
753 }
754
755 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
756 static {
757 String regex = START + "FastUnlock" + MID + END;
758 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
759 }
760
761 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
762 static {
858 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
859 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
860 }
861
862 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
863 static {
864 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
865 }
866
867 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
868 static {
869 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
870 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
871 }
872
873 public static final String IF = PREFIX + "IF" + POSTFIX;
874 static {
875 beforeMatchingNameRegex(IF, "If\\b");
876 }
877
878 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
879 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
880 static {
881 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
882 }
883
884 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
885 static {
886 trapNodes(INTRINSIC_TRAP, "intrinsic");
887 }
888
889 // Is only supported on riscv64.
890 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
891 static {
892 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
893 }
894
895 // Is only supported on riscv64.
896 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
897 static {
904 }
905
906 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
907 static {
908 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
909 }
910
911 // Only supported on x86.
912 public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
913 static {
914 machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
915 }
916
917 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
918 static {
919 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
920 }
921
922 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
923 static {
924 loadOfNodes(LOAD_OF_CLASS, "Load(B|UB|S|US|I|L|F|D|P|N)");
925 }
926
927 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
928 static {
929 beforeMatchingNameRegex(LOAD_B, "LoadB");
930 }
931
932 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
933 static {
934 loadOfNodes(LOAD_B_OF_CLASS, "LoadB");
935 }
936
937 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
938 static {
939 beforeMatchingNameRegex(LOAD_D, "LoadD");
940 }
941
942 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
943 static {
944 loadOfNodes(LOAD_D_OF_CLASS, "LoadD");
945 }
946
947 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
948 static {
949 beforeMatchingNameRegex(LOAD_F, "LoadF");
950 }
951
952 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
953 static {
954 loadOfNodes(LOAD_F_OF_CLASS, "LoadF");
955 }
956
957 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
958 static {
959 beforeMatchingNameRegex(LOAD_I, "LoadI");
960 }
961
962 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
963 static {
964 loadOfNodes(LOAD_I_OF_CLASS, "LoadI");
965 }
966
967 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
968 static {
969 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
970 }
971
972 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
973 static {
974 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
975 }
976
977 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
978 static {
979 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
980 }
981
982 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
983 static {
984 beforeMatchingNameRegex(LOAD_L, "LoadL");
985 }
986
987 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
988 static {
989 loadOfNodes(LOAD_L_OF_CLASS, "LoadL");
990 }
991
992 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
993 static {
994 beforeMatchingNameRegex(LOAD_N, "LoadN");
995 }
996
997 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
998 static {
999 loadOfNodes(LOAD_N_OF_CLASS, "LoadN");
1000 }
1001
1002 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1003 static {
1004 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1005 beforeMatching(LOAD_OF_FIELD, regex);
1006 }
1007
1008 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1009 static {
1010 beforeMatchingNameRegex(LOAD_P, "LoadP");
1011 }
1012
1013 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1014 static {
1015 loadOfNodes(LOAD_P_OF_CLASS, "LoadP");
1016 }
1017
1018 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1019 static {
1020 beforeMatchingNameRegex(LOAD_S, "LoadS");
1021 }
1022
1023 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1024 static {
1025 loadOfNodes(LOAD_S_OF_CLASS, "LoadS");
1026 }
1027
1028 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1029 static {
1030 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1031 }
1032
1033 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1034 static {
1035 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB");
1036 }
1037
1038 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1039 static {
1040 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1041 }
1042
1043 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1044 static {
1045 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS");
1046 }
1047
1048 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1049 static {
1050 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1051 }
1052
1053 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1054 static {
1055 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1056 }
1057
1058 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1059 static {
1060 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1061 }
1062
1063 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1064 static {
1065 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
1929 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
1930 }
1931
1932 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
1933 static {
1934 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
1935 }
1936
1937 public static final String STORE = PREFIX + "STORE" + POSTFIX;
1938 static {
1939 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
1940 }
1941
1942 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
1943 static {
1944 beforeMatchingNameRegex(STORE_B, "StoreB");
1945 }
1946
1947 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
1948 static {
1949 storeOfNodes(STORE_B_OF_CLASS, "StoreB");
1950 }
1951
1952 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
1953 static {
1954 beforeMatchingNameRegex(STORE_C, "StoreC");
1955 }
1956
1957 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
1958 static {
1959 storeOfNodes(STORE_C_OF_CLASS, "StoreC");
1960 }
1961
1962 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
1963 static {
1964 beforeMatchingNameRegex(STORE_D, "StoreD");
1965 }
1966
1967 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
1968 static {
1969 storeOfNodes(STORE_D_OF_CLASS, "StoreD");
1970 }
1971
1972 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
1973 static {
1974 beforeMatchingNameRegex(STORE_F, "StoreF");
1975 }
1976
1977 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
1978 static {
1979 storeOfNodes(STORE_F_OF_CLASS, "StoreF");
1980 }
1981
1982 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
1983 static {
1984 beforeMatchingNameRegex(STORE_I, "StoreI");
1985 }
1986
1987 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
1988 static {
1989 storeOfNodes(STORE_I_OF_CLASS, "StoreI");
1990 }
1991
1992 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
1993 static {
1994 beforeMatchingNameRegex(STORE_L, "StoreL");
1995 }
1996
1997 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
1998 static {
1999 storeOfNodes(STORE_L_OF_CLASS, "StoreL");
2000 }
2001
2002 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2003 static {
2004 beforeMatchingNameRegex(STORE_N, "StoreN");
2005 }
2006
2007 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2008 static {
2009 storeOfNodes(STORE_N_OF_CLASS, "StoreN");
2010 }
2011
2012 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2013 static {
2014 storeOfNodes(STORE_OF_CLASS, "Store(B|C|S|I|L|F|D|P|N)");
2015 }
2016
2017 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2018 static {
2019 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2020 beforeMatching(STORE_OF_FIELD, regex);
2021 }
2022
2023 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2024 static {
2025 beforeMatchingNameRegex(STORE_P, "StoreP");
2026 }
2027
2028 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2029 static {
2030 storeOfNodes(STORE_P_OF_CLASS, "StoreP");
2031 }
2032
2033 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2034 static {
2035 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2036 }
2037
2038 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2039 static {
2040 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2041 }
2042
2043 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2044 static {
2045 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2046 }
2047
2048 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2049 static {
2050 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2100 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2101 }
2102
2103 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2104 static {
2105 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2106 }
2107
2108 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2109 static {
2110 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2111 }
2112
2113 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2114 static {
2115 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2116 }
2117
2118 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2119 static {
2120 beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");
2121 }
2122
2123 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2124 static {
2125 trapNodes(TRAP, "reason");
2126 }
2127
2128 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2129 static {
2130 beforeMatchingNameRegex(DIV_HF, "DivHF");
2131 }
2132
2133 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2134 static {
2135 beforeMatchingNameRegex(UDIV_I, "UDivI");
2136 }
2137
2138 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2139 static {
2140 beforeMatchingNameRegex(UDIV_L, "UDivL");
3022 }
3023
3024 public static final String REPLICATE_HF = PREFIX + "REPLICATE_HF" + POSTFIX;
3025 static {
3026 machOnlyNameRegex(REPLICATE_HF, "replicateHF");
3027 }
3028
3029 public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3030 static {
3031 machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3032 }
3033
3034 /*
3035 * Utility methods to set up IR_NODE_MAPPINGS.
3036 */
3037
3038 /**
3039 * Apply {@code regex} on all machine independent ideal graph phases up to and including
3040 * {@link CompilePhase#BEFORE_MATCHING}.
3041 */
3042 private static void beforeMatching(String irNodePlaceholder, String regex) {
3043 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3044 }
3045
3046 /**
3047 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3048 * including {@link CompilePhase#BEFORE_MATCHING}.
3049 */
3050 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3051 String regex = START + irNodeRegex + MID + END;
3052 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3053 }
3054
3055 /**
3056 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3057 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3058 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3059 */
3060 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3061 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3062 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3063 // IS_REPLACED is later replaced with the specific type and size of the vector.
3064 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
3065 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3066 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3067 }
3068
3069 /**
3070 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3071 */
3072 private static void macroNodes(String irNodePlaceholder, String regex) {
3073 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3074 CompilePhase.BEFORE_STRINGOPTS,
3075 CompilePhase.BEFORE_MACRO_EXPANSION));
3076 }
3077
3078 private static void callOfNodes(String irNodePlaceholder, String callRegex) {
3079 String regex = START + callRegex + MID + IS_REPLACED + " " + END;
3080 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3081 }
3082
3083 /**
3084 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3085 * {@link CompilePhase#MATCHING}.
3086 */
3087 private static void optoOnly(String irNodePlaceholder, String regex) {
3088 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3089 }
3090
3091 private static void machOnly(String irNodePlaceholder, String regex) {
3092 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3093 }
3094
3095 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3096 String regex = START + irNodeRegex + MID + END;
3097 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3098 }
3099
3100 /**
3101 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3102 */
3103 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3104 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3105 CompilePhase.AFTER_CLOOPS,
3106 CompilePhase.FINAL_CODE));
3107 }
3152
3153 private static void parsePredicateNodes(String irNodePlaceholder, String label) {
3154 String regex = START + "ParsePredicate" + MID + "#" + label + " " + END;
3155 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_PARSING, regex,
3156 CompilePhase.AFTER_PARSING,
3157 CompilePhase.AFTER_LOOP_OPTS));
3158 }
3159
3160 // Typename in load/store have the structure:
3161 // @fully/qualified/package/name/to/TheClass+12 *
3162 // And variation:
3163 // - after @, we can have "stable:" or other labels, with optional space after ':'
3164 // - the class can actually be a subclass, with $ separator (and it must be ok to give only the deepest one
3165 // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3166 // - before the offset, we can have something like ":NotNull", either way, seeing "+" or ":" means the end of the type
3167 // Worst case, it can be something like:
3168 // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24 *
3169 private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)*[\\w/\\$]*\\b";
3170 private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?(:|\\+)\\S* \\*";
3171
3172 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
3173 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + IS_REPLACED + LOAD_STORE_SUFFIX + END;
3174 beforeMatching(irNodePlaceholder, regex);
3175 }
3176
3177 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
3178 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + IS_REPLACED + LOAD_STORE_SUFFIX + END;
3179 beforeMatching(irNodePlaceholder, regex);
3180 }
3181
3182 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3183 String regex = START + irNodeRegex + MID + END;
3184 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3185 CompilePhase.BEFORE_REMOVEUSELESS,
3186 CompilePhase.FINAL_CODE));
3187 }
3188
3189 /**
3190 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3191 * first phase that could contain vector nodes from super word.
3192 */
3193 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
3194 String regex = START + irNodeRegex + MID + END;
3195 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3196 CompilePhase.PHASEIDEALLOOP1,
3197 CompilePhase.BEFORE_MATCHING));
3198 }
|
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");
606 public static final String CMP_U3 = PREFIX + "CMP_U3" + POSTFIX;
607 static {
608 beforeMatchingNameRegex(CMP_U3, "CmpU3");
609 }
610
611 public static final String CMP_UL = PREFIX + "CMP_UL" + POSTFIX;
612 static {
613 beforeMatchingNameRegex(CMP_UL, "CmpUL");
614 }
615
616 public static final String CMP_UL3 = PREFIX + "CMP_UL3" + POSTFIX;
617 static {
618 beforeMatchingNameRegex(CMP_UL3, "CmpUL3");
619 }
620
621 public static final String CMP_P = PREFIX + "CMP_P" + POSTFIX;
622 static {
623 beforeMatchingNameRegex(CMP_P, "CmpP");
624 }
625
626 public static final String CMP_N = PREFIX + "CMP_N" + POSTFIX;
627 static {
628 beforeMatchingNameRegex(CMP_N, "CmpN");
629 }
630
631 public static final String CMP_LT_MASK = PREFIX + "CMP_LT_MASK" + POSTFIX;
632 static {
633 beforeMatchingNameRegex(CMP_LT_MASK, "CmpLTMask");
634 }
635
636 public static final String ROUND_F = PREFIX + "ROUND_F" + POSTFIX;
637 static {
638 beforeMatchingNameRegex(ROUND_F, "RoundF");
639 }
640
641 public static final String ROUND_D = PREFIX + "ROUND_D" + POSTFIX;
642 static {
643 beforeMatchingNameRegex(ROUND_D, "RoundD");
644 }
645
646 public static final String COMPRESS_BITS = PREFIX + "COMPRESS_BITS" + POSTFIX;
647 static {
648 beforeMatchingNameRegex(COMPRESS_BITS, "CompressBits");
649 }
650
765 beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
766 }
767
768 public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
769 static {
770 vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
771 }
772
773 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
774 static {
775 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
776 }
777
778 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
779 static {
780 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
781 }
782
783 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
784 static {
785 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava", IS_REPLACED);
786 }
787
788 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
789 static {
790 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
791 }
792
793 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
794 static {
795 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
796 }
797
798 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
799 static {
800 String regex = START + "FastUnlock" + MID + END;
801 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
802 }
803
804 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
805 static {
901 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
902 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
903 }
904
905 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
906 static {
907 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
908 }
909
910 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
911 static {
912 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
913 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
914 }
915
916 public static final String IF = PREFIX + "IF" + POSTFIX;
917 static {
918 beforeMatchingNameRegex(IF, "If\\b");
919 }
920
921 public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;
922 static {
923 beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
924 }
925
926 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
927 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
928 static {
929 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
930 }
931
932 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
933 static {
934 trapNodes(INTRINSIC_TRAP, "intrinsic");
935 }
936
937 // Is only supported on riscv64.
938 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
939 static {
940 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
941 }
942
943 // Is only supported on riscv64.
944 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
945 static {
952 }
953
954 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
955 static {
956 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
957 }
958
959 // Only supported on x86.
960 public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
961 static {
962 machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
963 }
964
965 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
966 static {
967 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
968 }
969
970 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
971 static {
972 anyLoadOfNodes(LOAD_OF_CLASS, IS_REPLACED);
973 }
974
975 public static void anyLoadOfNodes(String irNodePlaceholder, String fieldHolder) {
976 loadOfNodes(irNodePlaceholder, "Load(B|UB|S|US|I|L|F|D|P|N)", fieldHolder);
977 }
978
979 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
980 static {
981 beforeMatchingNameRegex(LOAD_B, "LoadB");
982 }
983
984 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
985 static {
986 loadOfNodes(LOAD_B_OF_CLASS, "LoadB", IS_REPLACED);
987 }
988
989 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
990 static {
991 beforeMatchingNameRegex(LOAD_D, "LoadD");
992 }
993
994 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
995 static {
996 loadOfNodes(LOAD_D_OF_CLASS, "LoadD", IS_REPLACED);
997 }
998
999 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
1000 static {
1001 beforeMatchingNameRegex(LOAD_F, "LoadF");
1002 }
1003
1004 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
1005 static {
1006 loadOfNodes(LOAD_F_OF_CLASS, "LoadF", IS_REPLACED);
1007 }
1008
1009 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
1010 static {
1011 beforeMatchingNameRegex(LOAD_I, "LoadI");
1012 }
1013
1014 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
1015 static {
1016 loadOfNodes(LOAD_I_OF_CLASS, "LoadI", IS_REPLACED);
1017 }
1018
1019 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
1020 static {
1021 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
1022 }
1023
1024 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
1025 static {
1026 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
1027 }
1028
1029 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
1030 static {
1031 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
1032 }
1033
1034 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
1035 static {
1036 beforeMatchingNameRegex(LOAD_L, "LoadL");
1037 }
1038
1039 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
1040 static {
1041 loadOfNodes(LOAD_L_OF_CLASS, "LoadL", IS_REPLACED);
1042 }
1043
1044 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1045 static {
1046 beforeMatchingNameRegex(LOAD_N, "LoadN");
1047 }
1048
1049 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1050 static {
1051 loadOfNodes(LOAD_N_OF_CLASS, "LoadN", IS_REPLACED);
1052 }
1053
1054 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1055 static {
1056 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1057 beforeMatching(LOAD_OF_FIELD, regex);
1058 }
1059
1060 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1061 static {
1062 beforeMatchingNameRegex(LOAD_P, "LoadP");
1063 }
1064
1065 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1066 static {
1067 loadOfNodes(LOAD_P_OF_CLASS, "LoadP", IS_REPLACED);
1068 }
1069
1070 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1071 static {
1072 beforeMatchingNameRegex(LOAD_S, "LoadS");
1073 }
1074
1075 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1076 static {
1077 loadOfNodes(LOAD_S_OF_CLASS, "LoadS", IS_REPLACED);
1078 }
1079
1080 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1081 static {
1082 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1083 }
1084
1085 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1086 static {
1087 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB", IS_REPLACED);
1088 }
1089
1090 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1091 static {
1092 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1093 }
1094
1095 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1096 static {
1097 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS", IS_REPLACED);
1098 }
1099
1100 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1101 static {
1102 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1103 }
1104
1105 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1106 static {
1107 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1108 }
1109
1110 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1111 static {
1112 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1113 }
1114
1115 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1116 static {
1117 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
1981 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
1982 }
1983
1984 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
1985 static {
1986 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
1987 }
1988
1989 public static final String STORE = PREFIX + "STORE" + POSTFIX;
1990 static {
1991 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
1992 }
1993
1994 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
1995 static {
1996 beforeMatchingNameRegex(STORE_B, "StoreB");
1997 }
1998
1999 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
2000 static {
2001 storeOfNodes(STORE_B_OF_CLASS, "StoreB", IS_REPLACED);
2002 }
2003
2004 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
2005 static {
2006 beforeMatchingNameRegex(STORE_C, "StoreC");
2007 }
2008
2009 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
2010 static {
2011 storeOfNodes(STORE_C_OF_CLASS, "StoreC", IS_REPLACED);
2012 }
2013
2014 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
2015 static {
2016 beforeMatchingNameRegex(STORE_D, "StoreD");
2017 }
2018
2019 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
2020 static {
2021 storeOfNodes(STORE_D_OF_CLASS, "StoreD", IS_REPLACED);
2022 }
2023
2024 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2025 static {
2026 beforeMatchingNameRegex(STORE_F, "StoreF");
2027 }
2028
2029 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2030 static {
2031 storeOfNodes(STORE_F_OF_CLASS, "StoreF", IS_REPLACED);
2032 }
2033
2034 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2035 static {
2036 beforeMatchingNameRegex(STORE_I, "StoreI");
2037 }
2038
2039 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2040 static {
2041 storeOfNodes(STORE_I_OF_CLASS, "StoreI", IS_REPLACED);
2042 }
2043
2044 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2045 static {
2046 beforeMatchingNameRegex(STORE_L, "StoreL");
2047 }
2048
2049 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2050 static {
2051 storeOfNodes(STORE_L_OF_CLASS, "StoreL", IS_REPLACED);
2052 }
2053
2054 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2055 static {
2056 beforeMatchingNameRegex(STORE_N, "StoreN");
2057 }
2058
2059 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2060 static {
2061 storeOfNodes(STORE_N_OF_CLASS, "StoreN", IS_REPLACED);
2062 }
2063
2064 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2065 static {
2066 anyStoreOfNodes(STORE_OF_CLASS, IS_REPLACED);
2067 }
2068
2069 public static void anyStoreOfNodes(String irNodePlaceholder, String fieldHolder) {
2070 storeOfNodes(irNodePlaceholder, "Store(B|C|S|I|L|F|D|P|N)", fieldHolder);
2071 }
2072
2073 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2074 static {
2075 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2076 beforeMatching(STORE_OF_FIELD, regex);
2077 }
2078
2079 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2080 static {
2081 beforeMatchingNameRegex(STORE_P, "StoreP");
2082 }
2083
2084 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2085 static {
2086 storeOfNodes(STORE_P_OF_CLASS, "StoreP", IS_REPLACED);
2087 }
2088
2089 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2090 static {
2091 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2092 }
2093
2094 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2095 static {
2096 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2097 }
2098
2099 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2100 static {
2101 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2102 }
2103
2104 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2105 static {
2106 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2156 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2157 }
2158
2159 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2160 static {
2161 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2162 }
2163
2164 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2165 static {
2166 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2167 }
2168
2169 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2170 static {
2171 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2172 }
2173
2174 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2175 static {
2176 String regex = START + "SubTypeCheck" + MID + END;
2177 macroNodes(SUBTYPE_CHECK, regex);
2178 }
2179
2180 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2181 static {
2182 trapNodes(TRAP, "reason");
2183 }
2184
2185 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2186 static {
2187 beforeMatchingNameRegex(DIV_HF, "DivHF");
2188 }
2189
2190 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2191 static {
2192 beforeMatchingNameRegex(UDIV_I, "UDivI");
2193 }
2194
2195 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2196 static {
2197 beforeMatchingNameRegex(UDIV_L, "UDivL");
3079 }
3080
3081 public static final String REPLICATE_HF = PREFIX + "REPLICATE_HF" + POSTFIX;
3082 static {
3083 machOnlyNameRegex(REPLICATE_HF, "replicateHF");
3084 }
3085
3086 public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3087 static {
3088 machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3089 }
3090
3091 /*
3092 * Utility methods to set up IR_NODE_MAPPINGS.
3093 */
3094
3095 /**
3096 * Apply {@code regex} on all machine independent ideal graph phases up to and including
3097 * {@link CompilePhase#BEFORE_MATCHING}.
3098 */
3099 public static void beforeMatching(String irNodePlaceholder, String regex) {
3100 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3101 }
3102
3103 /**
3104 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3105 * including {@link CompilePhase#BEFORE_MATCHING}.
3106 */
3107 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3108 String regex = START + irNodeRegex + MID + END;
3109 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3110 }
3111
3112 /**
3113 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3114 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3115 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3116 */
3117 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3118 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3119 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3120 // IS_REPLACED is later replaced with the specific type and size of the vector.
3121 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
3122 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3123 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3124 }
3125
3126 /**
3127 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3128 */
3129 private static void macroNodes(String irNodePlaceholder, String regex) {
3130 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3131 CompilePhase.BEFORE_STRINGOPTS,
3132 CompilePhase.BEFORE_MACRO_EXPANSION));
3133 }
3134
3135 private static void callOfNodes(String irNodePlaceholder, String callRegex, String calleeRegex) {
3136 String regex = START + callRegex + MID + calleeRegex + END;
3137 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3138 }
3139
3140 /**
3141 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3142 * {@link CompilePhase#MATCHING}.
3143 */
3144 public static void optoOnly(String irNodePlaceholder, String regex) {
3145 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3146 }
3147
3148 private static void machOnly(String irNodePlaceholder, String regex) {
3149 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3150 }
3151
3152 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3153 String regex = START + irNodeRegex + MID + END;
3154 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3155 }
3156
3157 /**
3158 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3159 */
3160 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3161 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3162 CompilePhase.AFTER_CLOOPS,
3163 CompilePhase.FINAL_CODE));
3164 }
3209
3210 private static void parsePredicateNodes(String irNodePlaceholder, String label) {
3211 String regex = START + "ParsePredicate" + MID + "#" + label + " " + END;
3212 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_PARSING, regex,
3213 CompilePhase.AFTER_PARSING,
3214 CompilePhase.AFTER_LOOP_OPTS));
3215 }
3216
3217 // Typename in load/store have the structure:
3218 // @fully/qualified/package/name/to/TheClass+12 *
3219 // And variation:
3220 // - after @, we can have "stable:" or other labels, with optional space after ':'
3221 // - the class can actually be a subclass, with $ separator (and it must be ok to give only the deepest one
3222 // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3223 // - before the offset, we can have something like ":NotNull", either way, seeing "+" or ":" means the end of the type
3224 // Worst case, it can be something like:
3225 // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24 *
3226 private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)*[\\w/\\$]*\\b";
3227 private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?(:|\\+)\\S* \\*";
3228
3229 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex, String loadee) {
3230 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + loadee + LOAD_STORE_SUFFIX + END;
3231 beforeMatching(irNodePlaceholder, regex);
3232 }
3233
3234 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex, String storee) {
3235 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + storee + LOAD_STORE_SUFFIX + END;
3236 beforeMatching(irNodePlaceholder, regex);
3237 }
3238
3239 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3240 String regex = START + irNodeRegex + MID + END;
3241 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3242 CompilePhase.BEFORE_REMOVEUSELESS,
3243 CompilePhase.FINAL_CODE));
3244 }
3245
3246 /**
3247 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3248 * first phase that could contain vector nodes from super word.
3249 */
3250 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
3251 String regex = START + irNodeRegex + MID + END;
3252 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3253 CompilePhase.PHASEIDEALLOOP1,
3254 CompilePhase.BEFORE_MATCHING));
3255 }
|