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 private static final String START = "(\\d+(\\s){2}(";
103 private static final String MID = ".*)+(\\s){2}===.*";
104 private static final String END = ")";
105 private static final String STORE_OF_CLASS_POSTFIX = "(:|\\+)\\S* \\*" + END;
106 private static final String LOAD_OF_CLASS_POSTFIX = "(:|\\+)\\S* \\*" + END;
107
108 public static final String IS_REPLACED = "#IS_REPLACED#"; // Is replaced by an additional user-defined string.
109
110 public static final String VECTOR_SIZE = "_@";
111 public static final String VECTOR_SIZE_TAG_ANY = "any";
112 public static final String VECTOR_SIZE_TAG_MAX = "max_for_type";
113 public static final String VECTOR_SIZE_ANY = VECTOR_SIZE + VECTOR_SIZE_TAG_ANY; // default for counts "=0" and failOn
114 public static final String VECTOR_SIZE_MAX = VECTOR_SIZE + VECTOR_SIZE_TAG_MAX; // default in counts
115 public static final String VECTOR_SIZE_2 = VECTOR_SIZE + "2";
116 public static final String VECTOR_SIZE_4 = VECTOR_SIZE + "4";
117 public static final String VECTOR_SIZE_8 = VECTOR_SIZE + "8";
118 public static final String VECTOR_SIZE_16 = VECTOR_SIZE + "16";
119 public static final String VECTOR_SIZE_32 = VECTOR_SIZE + "32";
120 public static final String VECTOR_SIZE_64 = VECTOR_SIZE + "64";
121
122 private static final String TYPE_BYTE = "B";
123 private static final String TYPE_CHAR = "C";
124 private static final String TYPE_SHORT = "S";
125 private static final String TYPE_INT = "I";
126 private static final String TYPE_LONG = "J";
135 /**
136 * Map every vectorNode to a type string.
137 */
138 private static final Map<String, String> VECTOR_NODE_TYPE = new HashMap<>();
139
140 /*
141 * Start of IR placeholder string definitions followed by a static block defining the regex-for-compile-phase mapping.
142 * An IR node placeholder string must start with PREFIX for normal IR nodes or COMPOSITE_PREFIX for composite IR
143 * nodes, or VECTOR_PREFIX for vector nodes (see class description above).
144 *
145 * An IR node definition looks like this:
146 *
147 * public static final String IR_NODE = [PREFIX|COMPOSITE_PREFIX|VECTOR_PREFIX] + "IR_NODE" + POSTFIX;
148 * static {
149 * // Define IR_NODE to regex-for-compile-phase mapping. Create a new IRNodeMapEntry object and add it to
150 * // IR_NODE_MAPPINGS. This can be done by using the helper methods defined after all IR node placeholder string
151 * // definitions.
152 * }
153 */
154
155 public static final String ABS_D = PREFIX + "ABS_D" + POSTFIX;
156 static {
157 beforeMatchingNameRegex(ABS_D, "AbsD");
158 }
159
160 public static final String ABS_F = PREFIX + "ABS_F" + POSTFIX;
161 static {
162 beforeMatchingNameRegex(ABS_F, "AbsF");
163 }
164
165 public static final String ABS_I = PREFIX + "ABS_I" + POSTFIX;
166 static {
167 beforeMatchingNameRegex(ABS_I, "AbsI");
168 }
169
170 public static final String ABS_L = PREFIX + "ABS_L" + POSTFIX;
171 static {
172 beforeMatchingNameRegex(ABS_L, "AbsL");
173 }
174
366
367 public static final String REARRANGE_VD = VECTOR_PREFIX + "REARRANGE_VD" + POSTFIX;
368 static {
369 vectorNode(REARRANGE_VD, "VectorRearrange", TYPE_DOUBLE);
370 }
371
372 public static final String ADD_P_OF = COMPOSITE_PREFIX + "ADD_P_OF" + POSTFIX;
373 static {
374 String regex = START + "addP_" + IS_REPLACED + MID + ".*" + END;
375 machOnly(ADD_P_OF, regex);
376 }
377
378 public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
379 static {
380 String regex = START + "Allocate\\b" + MID + END;
381 macroNodes(ALLOC, regex);
382 }
383
384 public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
385 static {
386 String regex = START + "Allocate\\b" + MID + "allocationKlass:.*\\b" + IS_REPLACED + "\\s.*" + END;
387 macroNodes(ALLOC_OF, regex);
388 }
389
390 public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
391 static {
392 String regex = START + "AllocateArray\\b" + MID + END;
393 macroNodes(ALLOC_ARRAY, regex);
394 }
395
396 public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
397 static {
398 // Assuming we are looking for an array of "some/package/MyClass". The printout is
399 // [Lsome/package/MyClass;
400 // or, with more dimensions
401 // [[[Lsome/package/MyClass;
402
403 // Case where the searched string is a not fully qualified name (but maybe partially qualified):
404 // package/MyClass or MyClass
405 // The ".*\\b" will eat the "some/" and "some/package/" resp.
406 String partial_name_prefix = ".+\\b";
407
408 // The thing after "allocationKlass:" (the name of the allocated class) is a sequence of:
409 // - a non-empty sequence of "["
410 // - a single character ("L"),
411 // - maybe a non-empty sequence of characters ending on a word boundary
412 // this sequence is omitted if the given name is already fully qualified (exact match)
413 // but will eat the package path prefix in the cases described above
414 // - the name we are looking for
415 // - the final ";".
416 String name_part = "\\[+.(" + partial_name_prefix + ")?" + IS_REPLACED + ";";
417 String regex = START + "AllocateArray\\b" + MID + "allocationKlass:" + name_part + ".*" + END;
418 macroNodes(ALLOC_ARRAY_OF, regex);
419 }
420
421 public static final String OR = PREFIX + "OR" + POSTFIX;
422 static {
423 beforeMatchingNameRegex(OR, "Or(I|L)");
424 }
425
426 public static final String AND = PREFIX + "AND" + POSTFIX;
427 static {
428 beforeMatchingNameRegex(AND, "And(I|L)");
429 }
430
431 public static final String AND_I = PREFIX + "AND_I" + POSTFIX;
432 static {
433 beforeMatchingNameRegex(AND_I, "AndI");
434 }
435
436 public static final String AND_L = PREFIX + "AND_L" + POSTFIX;
437 static {
438 beforeMatchingNameRegex(AND_L, "AndL");
463 vectorNode(AND_VL, "AndV", TYPE_LONG);
464 }
465
466 public static final String AND_V_MASK = PREFIX + "AND_V_MASK" + POSTFIX;
467 static {
468 beforeMatchingNameRegex(AND_V_MASK, "AndVMask");
469 }
470
471 public static final String AND_REDUCTION_V = PREFIX + "AND_REDUCTION_V" + POSTFIX;
472 static {
473 superWordNodes(AND_REDUCTION_V, "AndReductionV");
474 }
475
476 public static final String CALL = PREFIX + "CALL" + POSTFIX;
477 static {
478 beforeMatchingNameRegex(CALL, "Call.*Java");
479 }
480
481 public static final String CALL_OF = COMPOSITE_PREFIX + "CALL_OF" + POSTFIX;
482 static {
483 callOfNodes(CALL_OF, "Call.*");
484 }
485
486 public static final String CALL_OF_METHOD = COMPOSITE_PREFIX + "CALL_OF_METHOD" + POSTFIX;
487 static {
488 callOfNodes(CALL_OF_METHOD, "Call.*Java");
489 }
490
491 public static final String STATIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "STATIC_CALL_OF_METHOD" + POSTFIX;
492 static {
493 callOfNodes(STATIC_CALL_OF_METHOD, "CallStaticJava");
494 }
495
496 public static final String CAST_II = PREFIX + "CAST_II" + POSTFIX;
497 static {
498 beforeMatchingNameRegex(CAST_II, "CastII");
499 }
500
501 public static final String CAST_LL = PREFIX + "CAST_LL" + POSTFIX;
502 static {
503 beforeMatchingNameRegex(CAST_LL, "CastLL");
504 }
505
506 public static final String CBNZW_HI = PREFIX + "CBNZW_HI" + POSTFIX;
507 static {
508 optoOnly(CBNZW_HI, "cbwhi");
509 }
510
511 public static final String CBZW_LS = PREFIX + "CBZW_LS" + POSTFIX;
512 static {
513 optoOnly(CBZW_LS, "cbwls");
570 public static final String CMP_U3 = PREFIX + "CMP_U3" + POSTFIX;
571 static {
572 beforeMatchingNameRegex(CMP_U3, "CmpU3");
573 }
574
575 public static final String CMP_UL = PREFIX + "CMP_UL" + POSTFIX;
576 static {
577 beforeMatchingNameRegex(CMP_UL, "CmpUL");
578 }
579
580 public static final String CMP_UL3 = PREFIX + "CMP_UL3" + POSTFIX;
581 static {
582 beforeMatchingNameRegex(CMP_UL3, "CmpUL3");
583 }
584
585 public static final String CMP_P = PREFIX + "CMP_P" + POSTFIX;
586 static {
587 beforeMatchingNameRegex(CMP_P, "CmpP");
588 }
589
590 public static final String COMPRESS_BITS = PREFIX + "COMPRESS_BITS" + POSTFIX;
591 static {
592 beforeMatchingNameRegex(COMPRESS_BITS, "CompressBits");
593 }
594
595 public static final String CONV = PREFIX + "CONV" + POSTFIX;
596 static {
597 beforeMatchingNameRegex(CONV, "Conv");
598 }
599
600 public static final String CONV_F2HF = PREFIX + "CONV_F2HF" + POSTFIX;
601 static {
602 beforeMatchingNameRegex(CONV_F2HF, "ConvF2HF");
603 }
604
605 public static final String CONV_I2L = PREFIX + "CONV_I2L" + POSTFIX;
606 static {
607 beforeMatchingNameRegex(CONV_I2L, "ConvI2L");
608 }
609
689 beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
690 }
691
692 public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
693 static {
694 vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
695 }
696
697 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
698 static {
699 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
700 }
701
702 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
703 static {
704 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
705 }
706
707 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
708 static {
709 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava");
710 }
711
712 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
713 static {
714 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
715 }
716
717 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
718 static {
719 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
720 }
721
722 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
723 static {
724 String regex = START + "FastUnlock" + MID + END;
725 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
726 }
727
728 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
729 static {
825 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
826 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
827 }
828
829 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
830 static {
831 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
832 }
833
834 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
835 static {
836 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
837 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
838 }
839
840 public static final String IF = PREFIX + "IF" + POSTFIX;
841 static {
842 beforeMatchingNameRegex(IF, "If\\b");
843 }
844
845 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
846 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
847 static {
848 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
849 }
850
851 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
852 static {
853 trapNodes(INTRINSIC_TRAP, "intrinsic");
854 }
855
856 // Is only supported on riscv64.
857 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
858 static {
859 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
860 }
861
862 // Is only supported on riscv64.
863 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
864 static {
871 }
872
873 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
874 static {
875 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
876 }
877
878 // Only supported on x86.
879 public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
880 static {
881 machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
882 }
883
884 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
885 static {
886 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
887 }
888
889 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
890 static {
891 loadOfNodes(LOAD_OF_CLASS, "Load(B|UB|S|US|I|L|F|D|P|N)");
892 }
893
894 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
895 static {
896 beforeMatchingNameRegex(LOAD_B, "LoadB");
897 }
898
899 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
900 static {
901 loadOfNodes(LOAD_B_OF_CLASS, "LoadB");
902 }
903
904 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
905 static {
906 beforeMatchingNameRegex(LOAD_D, "LoadD");
907 }
908
909 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
910 static {
911 loadOfNodes(LOAD_D_OF_CLASS, "LoadD");
912 }
913
914 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
915 static {
916 beforeMatchingNameRegex(LOAD_F, "LoadF");
917 }
918
919 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
920 static {
921 loadOfNodes(LOAD_F_OF_CLASS, "LoadF");
922 }
923
924 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
925 static {
926 beforeMatchingNameRegex(LOAD_I, "LoadI");
927 }
928
929 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
930 static {
931 loadOfNodes(LOAD_I_OF_CLASS, "LoadI");
932 }
933
934 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
935 static {
936 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
937 }
938
939 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
940 static {
941 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
942 }
943
944 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
945 static {
946 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
947 }
948
949 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
950 static {
951 beforeMatchingNameRegex(LOAD_L, "LoadL");
952 }
953
954 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
955 static {
956 loadOfNodes(LOAD_L_OF_CLASS, "LoadL");
957 }
958
959 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
960 static {
961 beforeMatchingNameRegex(LOAD_N, "LoadN");
962 }
963
964 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
965 static {
966 loadOfNodes(LOAD_N_OF_CLASS, "LoadN");
967 }
968
969 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
970 static {
971 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
972 beforeMatching(LOAD_OF_FIELD, regex);
973 }
974
975 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
976 static {
977 beforeMatchingNameRegex(LOAD_P, "LoadP");
978 }
979
980 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
981 static {
982 loadOfNodes(LOAD_P_OF_CLASS, "LoadP");
983 }
984
985 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
986 static {
987 beforeMatchingNameRegex(LOAD_S, "LoadS");
988 }
989
990 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
991 static {
992 loadOfNodes(LOAD_S_OF_CLASS, "LoadS");
993 }
994
995 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
996 static {
997 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
998 }
999
1000 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1001 static {
1002 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB");
1003 }
1004
1005 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1006 static {
1007 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1008 }
1009
1010 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1011 static {
1012 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS");
1013 }
1014
1015 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1016 static {
1017 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1018 }
1019
1020 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1021 static {
1022 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1023 }
1024
1025 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1026 static {
1027 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1028 }
1029
1030 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1031 static {
1032 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
1881 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
1882 }
1883
1884 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
1885 static {
1886 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
1887 }
1888
1889 public static final String STORE = PREFIX + "STORE" + POSTFIX;
1890 static {
1891 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
1892 }
1893
1894 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
1895 static {
1896 beforeMatchingNameRegex(STORE_B, "StoreB");
1897 }
1898
1899 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
1900 static {
1901 storeOfNodes(STORE_B_OF_CLASS, "StoreB");
1902 }
1903
1904 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
1905 static {
1906 beforeMatchingNameRegex(STORE_C, "StoreC");
1907 }
1908
1909 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
1910 static {
1911 storeOfNodes(STORE_C_OF_CLASS, "StoreC");
1912 }
1913
1914 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
1915 static {
1916 beforeMatchingNameRegex(STORE_D, "StoreD");
1917 }
1918
1919 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
1920 static {
1921 storeOfNodes(STORE_D_OF_CLASS, "StoreD");
1922 }
1923
1924 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
1925 static {
1926 beforeMatchingNameRegex(STORE_F, "StoreF");
1927 }
1928
1929 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
1930 static {
1931 storeOfNodes(STORE_F_OF_CLASS, "StoreF");
1932 }
1933
1934 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
1935 static {
1936 beforeMatchingNameRegex(STORE_I, "StoreI");
1937 }
1938
1939 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
1940 static {
1941 storeOfNodes(STORE_I_OF_CLASS, "StoreI");
1942 }
1943
1944 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
1945 static {
1946 beforeMatchingNameRegex(STORE_L, "StoreL");
1947 }
1948
1949 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
1950 static {
1951 storeOfNodes(STORE_L_OF_CLASS, "StoreL");
1952 }
1953
1954 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
1955 static {
1956 beforeMatchingNameRegex(STORE_N, "StoreN");
1957 }
1958
1959 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
1960 static {
1961 storeOfNodes(STORE_N_OF_CLASS, "StoreN");
1962 }
1963
1964 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
1965 static {
1966 storeOfNodes(STORE_OF_CLASS, "Store(B|C|S|I|L|F|D|P|N)");
1967 }
1968
1969 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
1970 static {
1971 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1972 beforeMatching(STORE_OF_FIELD, regex);
1973 }
1974
1975 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
1976 static {
1977 beforeMatchingNameRegex(STORE_P, "StoreP");
1978 }
1979
1980 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
1981 static {
1982 storeOfNodes(STORE_P_OF_CLASS, "StoreP");
1983 }
1984
1985 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
1986 static {
1987 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
1988 }
1989
1990 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
1991 static {
1992 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
1993 }
1994
1995 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
1996 static {
1997 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
1998 }
1999
2000 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2001 static {
2002 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2052 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2053 }
2054
2055 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2056 static {
2057 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2058 }
2059
2060 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2061 static {
2062 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2063 }
2064
2065 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2066 static {
2067 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2068 }
2069
2070 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2071 static {
2072 beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");
2073 }
2074
2075 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2076 static {
2077 trapNodes(TRAP, "reason");
2078 }
2079
2080 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2081 static {
2082 beforeMatchingNameRegex(DIV_HF, "DivHF");
2083 }
2084
2085 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2086 static {
2087 beforeMatchingNameRegex(UDIV_I, "UDivI");
2088 }
2089
2090 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2091 static {
2092 beforeMatchingNameRegex(UDIV_L, "UDivL");
2834
2835 public static final String MOD_D = PREFIX + "MOD_D" + POSTFIX;
2836 static {
2837 String regex = START + "ModD" + MID + END;
2838 macroNodes(MOD_D, regex);
2839 }
2840
2841 public static final String BLACKHOLE = PREFIX + "BLACKHOLE" + POSTFIX;
2842 static {
2843 fromBeforeRemoveUselessToFinalCode(BLACKHOLE, "Blackhole");
2844 }
2845
2846 /*
2847 * Utility methods to set up IR_NODE_MAPPINGS.
2848 */
2849
2850 /**
2851 * Apply {@code regex} on all machine independent ideal graph phases up to and including
2852 * {@link CompilePhase#BEFORE_MATCHING}.
2853 */
2854 private static void beforeMatching(String irNodePlaceholder, String regex) {
2855 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2856 }
2857
2858 /**
2859 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
2860 * including {@link CompilePhase#BEFORE_MATCHING}.
2861 */
2862 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
2863 String regex = START + irNodeRegex + MID + END;
2864 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2865 }
2866
2867 /**
2868 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
2869 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
2870 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
2871 */
2872 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
2873 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
2874 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
2875 // IS_REPLACED is later replaced with the specific type and size of the vector.
2876 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
2877 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2878 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
2879 }
2880
2881 /**
2882 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
2883 */
2884 private static void macroNodes(String irNodePlaceholder, String regex) {
2885 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
2886 CompilePhase.BEFORE_STRINGOPTS,
2887 CompilePhase.BEFORE_MACRO_EXPANSION));
2888 }
2889
2890 private static void callOfNodes(String irNodePlaceholder, String callRegex) {
2891 String regex = START + callRegex + MID + IS_REPLACED + " " + END;
2892 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2893 }
2894
2895 /**
2896 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
2897 * {@link CompilePhase#MATCHING}.
2898 */
2899 private static void optoOnly(String irNodePlaceholder, String regex) {
2900 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
2901 }
2902
2903 private static void machOnly(String irNodePlaceholder, String regex) {
2904 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2905 }
2906
2907 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
2908 String regex = START + irNodeRegex + MID + END;
2909 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2910 }
2911
2912 /**
2913 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
2914 */
2915 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
2916 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2917 CompilePhase.AFTER_CLOOPS,
2918 CompilePhase.FINAL_CODE));
2919 }
2952 * up to and including {@link CompilePhase#AFTER_LOOP_OPTS}.
2953 */
2954 private static void duringLoopOpts(String irNodePlaceholder, String regex) {
2955 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_LOOP_OPTS, regex,
2956 CompilePhase.BEFORE_LOOP_OPTS,
2957 CompilePhase.AFTER_LOOP_OPTS));
2958 }
2959
2960 private static void trapNodes(String irNodePlaceholder, String trapReason) {
2961 String regex = START + "CallStaticJava" + MID + "uncommon_trap.*" + trapReason + END;
2962 beforeMatching(irNodePlaceholder, regex);
2963 }
2964
2965 private static void parsePredicateNodes(String irNodePlaceholder, String label) {
2966 String regex = START + "ParsePredicate" + MID + "#" + label + " " + END;
2967 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_PARSING, regex,
2968 CompilePhase.AFTER_PARSING,
2969 CompilePhase.AFTER_LOOP_OPTS));
2970 }
2971
2972 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
2973 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + LOAD_OF_CLASS_POSTFIX;
2974 beforeMatching(irNodePlaceholder, regex);
2975 }
2976
2977 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
2978 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + STORE_OF_CLASS_POSTFIX;
2979 beforeMatching(irNodePlaceholder, regex);
2980 }
2981
2982 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
2983 String regex = START + irNodeRegex + MID + END;
2984 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2985 CompilePhase.BEFORE_REMOVEUSELESS,
2986 CompilePhase.FINAL_CODE));
2987 }
2988
2989 /**
2990 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
2991 * first phase that could contain vector nodes from super word.
2992 */
2993 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
2994 String regex = START + irNodeRegex + MID + END;
2995 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2996 CompilePhase.PHASEIDEALLOOP1,
2997 CompilePhase.BEFORE_MATCHING));
2998 }
|
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 private static final String START = "(\\d+(\\s){2}(";
104 private static final String MID = ".*)+(\\s){2}===.*";
105 private static final String END = ")";
106 private static final String STORE_OF_CLASS_POSTFIX = "( \\([^\\)]+\\))?(:|\\+)\\S* \\*" + END;
107 private static final String LOAD_OF_CLASS_POSTFIX = "( \\([^\\)]+\\))?(:|\\+)\\S* \\*" + END;
108
109 public static final String IS_REPLACED = "#IS_REPLACED#"; // Is replaced by an additional user-defined string.
110
111 public static final String VECTOR_SIZE = "_@";
112 public static final String VECTOR_SIZE_TAG_ANY = "any";
113 public static final String VECTOR_SIZE_TAG_MAX = "max_for_type";
114 public static final String VECTOR_SIZE_ANY = VECTOR_SIZE + VECTOR_SIZE_TAG_ANY; // default for counts "=0" and failOn
115 public static final String VECTOR_SIZE_MAX = VECTOR_SIZE + VECTOR_SIZE_TAG_MAX; // default in counts
116 public static final String VECTOR_SIZE_2 = VECTOR_SIZE + "2";
117 public static final String VECTOR_SIZE_4 = VECTOR_SIZE + "4";
118 public static final String VECTOR_SIZE_8 = VECTOR_SIZE + "8";
119 public static final String VECTOR_SIZE_16 = VECTOR_SIZE + "16";
120 public static final String VECTOR_SIZE_32 = VECTOR_SIZE + "32";
121 public static final String VECTOR_SIZE_64 = VECTOR_SIZE + "64";
122
123 private static final String TYPE_BYTE = "B";
124 private static final String TYPE_CHAR = "C";
125 private static final String TYPE_SHORT = "S";
126 private static final String TYPE_INT = "I";
127 private static final String TYPE_LONG = "J";
136 /**
137 * Map every vectorNode to a type string.
138 */
139 private static final Map<String, String> VECTOR_NODE_TYPE = new HashMap<>();
140
141 /*
142 * Start of IR placeholder string definitions followed by a static block defining the regex-for-compile-phase mapping.
143 * An IR node placeholder string must start with PREFIX for normal IR nodes or COMPOSITE_PREFIX for composite IR
144 * nodes, or VECTOR_PREFIX for vector nodes (see class description above).
145 *
146 * An IR node definition looks like this:
147 *
148 * public static final String IR_NODE = [PREFIX|COMPOSITE_PREFIX|VECTOR_PREFIX] + "IR_NODE" + POSTFIX;
149 * static {
150 * // Define IR_NODE to regex-for-compile-phase mapping. Create a new IRNodeMapEntry object and add it to
151 * // IR_NODE_MAPPINGS. This can be done by using the helper methods defined after all IR node placeholder string
152 * // definitions.
153 * }
154 */
155
156 // Valhalla: Make sure that all Valhalla specific IR nodes are also properly initialized. Doing it here also
157 // ensures that the Flag VM is able to pick up the correct compile phases.
158 static {
159 InlineTypeIRNode.forceStaticInitialization();
160 }
161
162 public static final String ABS_D = PREFIX + "ABS_D" + POSTFIX;
163 static {
164 beforeMatchingNameRegex(ABS_D, "AbsD");
165 }
166
167 public static final String ABS_F = PREFIX + "ABS_F" + POSTFIX;
168 static {
169 beforeMatchingNameRegex(ABS_F, "AbsF");
170 }
171
172 public static final String ABS_I = PREFIX + "ABS_I" + POSTFIX;
173 static {
174 beforeMatchingNameRegex(ABS_I, "AbsI");
175 }
176
177 public static final String ABS_L = PREFIX + "ABS_L" + POSTFIX;
178 static {
179 beforeMatchingNameRegex(ABS_L, "AbsL");
180 }
181
373
374 public static final String REARRANGE_VD = VECTOR_PREFIX + "REARRANGE_VD" + POSTFIX;
375 static {
376 vectorNode(REARRANGE_VD, "VectorRearrange", TYPE_DOUBLE);
377 }
378
379 public static final String ADD_P_OF = COMPOSITE_PREFIX + "ADD_P_OF" + POSTFIX;
380 static {
381 String regex = START + "addP_" + IS_REPLACED + MID + ".*" + END;
382 machOnly(ADD_P_OF, regex);
383 }
384
385 public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
386 static {
387 String regex = START + "Allocate\\b" + MID + END;
388 macroNodes(ALLOC, regex);
389 }
390
391 public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
392 static {
393 allocateOfNodes(ALLOC_OF, IS_REPLACED);
394 }
395
396 public static void allocateOfNodes(String irNodePlaceholder, String allocatee) {
397 String regex = START + "Allocate\\b" + MID + "allocationKlass:.*\\b" + allocatee + "\\s.*" + END;
398 macroNodes(irNodePlaceholder, regex);
399 }
400
401 public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
402 static {
403 String regex = START + "AllocateArray\\b" + MID + END;
404 macroNodes(ALLOC_ARRAY, regex);
405 }
406
407 public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
408 static {
409 allocateArrayOfNodes(ALLOC_ARRAY_OF, IS_REPLACED);
410 }
411
412 public static void allocateArrayOfNodes(String irNodePlaceholder, String allocatee) {
413 // Assuming we are looking for an array of "some/package/MyClass". The printout is
414 // [Lsome/package/MyClass;
415 // or, with more dimensions
416 // [[[Lsome/package/MyClass;
417
418 // Case where the searched string is a not fully qualified name (but maybe partially qualified):
419 // package/MyClass or MyClass
420 // The ".*\\b" will eat the "some/" and "some/package/" resp.
421 String partial_name_prefix = ".+\\b";
422
423 // The thing after "allocationKlass:" (the name of the allocated class) is a sequence of:
424 // - a non-empty sequence of "["
425 // - a single character ("L"),
426 // - maybe a non-empty sequence of characters ending on a word boundary
427 // this sequence is omitted if the given name is already fully qualified (exact match)
428 // but will eat the package path prefix in the cases described above
429 // - the name we are looking for
430 // - the final ";".
431 String name_part = "\\[+.(" + partial_name_prefix + ")?" + allocatee + ";";
432 String regex = START + "AllocateArray\\b" + MID + "allocationKlass:" + name_part + ".*" + END;
433 macroNodes(irNodePlaceholder, regex);
434 }
435
436 public static final String OR = PREFIX + "OR" + POSTFIX;
437 static {
438 beforeMatchingNameRegex(OR, "Or(I|L)");
439 }
440
441 public static final String AND = PREFIX + "AND" + POSTFIX;
442 static {
443 beforeMatchingNameRegex(AND, "And(I|L)");
444 }
445
446 public static final String AND_I = PREFIX + "AND_I" + POSTFIX;
447 static {
448 beforeMatchingNameRegex(AND_I, "AndI");
449 }
450
451 public static final String AND_L = PREFIX + "AND_L" + POSTFIX;
452 static {
453 beforeMatchingNameRegex(AND_L, "AndL");
478 vectorNode(AND_VL, "AndV", TYPE_LONG);
479 }
480
481 public static final String AND_V_MASK = PREFIX + "AND_V_MASK" + POSTFIX;
482 static {
483 beforeMatchingNameRegex(AND_V_MASK, "AndVMask");
484 }
485
486 public static final String AND_REDUCTION_V = PREFIX + "AND_REDUCTION_V" + POSTFIX;
487 static {
488 superWordNodes(AND_REDUCTION_V, "AndReductionV");
489 }
490
491 public static final String CALL = PREFIX + "CALL" + POSTFIX;
492 static {
493 beforeMatchingNameRegex(CALL, "Call.*Java");
494 }
495
496 public static final String CALL_OF = COMPOSITE_PREFIX + "CALL_OF" + POSTFIX;
497 static {
498 callOfNodes(CALL_OF, "Call.*", IS_REPLACED + " " );
499 }
500
501 public static final String CALL_OF_METHOD = COMPOSITE_PREFIX + "CALL_OF_METHOD" + POSTFIX;
502 static {
503 callOfNodes(CALL_OF_METHOD, "Call.*Java", IS_REPLACED + " ");
504 }
505
506 public static final String STATIC_CALL = PREFIX + "STATIC_CALL" + POSTFIX;
507 static {
508 beforeMatchingNameRegex(STATIC_CALL, "CallStaticJava");
509 }
510
511 public static final String STATIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "STATIC_CALL_OF_METHOD" + POSTFIX;
512 static {
513 staticCallOfMethodNodes(STATIC_CALL_OF_METHOD, IS_REPLACED + " ");
514 }
515
516 public static void staticCallOfMethodNodes(String irNodePlaceholder, String calleeRegex) {
517 callOfNodes(irNodePlaceholder, "CallStaticJava", calleeRegex);
518 }
519
520 public static final String CALL_LEAF_NO_FP = PREFIX + "CALL_LEAF_NO_FP" + POSTFIX;
521 static {
522 beforeMatchingNameRegex(CALL_LEAF_NO_FP, "CallLeafNoFP");
523 }
524
525 public static final String CALL_LEAF_NO_FP_OF_METHOD = COMPOSITE_PREFIX + "CALL_LEAF_NO_FP_OF_METHOD" + POSTFIX;
526 static {
527 callLeafNoFpOfMethodNodes(CALL_LEAF_NO_FP_OF_METHOD, IS_REPLACED);
528 }
529
530 public static void callLeafNoFpOfMethodNodes(String irNodePlaceholder, String calleeRegex) {
531 callOfNodes(irNodePlaceholder, "CallLeafNoFP", calleeRegex);
532 }
533
534 public static final String CAST_II = PREFIX + "CAST_II" + POSTFIX;
535 static {
536 beforeMatchingNameRegex(CAST_II, "CastII");
537 }
538
539 public static final String CAST_LL = PREFIX + "CAST_LL" + POSTFIX;
540 static {
541 beforeMatchingNameRegex(CAST_LL, "CastLL");
542 }
543
544 public static final String CBNZW_HI = PREFIX + "CBNZW_HI" + POSTFIX;
545 static {
546 optoOnly(CBNZW_HI, "cbwhi");
547 }
548
549 public static final String CBZW_LS = PREFIX + "CBZW_LS" + POSTFIX;
550 static {
551 optoOnly(CBZW_LS, "cbwls");
608 public static final String CMP_U3 = PREFIX + "CMP_U3" + POSTFIX;
609 static {
610 beforeMatchingNameRegex(CMP_U3, "CmpU3");
611 }
612
613 public static final String CMP_UL = PREFIX + "CMP_UL" + POSTFIX;
614 static {
615 beforeMatchingNameRegex(CMP_UL, "CmpUL");
616 }
617
618 public static final String CMP_UL3 = PREFIX + "CMP_UL3" + POSTFIX;
619 static {
620 beforeMatchingNameRegex(CMP_UL3, "CmpUL3");
621 }
622
623 public static final String CMP_P = PREFIX + "CMP_P" + POSTFIX;
624 static {
625 beforeMatchingNameRegex(CMP_P, "CmpP");
626 }
627
628 public static final String CMP_N = PREFIX + "CMP_N" + POSTFIX;
629 static {
630 beforeMatchingNameRegex(CMP_N, "CmpN");
631 }
632
633 public static final String COMPRESS_BITS = PREFIX + "COMPRESS_BITS" + POSTFIX;
634 static {
635 beforeMatchingNameRegex(COMPRESS_BITS, "CompressBits");
636 }
637
638 public static final String CONV = PREFIX + "CONV" + POSTFIX;
639 static {
640 beforeMatchingNameRegex(CONV, "Conv");
641 }
642
643 public static final String CONV_F2HF = PREFIX + "CONV_F2HF" + POSTFIX;
644 static {
645 beforeMatchingNameRegex(CONV_F2HF, "ConvF2HF");
646 }
647
648 public static final String CONV_I2L = PREFIX + "CONV_I2L" + POSTFIX;
649 static {
650 beforeMatchingNameRegex(CONV_I2L, "ConvI2L");
651 }
652
732 beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
733 }
734
735 public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
736 static {
737 vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
738 }
739
740 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
741 static {
742 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
743 }
744
745 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
746 static {
747 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
748 }
749
750 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
751 static {
752 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava", IS_REPLACED);
753 }
754
755 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
756 static {
757 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
758 }
759
760 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
761 static {
762 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
763 }
764
765 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
766 static {
767 String regex = START + "FastUnlock" + MID + END;
768 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
769 }
770
771 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
772 static {
868 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
869 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
870 }
871
872 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
873 static {
874 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
875 }
876
877 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
878 static {
879 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
880 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
881 }
882
883 public static final String IF = PREFIX + "IF" + POSTFIX;
884 static {
885 beforeMatchingNameRegex(IF, "If\\b");
886 }
887
888 public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;
889 static {
890 beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
891 }
892
893 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
894 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
895 static {
896 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
897 }
898
899 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
900 static {
901 trapNodes(INTRINSIC_TRAP, "intrinsic");
902 }
903
904 // Is only supported on riscv64.
905 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
906 static {
907 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
908 }
909
910 // Is only supported on riscv64.
911 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
912 static {
919 }
920
921 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
922 static {
923 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
924 }
925
926 // Only supported on x86.
927 public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
928 static {
929 machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
930 }
931
932 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
933 static {
934 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
935 }
936
937 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
938 static {
939 anyLoadOfNodes(LOAD_OF_CLASS, IS_REPLACED);
940 }
941
942 public static void anyLoadOfNodes(String irNodePlaceholder, String fieldHolder) {
943 loadOfNodes(irNodePlaceholder, "Load(B|UB|S|US|I|L|F|D|P|N)", fieldHolder);
944 }
945
946 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
947 static {
948 beforeMatchingNameRegex(LOAD_B, "LoadB");
949 }
950
951 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
952 static {
953 loadOfNodes(LOAD_B_OF_CLASS, "LoadB", IS_REPLACED);
954 }
955
956 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
957 static {
958 beforeMatchingNameRegex(LOAD_D, "LoadD");
959 }
960
961 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
962 static {
963 loadOfNodes(LOAD_D_OF_CLASS, "LoadD", IS_REPLACED);
964 }
965
966 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
967 static {
968 beforeMatchingNameRegex(LOAD_F, "LoadF");
969 }
970
971 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
972 static {
973 loadOfNodes(LOAD_F_OF_CLASS, "LoadF", IS_REPLACED);
974 }
975
976 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
977 static {
978 beforeMatchingNameRegex(LOAD_I, "LoadI");
979 }
980
981 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
982 static {
983 loadOfNodes(LOAD_I_OF_CLASS, "LoadI", IS_REPLACED);
984 }
985
986 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
987 static {
988 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
989 }
990
991 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
992 static {
993 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
994 }
995
996 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
997 static {
998 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
999 }
1000
1001 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
1002 static {
1003 beforeMatchingNameRegex(LOAD_L, "LoadL");
1004 }
1005
1006 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
1007 static {
1008 loadOfNodes(LOAD_L_OF_CLASS, "LoadL", IS_REPLACED);
1009 }
1010
1011 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1012 static {
1013 beforeMatchingNameRegex(LOAD_N, "LoadN");
1014 }
1015
1016 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1017 static {
1018 loadOfNodes(LOAD_N_OF_CLASS, "LoadN", IS_REPLACED);
1019 }
1020
1021 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1022 static {
1023 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1024 beforeMatching(LOAD_OF_FIELD, regex);
1025 }
1026
1027 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1028 static {
1029 beforeMatchingNameRegex(LOAD_P, "LoadP");
1030 }
1031
1032 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1033 static {
1034 loadOfNodes(LOAD_P_OF_CLASS, "LoadP", IS_REPLACED);
1035 }
1036
1037 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1038 static {
1039 beforeMatchingNameRegex(LOAD_S, "LoadS");
1040 }
1041
1042 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1043 static {
1044 loadOfNodes(LOAD_S_OF_CLASS, "LoadS", IS_REPLACED);
1045 }
1046
1047 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1048 static {
1049 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1050 }
1051
1052 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1053 static {
1054 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB", IS_REPLACED);
1055 }
1056
1057 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1058 static {
1059 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1060 }
1061
1062 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1063 static {
1064 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS", IS_REPLACED);
1065 }
1066
1067 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1068 static {
1069 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1070 }
1071
1072 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1073 static {
1074 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1075 }
1076
1077 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1078 static {
1079 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1080 }
1081
1082 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1083 static {
1084 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
1933 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
1934 }
1935
1936 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
1937 static {
1938 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
1939 }
1940
1941 public static final String STORE = PREFIX + "STORE" + POSTFIX;
1942 static {
1943 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
1944 }
1945
1946 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
1947 static {
1948 beforeMatchingNameRegex(STORE_B, "StoreB");
1949 }
1950
1951 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
1952 static {
1953 storeOfNodes(STORE_B_OF_CLASS, "StoreB", IS_REPLACED);
1954 }
1955
1956 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
1957 static {
1958 beforeMatchingNameRegex(STORE_C, "StoreC");
1959 }
1960
1961 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
1962 static {
1963 storeOfNodes(STORE_C_OF_CLASS, "StoreC", IS_REPLACED);
1964 }
1965
1966 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
1967 static {
1968 beforeMatchingNameRegex(STORE_D, "StoreD");
1969 }
1970
1971 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
1972 static {
1973 storeOfNodes(STORE_D_OF_CLASS, "StoreD", IS_REPLACED);
1974 }
1975
1976 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
1977 static {
1978 beforeMatchingNameRegex(STORE_F, "StoreF");
1979 }
1980
1981 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
1982 static {
1983 storeOfNodes(STORE_F_OF_CLASS, "StoreF", IS_REPLACED);
1984 }
1985
1986 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
1987 static {
1988 beforeMatchingNameRegex(STORE_I, "StoreI");
1989 }
1990
1991 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
1992 static {
1993 storeOfNodes(STORE_I_OF_CLASS, "StoreI", IS_REPLACED);
1994 }
1995
1996 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
1997 static {
1998 beforeMatchingNameRegex(STORE_L, "StoreL");
1999 }
2000
2001 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2002 static {
2003 storeOfNodes(STORE_L_OF_CLASS, "StoreL", IS_REPLACED);
2004 }
2005
2006 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2007 static {
2008 beforeMatchingNameRegex(STORE_N, "StoreN");
2009 }
2010
2011 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2012 static {
2013 storeOfNodes(STORE_N_OF_CLASS, "StoreN", IS_REPLACED);
2014 }
2015
2016 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2017 static {
2018 anyStoreOfNodes(STORE_OF_CLASS, IS_REPLACED);
2019 }
2020
2021 public static void anyStoreOfNodes(String irNodePlaceholder, String fieldHolder) {
2022 storeOfNodes(irNodePlaceholder, "Store(B|C|S|I|L|F|D|P|N)", fieldHolder);
2023 }
2024
2025 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2026 static {
2027 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2028 beforeMatching(STORE_OF_FIELD, regex);
2029 }
2030
2031 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2032 static {
2033 beforeMatchingNameRegex(STORE_P, "StoreP");
2034 }
2035
2036 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2037 static {
2038 storeOfNodes(STORE_P_OF_CLASS, "StoreP", IS_REPLACED);
2039 }
2040
2041 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2042 static {
2043 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2044 }
2045
2046 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2047 static {
2048 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2049 }
2050
2051 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2052 static {
2053 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2054 }
2055
2056 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2057 static {
2058 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2108 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2109 }
2110
2111 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2112 static {
2113 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2114 }
2115
2116 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2117 static {
2118 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2119 }
2120
2121 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2122 static {
2123 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2124 }
2125
2126 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2127 static {
2128 String regex = START + "SubTypeCheck" + MID + END;
2129 macroNodes(SUBTYPE_CHECK, regex);
2130 }
2131
2132 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2133 static {
2134 trapNodes(TRAP, "reason");
2135 }
2136
2137 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2138 static {
2139 beforeMatchingNameRegex(DIV_HF, "DivHF");
2140 }
2141
2142 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2143 static {
2144 beforeMatchingNameRegex(UDIV_I, "UDivI");
2145 }
2146
2147 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2148 static {
2149 beforeMatchingNameRegex(UDIV_L, "UDivL");
2891
2892 public static final String MOD_D = PREFIX + "MOD_D" + POSTFIX;
2893 static {
2894 String regex = START + "ModD" + MID + END;
2895 macroNodes(MOD_D, regex);
2896 }
2897
2898 public static final String BLACKHOLE = PREFIX + "BLACKHOLE" + POSTFIX;
2899 static {
2900 fromBeforeRemoveUselessToFinalCode(BLACKHOLE, "Blackhole");
2901 }
2902
2903 /*
2904 * Utility methods to set up IR_NODE_MAPPINGS.
2905 */
2906
2907 /**
2908 * Apply {@code regex} on all machine independent ideal graph phases up to and including
2909 * {@link CompilePhase#BEFORE_MATCHING}.
2910 */
2911 public static void beforeMatching(String irNodePlaceholder, String regex) {
2912 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2913 }
2914
2915 /**
2916 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
2917 * including {@link CompilePhase#BEFORE_MATCHING}.
2918 */
2919 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
2920 String regex = START + irNodeRegex + MID + END;
2921 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2922 }
2923
2924 /**
2925 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
2926 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
2927 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
2928 */
2929 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
2930 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
2931 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
2932 // IS_REPLACED is later replaced with the specific type and size of the vector.
2933 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
2934 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2935 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
2936 }
2937
2938 /**
2939 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
2940 */
2941 private static void macroNodes(String irNodePlaceholder, String regex) {
2942 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
2943 CompilePhase.BEFORE_STRINGOPTS,
2944 CompilePhase.BEFORE_MACRO_EXPANSION));
2945 }
2946
2947 private static void callOfNodes(String irNodePlaceholder, String callRegex, String calleeRegex) {
2948 String regex = START + callRegex + MID + calleeRegex + END;
2949 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2950 }
2951
2952 /**
2953 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
2954 * {@link CompilePhase#MATCHING}.
2955 */
2956 public static void optoOnly(String irNodePlaceholder, String regex) {
2957 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
2958 }
2959
2960 private static void machOnly(String irNodePlaceholder, String regex) {
2961 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2962 }
2963
2964 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
2965 String regex = START + irNodeRegex + MID + END;
2966 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2967 }
2968
2969 /**
2970 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
2971 */
2972 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
2973 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2974 CompilePhase.AFTER_CLOOPS,
2975 CompilePhase.FINAL_CODE));
2976 }
3009 * up to and including {@link CompilePhase#AFTER_LOOP_OPTS}.
3010 */
3011 private static void duringLoopOpts(String irNodePlaceholder, String regex) {
3012 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_LOOP_OPTS, regex,
3013 CompilePhase.BEFORE_LOOP_OPTS,
3014 CompilePhase.AFTER_LOOP_OPTS));
3015 }
3016
3017 private static void trapNodes(String irNodePlaceholder, String trapReason) {
3018 String regex = START + "CallStaticJava" + MID + "uncommon_trap.*" + trapReason + END;
3019 beforeMatching(irNodePlaceholder, regex);
3020 }
3021
3022 private static void parsePredicateNodes(String irNodePlaceholder, String label) {
3023 String regex = START + "ParsePredicate" + MID + "#" + label + " " + END;
3024 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_PARSING, regex,
3025 CompilePhase.AFTER_PARSING,
3026 CompilePhase.AFTER_LOOP_OPTS));
3027 }
3028
3029 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex, String loadee) {
3030 String regex = START + irNodeRegex + MID + "@(\\w+: ?)*[\\w/]*\\b" + loadee + LOAD_OF_CLASS_POSTFIX;
3031 beforeMatching(irNodePlaceholder, regex);
3032 }
3033
3034 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex, String storee) {
3035 String regex = START + irNodeRegex + MID + "@(\\w+: ?)*[\\w/]*\\b" + storee + STORE_OF_CLASS_POSTFIX;
3036 beforeMatching(irNodePlaceholder, regex);
3037 }
3038
3039 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3040 String regex = START + irNodeRegex + MID + END;
3041 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3042 CompilePhase.BEFORE_REMOVEUSELESS,
3043 CompilePhase.FINAL_CODE));
3044 }
3045
3046 /**
3047 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3048 * first phase that could contain vector nodes from super word.
3049 */
3050 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
3051 String regex = START + irNodeRegex + MID + END;
3052 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3053 CompilePhase.PHASEIDEALLOOP1,
3054 CompilePhase.BEFORE_MATCHING));
3055 }
|