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
702 beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
703 }
704
705 public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
706 static {
707 vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
708 }
709
710 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
711 static {
712 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
713 }
714
715 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
716 static {
717 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
718 }
719
720 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
721 static {
722 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava");
723 }
724
725 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
726 static {
727 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
728 }
729
730 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
731 static {
732 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
733 }
734
735 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
736 static {
737 String regex = START + "FastUnlock" + MID + END;
738 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
739 }
740
741 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
742 static {
838 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
839 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
840 }
841
842 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
843 static {
844 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
845 }
846
847 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
848 static {
849 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
850 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
851 }
852
853 public static final String IF = PREFIX + "IF" + POSTFIX;
854 static {
855 beforeMatchingNameRegex(IF, "If\\b");
856 }
857
858 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
859 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
860 static {
861 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
862 }
863
864 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
865 static {
866 trapNodes(INTRINSIC_TRAP, "intrinsic");
867 }
868
869 // Is only supported on riscv64.
870 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
871 static {
872 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
873 }
874
875 // Is only supported on riscv64.
876 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
877 static {
884 }
885
886 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
887 static {
888 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
889 }
890
891 // Only supported on x86.
892 public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
893 static {
894 machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
895 }
896
897 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
898 static {
899 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
900 }
901
902 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
903 static {
904 loadOfNodes(LOAD_OF_CLASS, "Load(B|UB|S|US|I|L|F|D|P|N)");
905 }
906
907 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
908 static {
909 beforeMatchingNameRegex(LOAD_B, "LoadB");
910 }
911
912 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
913 static {
914 loadOfNodes(LOAD_B_OF_CLASS, "LoadB");
915 }
916
917 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
918 static {
919 beforeMatchingNameRegex(LOAD_D, "LoadD");
920 }
921
922 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
923 static {
924 loadOfNodes(LOAD_D_OF_CLASS, "LoadD");
925 }
926
927 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
928 static {
929 beforeMatchingNameRegex(LOAD_F, "LoadF");
930 }
931
932 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
933 static {
934 loadOfNodes(LOAD_F_OF_CLASS, "LoadF");
935 }
936
937 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
938 static {
939 beforeMatchingNameRegex(LOAD_I, "LoadI");
940 }
941
942 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
943 static {
944 loadOfNodes(LOAD_I_OF_CLASS, "LoadI");
945 }
946
947 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
948 static {
949 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
950 }
951
952 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
953 static {
954 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
955 }
956
957 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
958 static {
959 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
960 }
961
962 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
963 static {
964 beforeMatchingNameRegex(LOAD_L, "LoadL");
965 }
966
967 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
968 static {
969 loadOfNodes(LOAD_L_OF_CLASS, "LoadL");
970 }
971
972 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
973 static {
974 beforeMatchingNameRegex(LOAD_N, "LoadN");
975 }
976
977 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
978 static {
979 loadOfNodes(LOAD_N_OF_CLASS, "LoadN");
980 }
981
982 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
983 static {
984 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
985 beforeMatching(LOAD_OF_FIELD, regex);
986 }
987
988 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
989 static {
990 beforeMatchingNameRegex(LOAD_P, "LoadP");
991 }
992
993 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
994 static {
995 loadOfNodes(LOAD_P_OF_CLASS, "LoadP");
996 }
997
998 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
999 static {
1000 beforeMatchingNameRegex(LOAD_S, "LoadS");
1001 }
1002
1003 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1004 static {
1005 loadOfNodes(LOAD_S_OF_CLASS, "LoadS");
1006 }
1007
1008 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1009 static {
1010 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1011 }
1012
1013 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1014 static {
1015 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB");
1016 }
1017
1018 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1019 static {
1020 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1021 }
1022
1023 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1024 static {
1025 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS");
1026 }
1027
1028 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1029 static {
1030 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1031 }
1032
1033 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1034 static {
1035 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1036 }
1037
1038 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1039 static {
1040 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1041 }
1042
1043 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1044 static {
1045 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
1904 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
1905 }
1906
1907 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
1908 static {
1909 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
1910 }
1911
1912 public static final String STORE = PREFIX + "STORE" + POSTFIX;
1913 static {
1914 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
1915 }
1916
1917 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
1918 static {
1919 beforeMatchingNameRegex(STORE_B, "StoreB");
1920 }
1921
1922 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
1923 static {
1924 storeOfNodes(STORE_B_OF_CLASS, "StoreB");
1925 }
1926
1927 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
1928 static {
1929 beforeMatchingNameRegex(STORE_C, "StoreC");
1930 }
1931
1932 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
1933 static {
1934 storeOfNodes(STORE_C_OF_CLASS, "StoreC");
1935 }
1936
1937 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
1938 static {
1939 beforeMatchingNameRegex(STORE_D, "StoreD");
1940 }
1941
1942 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
1943 static {
1944 storeOfNodes(STORE_D_OF_CLASS, "StoreD");
1945 }
1946
1947 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
1948 static {
1949 beforeMatchingNameRegex(STORE_F, "StoreF");
1950 }
1951
1952 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
1953 static {
1954 storeOfNodes(STORE_F_OF_CLASS, "StoreF");
1955 }
1956
1957 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
1958 static {
1959 beforeMatchingNameRegex(STORE_I, "StoreI");
1960 }
1961
1962 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
1963 static {
1964 storeOfNodes(STORE_I_OF_CLASS, "StoreI");
1965 }
1966
1967 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
1968 static {
1969 beforeMatchingNameRegex(STORE_L, "StoreL");
1970 }
1971
1972 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
1973 static {
1974 storeOfNodes(STORE_L_OF_CLASS, "StoreL");
1975 }
1976
1977 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
1978 static {
1979 beforeMatchingNameRegex(STORE_N, "StoreN");
1980 }
1981
1982 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
1983 static {
1984 storeOfNodes(STORE_N_OF_CLASS, "StoreN");
1985 }
1986
1987 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
1988 static {
1989 storeOfNodes(STORE_OF_CLASS, "Store(B|C|S|I|L|F|D|P|N)");
1990 }
1991
1992 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
1993 static {
1994 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1995 beforeMatching(STORE_OF_FIELD, regex);
1996 }
1997
1998 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
1999 static {
2000 beforeMatchingNameRegex(STORE_P, "StoreP");
2001 }
2002
2003 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2004 static {
2005 storeOfNodes(STORE_P_OF_CLASS, "StoreP");
2006 }
2007
2008 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2009 static {
2010 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2011 }
2012
2013 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2014 static {
2015 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2016 }
2017
2018 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2019 static {
2020 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2021 }
2022
2023 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2024 static {
2025 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2075 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2076 }
2077
2078 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2079 static {
2080 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2081 }
2082
2083 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2084 static {
2085 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2086 }
2087
2088 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2089 static {
2090 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2091 }
2092
2093 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2094 static {
2095 beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");
2096 }
2097
2098 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2099 static {
2100 trapNodes(TRAP, "reason");
2101 }
2102
2103 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2104 static {
2105 beforeMatchingNameRegex(DIV_HF, "DivHF");
2106 }
2107
2108 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2109 static {
2110 beforeMatchingNameRegex(UDIV_I, "UDivI");
2111 }
2112
2113 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2114 static {
2115 beforeMatchingNameRegex(UDIV_L, "UDivL");
2887 }
2888
2889 public static final String SELECT_FROM_TWO_VECTOR_VD = VECTOR_PREFIX + "SELECT_FROM_TWO_VECTOR_VD" + POSTFIX;
2890 static {
2891 vectorNode(SELECT_FROM_TWO_VECTOR_VD, "SelectFromTwoVector", TYPE_DOUBLE);
2892 }
2893
2894 public static final String SELECT_FROM_TWO_VECTOR_VL = VECTOR_PREFIX + "SELECT_FROM_TWO_VECTOR_VL" + POSTFIX;
2895 static {
2896 vectorNode(SELECT_FROM_TWO_VECTOR_VL, "SelectFromTwoVector", TYPE_LONG);
2897 }
2898
2899 /*
2900 * Utility methods to set up IR_NODE_MAPPINGS.
2901 */
2902
2903 /**
2904 * Apply {@code regex} on all machine independent ideal graph phases up to and including
2905 * {@link CompilePhase#BEFORE_MATCHING}.
2906 */
2907 private static void beforeMatching(String irNodePlaceholder, String regex) {
2908 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2909 }
2910
2911 /**
2912 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
2913 * including {@link CompilePhase#BEFORE_MATCHING}.
2914 */
2915 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
2916 String regex = START + irNodeRegex + MID + END;
2917 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2918 }
2919
2920 /**
2921 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
2922 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
2923 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
2924 */
2925 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
2926 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
2927 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
2928 // IS_REPLACED is later replaced with the specific type and size of the vector.
2929 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
2930 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2931 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
2932 }
2933
2934 /**
2935 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
2936 */
2937 private static void macroNodes(String irNodePlaceholder, String regex) {
2938 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
2939 CompilePhase.BEFORE_STRINGOPTS,
2940 CompilePhase.BEFORE_MACRO_EXPANSION));
2941 }
2942
2943 private static void callOfNodes(String irNodePlaceholder, String callRegex) {
2944 String regex = START + callRegex + MID + IS_REPLACED + " " + END;
2945 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2946 }
2947
2948 /**
2949 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
2950 * {@link CompilePhase#MATCHING}.
2951 */
2952 private static void optoOnly(String irNodePlaceholder, String regex) {
2953 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
2954 }
2955
2956 private static void machOnly(String irNodePlaceholder, String regex) {
2957 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2958 }
2959
2960 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
2961 String regex = START + irNodeRegex + MID + END;
2962 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2963 }
2964
2965 /**
2966 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
2967 */
2968 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
2969 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2970 CompilePhase.AFTER_CLOOPS,
2971 CompilePhase.FINAL_CODE));
2972 }
3017
3018 private static void parsePredicateNodes(String irNodePlaceholder, String label) {
3019 String regex = START + "ParsePredicate" + MID + "#" + label + " " + END;
3020 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_PARSING, regex,
3021 CompilePhase.AFTER_PARSING,
3022 CompilePhase.AFTER_LOOP_OPTS));
3023 }
3024
3025 // Typename in load/store have the structure:
3026 // @fully/qualified/package/name/to/TheClass+12 *
3027 // And variation:
3028 // - after @, we can have "stable:" or other labels, with optional space after ':'
3029 // - the class can actually be a subclass, with $ separator (and it must be ok to give only the deepest one
3030 // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3031 // - before the offset, we can have something like ":NotNull", either way, seeing "+" or ":" means the end of the type
3032 // Worst case, it can be something like:
3033 // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24 *
3034 private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)*[\\w/\\$]*\\b";
3035 private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?(:|\\+)\\S* \\*";
3036
3037 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
3038 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + IS_REPLACED + LOAD_STORE_SUFFIX + END;
3039 beforeMatching(irNodePlaceholder, regex);
3040 }
3041
3042 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
3043 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + IS_REPLACED + LOAD_STORE_SUFFIX + END;
3044 beforeMatching(irNodePlaceholder, regex);
3045 }
3046
3047 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3048 String regex = START + irNodeRegex + MID + END;
3049 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3050 CompilePhase.BEFORE_REMOVEUSELESS,
3051 CompilePhase.FINAL_CODE));
3052 }
3053
3054 /**
3055 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3056 * first phase that could contain vector nodes from super word.
3057 */
3058 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
3059 String regex = START + irNodeRegex + MID + END;
3060 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3061 CompilePhase.PHASEIDEALLOOP1,
3062 CompilePhase.BEFORE_MATCHING));
3063 }
|
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
745 beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
746 }
747
748 public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
749 static {
750 vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
751 }
752
753 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
754 static {
755 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
756 }
757
758 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
759 static {
760 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
761 }
762
763 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
764 static {
765 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava", IS_REPLACED);
766 }
767
768 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
769 static {
770 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
771 }
772
773 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
774 static {
775 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
776 }
777
778 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
779 static {
780 String regex = START + "FastUnlock" + MID + END;
781 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
782 }
783
784 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
785 static {
881 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
882 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
883 }
884
885 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
886 static {
887 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
888 }
889
890 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
891 static {
892 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
893 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
894 }
895
896 public static final String IF = PREFIX + "IF" + POSTFIX;
897 static {
898 beforeMatchingNameRegex(IF, "If\\b");
899 }
900
901 public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;
902 static {
903 beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
904 }
905
906 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
907 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
908 static {
909 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
910 }
911
912 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
913 static {
914 trapNodes(INTRINSIC_TRAP, "intrinsic");
915 }
916
917 // Is only supported on riscv64.
918 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
919 static {
920 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
921 }
922
923 // Is only supported on riscv64.
924 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
925 static {
932 }
933
934 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
935 static {
936 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
937 }
938
939 // Only supported on x86.
940 public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
941 static {
942 machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
943 }
944
945 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
946 static {
947 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
948 }
949
950 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
951 static {
952 anyLoadOfNodes(LOAD_OF_CLASS, IS_REPLACED);
953 }
954
955 public static void anyLoadOfNodes(String irNodePlaceholder, String fieldHolder) {
956 loadOfNodes(irNodePlaceholder, "Load(B|UB|S|US|I|L|F|D|P|N)", fieldHolder);
957 }
958
959 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
960 static {
961 beforeMatchingNameRegex(LOAD_B, "LoadB");
962 }
963
964 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
965 static {
966 loadOfNodes(LOAD_B_OF_CLASS, "LoadB", IS_REPLACED);
967 }
968
969 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
970 static {
971 beforeMatchingNameRegex(LOAD_D, "LoadD");
972 }
973
974 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
975 static {
976 loadOfNodes(LOAD_D_OF_CLASS, "LoadD", IS_REPLACED);
977 }
978
979 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
980 static {
981 beforeMatchingNameRegex(LOAD_F, "LoadF");
982 }
983
984 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
985 static {
986 loadOfNodes(LOAD_F_OF_CLASS, "LoadF", IS_REPLACED);
987 }
988
989 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
990 static {
991 beforeMatchingNameRegex(LOAD_I, "LoadI");
992 }
993
994 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
995 static {
996 loadOfNodes(LOAD_I_OF_CLASS, "LoadI", IS_REPLACED);
997 }
998
999 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
1000 static {
1001 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
1002 }
1003
1004 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
1005 static {
1006 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
1007 }
1008
1009 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
1010 static {
1011 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
1012 }
1013
1014 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
1015 static {
1016 beforeMatchingNameRegex(LOAD_L, "LoadL");
1017 }
1018
1019 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
1020 static {
1021 loadOfNodes(LOAD_L_OF_CLASS, "LoadL", IS_REPLACED);
1022 }
1023
1024 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1025 static {
1026 beforeMatchingNameRegex(LOAD_N, "LoadN");
1027 }
1028
1029 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1030 static {
1031 loadOfNodes(LOAD_N_OF_CLASS, "LoadN", IS_REPLACED);
1032 }
1033
1034 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1035 static {
1036 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1037 beforeMatching(LOAD_OF_FIELD, regex);
1038 }
1039
1040 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1041 static {
1042 beforeMatchingNameRegex(LOAD_P, "LoadP");
1043 }
1044
1045 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1046 static {
1047 loadOfNodes(LOAD_P_OF_CLASS, "LoadP", IS_REPLACED);
1048 }
1049
1050 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1051 static {
1052 beforeMatchingNameRegex(LOAD_S, "LoadS");
1053 }
1054
1055 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1056 static {
1057 loadOfNodes(LOAD_S_OF_CLASS, "LoadS", IS_REPLACED);
1058 }
1059
1060 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1061 static {
1062 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1063 }
1064
1065 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1066 static {
1067 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB", IS_REPLACED);
1068 }
1069
1070 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1071 static {
1072 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1073 }
1074
1075 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1076 static {
1077 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS", IS_REPLACED);
1078 }
1079
1080 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1081 static {
1082 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1083 }
1084
1085 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1086 static {
1087 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1088 }
1089
1090 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1091 static {
1092 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1093 }
1094
1095 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1096 static {
1097 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
1956 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
1957 }
1958
1959 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
1960 static {
1961 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
1962 }
1963
1964 public static final String STORE = PREFIX + "STORE" + POSTFIX;
1965 static {
1966 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
1967 }
1968
1969 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
1970 static {
1971 beforeMatchingNameRegex(STORE_B, "StoreB");
1972 }
1973
1974 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
1975 static {
1976 storeOfNodes(STORE_B_OF_CLASS, "StoreB", IS_REPLACED);
1977 }
1978
1979 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
1980 static {
1981 beforeMatchingNameRegex(STORE_C, "StoreC");
1982 }
1983
1984 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
1985 static {
1986 storeOfNodes(STORE_C_OF_CLASS, "StoreC", IS_REPLACED);
1987 }
1988
1989 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
1990 static {
1991 beforeMatchingNameRegex(STORE_D, "StoreD");
1992 }
1993
1994 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
1995 static {
1996 storeOfNodes(STORE_D_OF_CLASS, "StoreD", IS_REPLACED);
1997 }
1998
1999 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2000 static {
2001 beforeMatchingNameRegex(STORE_F, "StoreF");
2002 }
2003
2004 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2005 static {
2006 storeOfNodes(STORE_F_OF_CLASS, "StoreF", IS_REPLACED);
2007 }
2008
2009 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2010 static {
2011 beforeMatchingNameRegex(STORE_I, "StoreI");
2012 }
2013
2014 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2015 static {
2016 storeOfNodes(STORE_I_OF_CLASS, "StoreI", IS_REPLACED);
2017 }
2018
2019 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2020 static {
2021 beforeMatchingNameRegex(STORE_L, "StoreL");
2022 }
2023
2024 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2025 static {
2026 storeOfNodes(STORE_L_OF_CLASS, "StoreL", IS_REPLACED);
2027 }
2028
2029 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2030 static {
2031 beforeMatchingNameRegex(STORE_N, "StoreN");
2032 }
2033
2034 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2035 static {
2036 storeOfNodes(STORE_N_OF_CLASS, "StoreN", IS_REPLACED);
2037 }
2038
2039 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2040 static {
2041 anyStoreOfNodes(STORE_OF_CLASS, IS_REPLACED);
2042 }
2043
2044 public static void anyStoreOfNodes(String irNodePlaceholder, String fieldHolder) {
2045 storeOfNodes(irNodePlaceholder, "Store(B|C|S|I|L|F|D|P|N)", fieldHolder);
2046 }
2047
2048 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2049 static {
2050 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2051 beforeMatching(STORE_OF_FIELD, regex);
2052 }
2053
2054 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2055 static {
2056 beforeMatchingNameRegex(STORE_P, "StoreP");
2057 }
2058
2059 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2060 static {
2061 storeOfNodes(STORE_P_OF_CLASS, "StoreP", IS_REPLACED);
2062 }
2063
2064 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2065 static {
2066 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2067 }
2068
2069 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2070 static {
2071 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2072 }
2073
2074 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2075 static {
2076 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2077 }
2078
2079 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2080 static {
2081 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2131 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2132 }
2133
2134 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2135 static {
2136 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2137 }
2138
2139 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2140 static {
2141 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2142 }
2143
2144 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2145 static {
2146 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2147 }
2148
2149 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2150 static {
2151 String regex = START + "SubTypeCheck" + MID + END;
2152 macroNodes(SUBTYPE_CHECK, regex);
2153 }
2154
2155 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2156 static {
2157 trapNodes(TRAP, "reason");
2158 }
2159
2160 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2161 static {
2162 beforeMatchingNameRegex(DIV_HF, "DivHF");
2163 }
2164
2165 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2166 static {
2167 beforeMatchingNameRegex(UDIV_I, "UDivI");
2168 }
2169
2170 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2171 static {
2172 beforeMatchingNameRegex(UDIV_L, "UDivL");
2944 }
2945
2946 public static final String SELECT_FROM_TWO_VECTOR_VD = VECTOR_PREFIX + "SELECT_FROM_TWO_VECTOR_VD" + POSTFIX;
2947 static {
2948 vectorNode(SELECT_FROM_TWO_VECTOR_VD, "SelectFromTwoVector", TYPE_DOUBLE);
2949 }
2950
2951 public static final String SELECT_FROM_TWO_VECTOR_VL = VECTOR_PREFIX + "SELECT_FROM_TWO_VECTOR_VL" + POSTFIX;
2952 static {
2953 vectorNode(SELECT_FROM_TWO_VECTOR_VL, "SelectFromTwoVector", TYPE_LONG);
2954 }
2955
2956 /*
2957 * Utility methods to set up IR_NODE_MAPPINGS.
2958 */
2959
2960 /**
2961 * Apply {@code regex} on all machine independent ideal graph phases up to and including
2962 * {@link CompilePhase#BEFORE_MATCHING}.
2963 */
2964 public static void beforeMatching(String irNodePlaceholder, String regex) {
2965 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2966 }
2967
2968 /**
2969 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
2970 * including {@link CompilePhase#BEFORE_MATCHING}.
2971 */
2972 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
2973 String regex = START + irNodeRegex + MID + END;
2974 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2975 }
2976
2977 /**
2978 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
2979 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
2980 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
2981 */
2982 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
2983 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
2984 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
2985 // IS_REPLACED is later replaced with the specific type and size of the vector.
2986 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
2987 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2988 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
2989 }
2990
2991 /**
2992 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
2993 */
2994 private static void macroNodes(String irNodePlaceholder, String regex) {
2995 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
2996 CompilePhase.BEFORE_STRINGOPTS,
2997 CompilePhase.BEFORE_MACRO_EXPANSION));
2998 }
2999
3000 private static void callOfNodes(String irNodePlaceholder, String callRegex, String calleeRegex) {
3001 String regex = START + callRegex + MID + calleeRegex + END;
3002 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3003 }
3004
3005 /**
3006 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3007 * {@link CompilePhase#MATCHING}.
3008 */
3009 public static void optoOnly(String irNodePlaceholder, String regex) {
3010 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3011 }
3012
3013 private static void machOnly(String irNodePlaceholder, String regex) {
3014 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3015 }
3016
3017 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3018 String regex = START + irNodeRegex + MID + END;
3019 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3020 }
3021
3022 /**
3023 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3024 */
3025 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3026 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3027 CompilePhase.AFTER_CLOOPS,
3028 CompilePhase.FINAL_CODE));
3029 }
3074
3075 private static void parsePredicateNodes(String irNodePlaceholder, String label) {
3076 String regex = START + "ParsePredicate" + MID + "#" + label + " " + END;
3077 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_PARSING, regex,
3078 CompilePhase.AFTER_PARSING,
3079 CompilePhase.AFTER_LOOP_OPTS));
3080 }
3081
3082 // Typename in load/store have the structure:
3083 // @fully/qualified/package/name/to/TheClass+12 *
3084 // And variation:
3085 // - after @, we can have "stable:" or other labels, with optional space after ':'
3086 // - the class can actually be a subclass, with $ separator (and it must be ok to give only the deepest one
3087 // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3088 // - before the offset, we can have something like ":NotNull", either way, seeing "+" or ":" means the end of the type
3089 // Worst case, it can be something like:
3090 // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24 *
3091 private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)*[\\w/\\$]*\\b";
3092 private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?(:|\\+)\\S* \\*";
3093
3094 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex, String loadee) {
3095 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + loadee + LOAD_STORE_SUFFIX + END;
3096 beforeMatching(irNodePlaceholder, regex);
3097 }
3098
3099 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex, String storee) {
3100 String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + storee + LOAD_STORE_SUFFIX + END;
3101 beforeMatching(irNodePlaceholder, regex);
3102 }
3103
3104 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3105 String regex = START + irNodeRegex + MID + END;
3106 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3107 CompilePhase.BEFORE_REMOVEUSELESS,
3108 CompilePhase.FINAL_CODE));
3109 }
3110
3111 /**
3112 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3113 * first phase that could contain vector nodes from super word.
3114 */
3115 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
3116 String regex = START + irNodeRegex + MID + END;
3117 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3118 CompilePhase.PHASEIDEALLOOP1,
3119 CompilePhase.BEFORE_MATCHING));
3120 }
|