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
684 beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
685 }
686
687 public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
688 static {
689 vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
690 }
691
692 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
693 static {
694 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
695 }
696
697 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
698 static {
699 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
700 }
701
702 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
703 static {
704 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava");
705 }
706
707 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
708 static {
709 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
710 }
711
712 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
713 static {
714 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
715 }
716
717 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
718 static {
719 String regex = START + "FastUnlock" + MID + END;
720 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
721 }
722
723 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
724 static {
820 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
821 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
822 }
823
824 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
825 static {
826 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
827 }
828
829 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
830 static {
831 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
832 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
833 }
834
835 public static final String IF = PREFIX + "IF" + POSTFIX;
836 static {
837 beforeMatchingNameRegex(IF, "If\\b");
838 }
839
840 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
841 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
842 static {
843 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
844 }
845
846 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
847 static {
848 trapNodes(INTRINSIC_TRAP, "intrinsic");
849 }
850
851 // Is only supported on riscv64.
852 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
853 static {
854 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
855 }
856
857 // Is only supported on riscv64.
858 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
859 static {
860 beforeMatchingNameRegex(IS_FINITE_F, "IsFiniteF");
861 }
862
863 public static final String IS_INFINITE_D = PREFIX + "IS_INFINITE_D" + POSTFIX;
864 static {
865 beforeMatchingNameRegex(IS_INFINITE_D, "IsInfiniteD");
866 }
867
868 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
869 static {
870 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
871 }
872
873 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
874 static {
875 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
876 }
877
878 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
879 static {
880 loadOfNodes(LOAD_OF_CLASS, "Load(B|UB|S|US|I|L|F|D|P|N)");
881 }
882
883 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
884 static {
885 beforeMatchingNameRegex(LOAD_B, "LoadB");
886 }
887
888 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
889 static {
890 loadOfNodes(LOAD_B_OF_CLASS, "LoadB");
891 }
892
893 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
894 static {
895 beforeMatchingNameRegex(LOAD_D, "LoadD");
896 }
897
898 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
899 static {
900 loadOfNodes(LOAD_D_OF_CLASS, "LoadD");
901 }
902
903 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
904 static {
905 beforeMatchingNameRegex(LOAD_F, "LoadF");
906 }
907
908 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
909 static {
910 loadOfNodes(LOAD_F_OF_CLASS, "LoadF");
911 }
912
913 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
914 static {
915 beforeMatchingNameRegex(LOAD_I, "LoadI");
916 }
917
918 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
919 static {
920 loadOfNodes(LOAD_I_OF_CLASS, "LoadI");
921 }
922
923 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
924 static {
925 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
926 }
927
928 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
929 static {
930 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
931 }
932
933 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
934 static {
935 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
936 }
937
938 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
939 static {
940 beforeMatchingNameRegex(LOAD_L, "LoadL");
941 }
942
943 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
944 static {
945 loadOfNodes(LOAD_L_OF_CLASS, "LoadL");
946 }
947
948 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
949 static {
950 beforeMatchingNameRegex(LOAD_N, "LoadN");
951 }
952
953 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
954 static {
955 loadOfNodes(LOAD_N_OF_CLASS, "LoadN");
956 }
957
958 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
959 static {
960 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
961 beforeMatching(LOAD_OF_FIELD, regex);
962 }
963
964 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
965 static {
966 beforeMatchingNameRegex(LOAD_P, "LoadP");
967 }
968
969 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
970 static {
971 loadOfNodes(LOAD_P_OF_CLASS, "LoadP");
972 }
973
974 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
975 static {
976 beforeMatchingNameRegex(LOAD_S, "LoadS");
977 }
978
979 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
980 static {
981 loadOfNodes(LOAD_S_OF_CLASS, "LoadS");
982 }
983
984 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
985 static {
986 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
987 }
988
989 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
990 static {
991 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB");
992 }
993
994 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
995 static {
996 beforeMatchingNameRegex(LOAD_US, "LoadUS");
997 }
998
999 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1000 static {
1001 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS");
1002 }
1003
1004 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1005 static {
1006 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1007 }
1008
1009 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1010 static {
1011 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1012 }
1013
1014 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1015 static {
1016 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1017 }
1018
1019 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1020 static {
1021 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
1860 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
1861 }
1862
1863 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
1864 static {
1865 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
1866 }
1867
1868 public static final String STORE = PREFIX + "STORE" + POSTFIX;
1869 static {
1870 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
1871 }
1872
1873 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
1874 static {
1875 beforeMatchingNameRegex(STORE_B, "StoreB");
1876 }
1877
1878 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
1879 static {
1880 storeOfNodes(STORE_B_OF_CLASS, "StoreB");
1881 }
1882
1883 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
1884 static {
1885 beforeMatchingNameRegex(STORE_C, "StoreC");
1886 }
1887
1888 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
1889 static {
1890 storeOfNodes(STORE_C_OF_CLASS, "StoreC");
1891 }
1892
1893 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
1894 static {
1895 beforeMatchingNameRegex(STORE_D, "StoreD");
1896 }
1897
1898 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
1899 static {
1900 storeOfNodes(STORE_D_OF_CLASS, "StoreD");
1901 }
1902
1903 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
1904 static {
1905 beforeMatchingNameRegex(STORE_F, "StoreF");
1906 }
1907
1908 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
1909 static {
1910 storeOfNodes(STORE_F_OF_CLASS, "StoreF");
1911 }
1912
1913 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
1914 static {
1915 beforeMatchingNameRegex(STORE_I, "StoreI");
1916 }
1917
1918 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
1919 static {
1920 storeOfNodes(STORE_I_OF_CLASS, "StoreI");
1921 }
1922
1923 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
1924 static {
1925 beforeMatchingNameRegex(STORE_L, "StoreL");
1926 }
1927
1928 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
1929 static {
1930 storeOfNodes(STORE_L_OF_CLASS, "StoreL");
1931 }
1932
1933 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
1934 static {
1935 beforeMatchingNameRegex(STORE_N, "StoreN");
1936 }
1937
1938 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
1939 static {
1940 storeOfNodes(STORE_N_OF_CLASS, "StoreN");
1941 }
1942
1943 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
1944 static {
1945 storeOfNodes(STORE_OF_CLASS, "Store(B|C|S|I|L|F|D|P|N)");
1946 }
1947
1948 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
1949 static {
1950 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1951 beforeMatching(STORE_OF_FIELD, regex);
1952 }
1953
1954 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
1955 static {
1956 beforeMatchingNameRegex(STORE_P, "StoreP");
1957 }
1958
1959 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
1960 static {
1961 storeOfNodes(STORE_P_OF_CLASS, "StoreP");
1962 }
1963
1964 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
1965 static {
1966 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
1967 }
1968
1969 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
1970 static {
1971 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
1972 }
1973
1974 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
1975 static {
1976 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
1977 }
1978
1979 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
1980 static {
1981 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2031 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2032 }
2033
2034 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2035 static {
2036 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2037 }
2038
2039 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2040 static {
2041 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2042 }
2043
2044 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2045 static {
2046 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2047 }
2048
2049 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2050 static {
2051 beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");
2052 }
2053
2054 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2055 static {
2056 trapNodes(TRAP, "reason");
2057 }
2058
2059 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2060 static {
2061 beforeMatchingNameRegex(DIV_HF, "DivHF");
2062 }
2063
2064 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2065 static {
2066 beforeMatchingNameRegex(UDIV_I, "UDivI");
2067 }
2068
2069 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2070 static {
2071 beforeMatchingNameRegex(UDIV_L, "UDivL");
2783
2784 public static final String MOD_D = PREFIX + "MOD_D" + POSTFIX;
2785 static {
2786 String regex = START + "ModD" + MID + END;
2787 macroNodes(MOD_D, regex);
2788 }
2789
2790 public static final String BLACKHOLE = PREFIX + "BLACKHOLE" + POSTFIX;
2791 static {
2792 fromBeforeRemoveUselessToFinalCode(BLACKHOLE, "Blackhole");
2793 }
2794
2795 /*
2796 * Utility methods to set up IR_NODE_MAPPINGS.
2797 */
2798
2799 /**
2800 * Apply {@code regex} on all machine independent ideal graph phases up to and including
2801 * {@link CompilePhase#BEFORE_MATCHING}.
2802 */
2803 private static void beforeMatching(String irNodePlaceholder, String regex) {
2804 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2805 }
2806
2807 /**
2808 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
2809 * including {@link CompilePhase#BEFORE_MATCHING}.
2810 */
2811 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
2812 String regex = START + irNodeRegex + MID + END;
2813 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2814 }
2815
2816 /**
2817 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
2818 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
2819 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
2820 */
2821 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
2822 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
2823 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
2824 // IS_REPLACED is later replaced with the specific type and size of the vector.
2825 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
2826 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2827 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
2828 }
2829
2830 /**
2831 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
2832 */
2833 private static void macroNodes(String irNodePlaceholder, String regex) {
2834 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
2835 CompilePhase.BEFORE_STRINGOPTS,
2836 CompilePhase.BEFORE_MACRO_EXPANSION));
2837 }
2838
2839 private static void callOfNodes(String irNodePlaceholder, String callRegex) {
2840 String regex = START + callRegex + MID + IS_REPLACED + " " + END;
2841 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2842 }
2843
2844 /**
2845 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
2846 * {@link CompilePhase#MATCHING}.
2847 */
2848 private static void optoOnly(String irNodePlaceholder, String regex) {
2849 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
2850 }
2851
2852 private static void machOnly(String irNodePlaceholder, String regex) {
2853 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2854 }
2855
2856 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
2857 String regex = START + irNodeRegex + MID + END;
2858 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2859 }
2860
2861 /**
2862 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
2863 */
2864 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
2865 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2866 CompilePhase.AFTER_CLOOPS,
2867 CompilePhase.FINAL_CODE));
2868 }
2901 * up to and including {@link CompilePhase#AFTER_LOOP_OPTS}.
2902 */
2903 private static void duringLoopOpts(String irNodePlaceholder, String regex) {
2904 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_LOOP_OPTS, regex,
2905 CompilePhase.BEFORE_LOOP_OPTS,
2906 CompilePhase.AFTER_LOOP_OPTS));
2907 }
2908
2909 private static void trapNodes(String irNodePlaceholder, String trapReason) {
2910 String regex = START + "CallStaticJava" + MID + "uncommon_trap.*" + trapReason + END;
2911 beforeMatching(irNodePlaceholder, regex);
2912 }
2913
2914 private static void parsePredicateNodes(String irNodePlaceholder, String label) {
2915 String regex = START + "ParsePredicate" + MID + "#" + label + " " + END;
2916 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_PARSING, regex,
2917 CompilePhase.AFTER_PARSING,
2918 CompilePhase.AFTER_LOOP_OPTS));
2919 }
2920
2921 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
2922 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + LOAD_OF_CLASS_POSTFIX;
2923 beforeMatching(irNodePlaceholder, regex);
2924 }
2925
2926 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
2927 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + STORE_OF_CLASS_POSTFIX;
2928 beforeMatching(irNodePlaceholder, regex);
2929 }
2930
2931 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
2932 String regex = START + irNodeRegex + MID + END;
2933 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2934 CompilePhase.BEFORE_REMOVEUSELESS,
2935 CompilePhase.FINAL_CODE));
2936 }
2937
2938 /**
2939 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
2940 * first phase that could contain vector nodes from super word.
2941 */
2942 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
2943 String regex = START + irNodeRegex + MID + END;
2944 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2945 CompilePhase.PHASEIDEALLOOP1,
2946 CompilePhase.BEFORE_MATCHING));
2947 }
|
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
727 beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
728 }
729
730 public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
731 static {
732 vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
733 }
734
735 public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
736 static {
737 vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
738 }
739
740 public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
741 static {
742 vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
743 }
744
745 public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
746 static {
747 callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava", IS_REPLACED);
748 }
749
750 public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
751 static {
752 beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
753 }
754
755 public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
756 static {
757 beforeMatchingNameRegex(FAST_LOCK, "FastLock");
758 }
759
760 public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
761 static {
762 String regex = START + "FastUnlock" + MID + END;
763 fromMacroToBeforeMatching(FAST_UNLOCK, regex);
764 }
765
766 public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
767 static {
863 String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
864 machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
865 }
866
867 public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
868 static {
869 machOnlyNameRegex(G1_STORE_P, "g1StoreP");
870 }
871
872 public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
873 static {
874 String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
875 machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
876 }
877
878 public static final String IF = PREFIX + "IF" + POSTFIX;
879 static {
880 beforeMatchingNameRegex(IF, "If\\b");
881 }
882
883 public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;
884 static {
885 beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
886 }
887
888 // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
889 public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
890 static {
891 trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
892 }
893
894 public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
895 static {
896 trapNodes(INTRINSIC_TRAP, "intrinsic");
897 }
898
899 // Is only supported on riscv64.
900 public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
901 static {
902 beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
903 }
904
905 // Is only supported on riscv64.
906 public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
907 static {
908 beforeMatchingNameRegex(IS_FINITE_F, "IsFiniteF");
909 }
910
911 public static final String IS_INFINITE_D = PREFIX + "IS_INFINITE_D" + POSTFIX;
912 static {
913 beforeMatchingNameRegex(IS_INFINITE_D, "IsInfiniteD");
914 }
915
916 public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
917 static {
918 beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
919 }
920
921 public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
922 static {
923 beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
924 }
925
926 public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
927 static {
928 anyLoadOfNodes(LOAD_OF_CLASS, IS_REPLACED);
929 }
930
931 public static void anyLoadOfNodes(String irNodePlaceholder, String fieldHolder) {
932 loadOfNodes(irNodePlaceholder, "Load(B|UB|S|US|I|L|F|D|P|N)", fieldHolder);
933 }
934
935 public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
936 static {
937 beforeMatchingNameRegex(LOAD_B, "LoadB");
938 }
939
940 public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
941 static {
942 loadOfNodes(LOAD_B_OF_CLASS, "LoadB", IS_REPLACED);
943 }
944
945 public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
946 static {
947 beforeMatchingNameRegex(LOAD_D, "LoadD");
948 }
949
950 public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
951 static {
952 loadOfNodes(LOAD_D_OF_CLASS, "LoadD", IS_REPLACED);
953 }
954
955 public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
956 static {
957 beforeMatchingNameRegex(LOAD_F, "LoadF");
958 }
959
960 public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
961 static {
962 loadOfNodes(LOAD_F_OF_CLASS, "LoadF", IS_REPLACED);
963 }
964
965 public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
966 static {
967 beforeMatchingNameRegex(LOAD_I, "LoadI");
968 }
969
970 public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
971 static {
972 loadOfNodes(LOAD_I_OF_CLASS, "LoadI", IS_REPLACED);
973 }
974
975 public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
976 static {
977 beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
978 }
979
980 public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
981 static {
982 beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
983 }
984
985 public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
986 static {
987 beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
988 }
989
990 public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
991 static {
992 beforeMatchingNameRegex(LOAD_L, "LoadL");
993 }
994
995 public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
996 static {
997 loadOfNodes(LOAD_L_OF_CLASS, "LoadL", IS_REPLACED);
998 }
999
1000 public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1001 static {
1002 beforeMatchingNameRegex(LOAD_N, "LoadN");
1003 }
1004
1005 public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1006 static {
1007 loadOfNodes(LOAD_N_OF_CLASS, "LoadN", IS_REPLACED);
1008 }
1009
1010 public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1011 static {
1012 String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1013 beforeMatching(LOAD_OF_FIELD, regex);
1014 }
1015
1016 public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1017 static {
1018 beforeMatchingNameRegex(LOAD_P, "LoadP");
1019 }
1020
1021 public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1022 static {
1023 loadOfNodes(LOAD_P_OF_CLASS, "LoadP", IS_REPLACED);
1024 }
1025
1026 public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1027 static {
1028 beforeMatchingNameRegex(LOAD_S, "LoadS");
1029 }
1030
1031 public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1032 static {
1033 loadOfNodes(LOAD_S_OF_CLASS, "LoadS", IS_REPLACED);
1034 }
1035
1036 public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1037 static {
1038 beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1039 }
1040
1041 public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1042 static {
1043 loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB", IS_REPLACED);
1044 }
1045
1046 public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1047 static {
1048 beforeMatchingNameRegex(LOAD_US, "LoadUS");
1049 }
1050
1051 public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1052 static {
1053 loadOfNodes(LOAD_US_OF_CLASS, "LoadUS", IS_REPLACED);
1054 }
1055
1056 public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1057 static {
1058 vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1059 }
1060
1061 public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1062 static {
1063 vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1064 }
1065
1066 public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1067 static {
1068 vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1069 }
1070
1071 public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1072 static {
1073 vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);
1912 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
1913 }
1914
1915 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
1916 static {
1917 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
1918 }
1919
1920 public static final String STORE = PREFIX + "STORE" + POSTFIX;
1921 static {
1922 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
1923 }
1924
1925 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
1926 static {
1927 beforeMatchingNameRegex(STORE_B, "StoreB");
1928 }
1929
1930 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
1931 static {
1932 storeOfNodes(STORE_B_OF_CLASS, "StoreB", IS_REPLACED);
1933 }
1934
1935 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
1936 static {
1937 beforeMatchingNameRegex(STORE_C, "StoreC");
1938 }
1939
1940 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
1941 static {
1942 storeOfNodes(STORE_C_OF_CLASS, "StoreC", IS_REPLACED);
1943 }
1944
1945 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
1946 static {
1947 beforeMatchingNameRegex(STORE_D, "StoreD");
1948 }
1949
1950 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
1951 static {
1952 storeOfNodes(STORE_D_OF_CLASS, "StoreD", IS_REPLACED);
1953 }
1954
1955 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
1956 static {
1957 beforeMatchingNameRegex(STORE_F, "StoreF");
1958 }
1959
1960 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
1961 static {
1962 storeOfNodes(STORE_F_OF_CLASS, "StoreF", IS_REPLACED);
1963 }
1964
1965 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
1966 static {
1967 beforeMatchingNameRegex(STORE_I, "StoreI");
1968 }
1969
1970 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
1971 static {
1972 storeOfNodes(STORE_I_OF_CLASS, "StoreI", IS_REPLACED);
1973 }
1974
1975 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
1976 static {
1977 beforeMatchingNameRegex(STORE_L, "StoreL");
1978 }
1979
1980 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
1981 static {
1982 storeOfNodes(STORE_L_OF_CLASS, "StoreL", IS_REPLACED);
1983 }
1984
1985 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
1986 static {
1987 beforeMatchingNameRegex(STORE_N, "StoreN");
1988 }
1989
1990 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
1991 static {
1992 storeOfNodes(STORE_N_OF_CLASS, "StoreN", IS_REPLACED);
1993 }
1994
1995 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
1996 static {
1997 anyStoreOfNodes(STORE_OF_CLASS, IS_REPLACED);
1998 }
1999
2000 public static void anyStoreOfNodes(String irNodePlaceholder, String fieldHolder) {
2001 storeOfNodes(irNodePlaceholder, "Store(B|C|S|I|L|F|D|P|N)", fieldHolder);
2002 }
2003
2004 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2005 static {
2006 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2007 beforeMatching(STORE_OF_FIELD, regex);
2008 }
2009
2010 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2011 static {
2012 beforeMatchingNameRegex(STORE_P, "StoreP");
2013 }
2014
2015 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2016 static {
2017 storeOfNodes(STORE_P_OF_CLASS, "StoreP", IS_REPLACED);
2018 }
2019
2020 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2021 static {
2022 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2023 }
2024
2025 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2026 static {
2027 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2028 }
2029
2030 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2031 static {
2032 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2033 }
2034
2035 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2036 static {
2037 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2087 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2088 }
2089
2090 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2091 static {
2092 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2093 }
2094
2095 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2096 static {
2097 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2098 }
2099
2100 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2101 static {
2102 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2103 }
2104
2105 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2106 static {
2107 String regex = START + "SubTypeCheck" + MID + END;
2108 macroNodes(SUBTYPE_CHECK, regex);
2109 }
2110
2111 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2112 static {
2113 trapNodes(TRAP, "reason");
2114 }
2115
2116 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2117 static {
2118 beforeMatchingNameRegex(DIV_HF, "DivHF");
2119 }
2120
2121 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2122 static {
2123 beforeMatchingNameRegex(UDIV_I, "UDivI");
2124 }
2125
2126 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2127 static {
2128 beforeMatchingNameRegex(UDIV_L, "UDivL");
2840
2841 public static final String MOD_D = PREFIX + "MOD_D" + POSTFIX;
2842 static {
2843 String regex = START + "ModD" + MID + END;
2844 macroNodes(MOD_D, regex);
2845 }
2846
2847 public static final String BLACKHOLE = PREFIX + "BLACKHOLE" + POSTFIX;
2848 static {
2849 fromBeforeRemoveUselessToFinalCode(BLACKHOLE, "Blackhole");
2850 }
2851
2852 /*
2853 * Utility methods to set up IR_NODE_MAPPINGS.
2854 */
2855
2856 /**
2857 * Apply {@code regex} on all machine independent ideal graph phases up to and including
2858 * {@link CompilePhase#BEFORE_MATCHING}.
2859 */
2860 public static void beforeMatching(String irNodePlaceholder, String regex) {
2861 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2862 }
2863
2864 /**
2865 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
2866 * including {@link CompilePhase#BEFORE_MATCHING}.
2867 */
2868 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
2869 String regex = START + irNodeRegex + MID + END;
2870 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2871 }
2872
2873 /**
2874 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
2875 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
2876 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
2877 */
2878 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
2879 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
2880 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
2881 // IS_REPLACED is later replaced with the specific type and size of the vector.
2882 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
2883 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2884 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
2885 }
2886
2887 /**
2888 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
2889 */
2890 private static void macroNodes(String irNodePlaceholder, String regex) {
2891 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
2892 CompilePhase.BEFORE_STRINGOPTS,
2893 CompilePhase.BEFORE_MACRO_EXPANSION));
2894 }
2895
2896 private static void callOfNodes(String irNodePlaceholder, String callRegex, String calleeRegex) {
2897 String regex = START + callRegex + MID + calleeRegex + END;
2898 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2899 }
2900
2901 /**
2902 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
2903 * {@link CompilePhase#MATCHING}.
2904 */
2905 public static void optoOnly(String irNodePlaceholder, String regex) {
2906 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
2907 }
2908
2909 private static void machOnly(String irNodePlaceholder, String regex) {
2910 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2911 }
2912
2913 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
2914 String regex = START + irNodeRegex + MID + END;
2915 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2916 }
2917
2918 /**
2919 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
2920 */
2921 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
2922 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2923 CompilePhase.AFTER_CLOOPS,
2924 CompilePhase.FINAL_CODE));
2925 }
2958 * up to and including {@link CompilePhase#AFTER_LOOP_OPTS}.
2959 */
2960 private static void duringLoopOpts(String irNodePlaceholder, String regex) {
2961 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_LOOP_OPTS, regex,
2962 CompilePhase.BEFORE_LOOP_OPTS,
2963 CompilePhase.AFTER_LOOP_OPTS));
2964 }
2965
2966 private static void trapNodes(String irNodePlaceholder, String trapReason) {
2967 String regex = START + "CallStaticJava" + MID + "uncommon_trap.*" + trapReason + END;
2968 beforeMatching(irNodePlaceholder, regex);
2969 }
2970
2971 private static void parsePredicateNodes(String irNodePlaceholder, String label) {
2972 String regex = START + "ParsePredicate" + MID + "#" + label + " " + END;
2973 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_PARSING, regex,
2974 CompilePhase.AFTER_PARSING,
2975 CompilePhase.AFTER_LOOP_OPTS));
2976 }
2977
2978 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex, String loadee) {
2979 String regex = START + irNodeRegex + MID + "@(\\w+: ?)*[\\w/]*\\b" + loadee + LOAD_OF_CLASS_POSTFIX;
2980 beforeMatching(irNodePlaceholder, regex);
2981 }
2982
2983 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex, String storee) {
2984 String regex = START + irNodeRegex + MID + "@(\\w+: ?)*[\\w/]*\\b" + storee + STORE_OF_CLASS_POSTFIX;
2985 beforeMatching(irNodePlaceholder, regex);
2986 }
2987
2988 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
2989 String regex = START + irNodeRegex + MID + END;
2990 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2991 CompilePhase.BEFORE_REMOVEUSELESS,
2992 CompilePhase.FINAL_CODE));
2993 }
2994
2995 /**
2996 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
2997 * first phase that could contain vector nodes from super word.
2998 */
2999 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
3000 String regex = START + irNodeRegex + MID + END;
3001 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3002 CompilePhase.PHASEIDEALLOOP1,
3003 CompilePhase.BEFORE_MATCHING));
3004 }
|