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);
1810 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
1811 }
1812
1813 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
1814 static {
1815 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
1816 }
1817
1818 public static final String STORE = PREFIX + "STORE" + POSTFIX;
1819 static {
1820 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
1821 }
1822
1823 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
1824 static {
1825 beforeMatchingNameRegex(STORE_B, "StoreB");
1826 }
1827
1828 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
1829 static {
1830 storeOfNodes(STORE_B_OF_CLASS, "StoreB");
1831 }
1832
1833 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
1834 static {
1835 beforeMatchingNameRegex(STORE_C, "StoreC");
1836 }
1837
1838 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
1839 static {
1840 storeOfNodes(STORE_C_OF_CLASS, "StoreC");
1841 }
1842
1843 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
1844 static {
1845 beforeMatchingNameRegex(STORE_D, "StoreD");
1846 }
1847
1848 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
1849 static {
1850 storeOfNodes(STORE_D_OF_CLASS, "StoreD");
1851 }
1852
1853 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
1854 static {
1855 beforeMatchingNameRegex(STORE_F, "StoreF");
1856 }
1857
1858 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
1859 static {
1860 storeOfNodes(STORE_F_OF_CLASS, "StoreF");
1861 }
1862
1863 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
1864 static {
1865 beforeMatchingNameRegex(STORE_I, "StoreI");
1866 }
1867
1868 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
1869 static {
1870 storeOfNodes(STORE_I_OF_CLASS, "StoreI");
1871 }
1872
1873 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
1874 static {
1875 beforeMatchingNameRegex(STORE_L, "StoreL");
1876 }
1877
1878 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
1879 static {
1880 storeOfNodes(STORE_L_OF_CLASS, "StoreL");
1881 }
1882
1883 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
1884 static {
1885 beforeMatchingNameRegex(STORE_N, "StoreN");
1886 }
1887
1888 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
1889 static {
1890 storeOfNodes(STORE_N_OF_CLASS, "StoreN");
1891 }
1892
1893 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
1894 static {
1895 storeOfNodes(STORE_OF_CLASS, "Store(B|C|S|I|L|F|D|P|N)");
1896 }
1897
1898 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
1899 static {
1900 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1901 beforeMatching(STORE_OF_FIELD, regex);
1902 }
1903
1904 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
1905 static {
1906 beforeMatchingNameRegex(STORE_P, "StoreP");
1907 }
1908
1909 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
1910 static {
1911 storeOfNodes(STORE_P_OF_CLASS, "StoreP");
1912 }
1913
1914 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
1915 static {
1916 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
1917 }
1918
1919 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
1920 static {
1921 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
1922 }
1923
1924 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
1925 static {
1926 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
1927 }
1928
1929 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
1930 static {
1931 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
1981 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
1982 }
1983
1984 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
1985 static {
1986 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
1987 }
1988
1989 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
1990 static {
1991 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
1992 }
1993
1994 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
1995 static {
1996 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
1997 }
1998
1999 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2000 static {
2001 beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");
2002 }
2003
2004 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2005 static {
2006 trapNodes(TRAP, "reason");
2007 }
2008
2009 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2010 static {
2011 beforeMatchingNameRegex(DIV_HF, "DivHF");
2012 }
2013
2014 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2015 static {
2016 beforeMatchingNameRegex(UDIV_I, "UDivI");
2017 }
2018
2019 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2020 static {
2021 beforeMatchingNameRegex(UDIV_L, "UDivL");
2713
2714 public static final String MOD_D = PREFIX + "MOD_D" + POSTFIX;
2715 static {
2716 String regex = START + "ModD" + MID + END;
2717 macroNodes(MOD_D, regex);
2718 }
2719
2720 public static final String BLACKHOLE = PREFIX + "BLACKHOLE" + POSTFIX;
2721 static {
2722 fromBeforeRemoveUselessToFinalCode(BLACKHOLE, "Blackhole");
2723 }
2724
2725 /*
2726 * Utility methods to set up IR_NODE_MAPPINGS.
2727 */
2728
2729 /**
2730 * Apply {@code regex} on all machine independent ideal graph phases up to and including
2731 * {@link CompilePhase#BEFORE_MATCHING}.
2732 */
2733 private static void beforeMatching(String irNodePlaceholder, String regex) {
2734 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2735 }
2736
2737 /**
2738 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
2739 * including {@link CompilePhase#BEFORE_MATCHING}.
2740 */
2741 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
2742 String regex = START + irNodeRegex + MID + END;
2743 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2744 }
2745
2746 /**
2747 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
2748 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
2749 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
2750 */
2751 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
2752 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
2753 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
2754 // IS_REPLACED is later replaced with the specific type and size of the vector.
2755 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
2756 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2757 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
2758 }
2759
2760 /**
2761 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
2762 */
2763 private static void macroNodes(String irNodePlaceholder, String regex) {
2764 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
2765 CompilePhase.BEFORE_STRINGOPTS,
2766 CompilePhase.BEFORE_MACRO_EXPANSION));
2767 }
2768
2769 private static void callOfNodes(String irNodePlaceholder, String callRegex) {
2770 String regex = START + callRegex + MID + IS_REPLACED + " " + END;
2771 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2772 }
2773
2774 /**
2775 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
2776 * {@link CompilePhase#MATCHING}.
2777 */
2778 private static void optoOnly(String irNodePlaceholder, String regex) {
2779 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
2780 }
2781
2782 private static void machOnly(String irNodePlaceholder, String regex) {
2783 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2784 }
2785
2786 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
2787 String regex = START + irNodeRegex + MID + END;
2788 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2789 }
2790
2791 /**
2792 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
2793 */
2794 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
2795 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2796 CompilePhase.AFTER_CLOOPS,
2797 CompilePhase.FINAL_CODE));
2798 }
2821 * including {@link CompilePhase#BEFORE_MATCHING}
2822 */
2823 private static void afterBarrierExpansionToBeforeMatching(String irNodePlaceholder, String regex) {
2824 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2825 CompilePhase.OPTIMIZE_FINISHED,
2826 CompilePhase.BEFORE_MATCHING));
2827 }
2828
2829 private static void trapNodes(String irNodePlaceholder, String trapReason) {
2830 String regex = START + "CallStaticJava" + MID + "uncommon_trap.*" + trapReason + END;
2831 beforeMatching(irNodePlaceholder, regex);
2832 }
2833
2834 private static void parsePredicateNodes(String irNodePlaceholder, String label) {
2835 String regex = START + "ParsePredicate" + MID + "#" + label + "[ ]*!jvms:" + END;
2836 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_PARSING, regex,
2837 CompilePhase.AFTER_PARSING,
2838 CompilePhase.PHASEIDEALLOOP_ITERATIONS));
2839 }
2840
2841 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
2842 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + LOAD_OF_CLASS_POSTFIX;
2843 beforeMatching(irNodePlaceholder, regex);
2844 }
2845
2846 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
2847 String regex = START + irNodeRegex + MID + "@\\S*" + IS_REPLACED + STORE_OF_CLASS_POSTFIX;
2848 beforeMatching(irNodePlaceholder, regex);
2849 }
2850
2851 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
2852 String regex = START + irNodeRegex + MID + END;
2853 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2854 CompilePhase.BEFORE_REMOVEUSELESS,
2855 CompilePhase.FINAL_CODE));
2856 }
2857
2858 /**
2859 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
2860 * first phase that could contain vector nodes from super word.
2861 */
2862 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
2863 String regex = START + irNodeRegex + MID + END;
2864 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2865 CompilePhase.PHASEIDEALLOOP1,
2866 CompilePhase.BEFORE_MATCHING));
2867 }
|
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);
1862 vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
1863 }
1864
1865 public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
1866 static {
1867 vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
1868 }
1869
1870 public static final String STORE = PREFIX + "STORE" + POSTFIX;
1871 static {
1872 beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
1873 }
1874
1875 public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
1876 static {
1877 beforeMatchingNameRegex(STORE_B, "StoreB");
1878 }
1879
1880 public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
1881 static {
1882 storeOfNodes(STORE_B_OF_CLASS, "StoreB", IS_REPLACED);
1883 }
1884
1885 public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
1886 static {
1887 beforeMatchingNameRegex(STORE_C, "StoreC");
1888 }
1889
1890 public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
1891 static {
1892 storeOfNodes(STORE_C_OF_CLASS, "StoreC", IS_REPLACED);
1893 }
1894
1895 public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
1896 static {
1897 beforeMatchingNameRegex(STORE_D, "StoreD");
1898 }
1899
1900 public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
1901 static {
1902 storeOfNodes(STORE_D_OF_CLASS, "StoreD", IS_REPLACED);
1903 }
1904
1905 public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
1906 static {
1907 beforeMatchingNameRegex(STORE_F, "StoreF");
1908 }
1909
1910 public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
1911 static {
1912 storeOfNodes(STORE_F_OF_CLASS, "StoreF", IS_REPLACED);
1913 }
1914
1915 public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
1916 static {
1917 beforeMatchingNameRegex(STORE_I, "StoreI");
1918 }
1919
1920 public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
1921 static {
1922 storeOfNodes(STORE_I_OF_CLASS, "StoreI", IS_REPLACED);
1923 }
1924
1925 public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
1926 static {
1927 beforeMatchingNameRegex(STORE_L, "StoreL");
1928 }
1929
1930 public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
1931 static {
1932 storeOfNodes(STORE_L_OF_CLASS, "StoreL", IS_REPLACED);
1933 }
1934
1935 public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
1936 static {
1937 beforeMatchingNameRegex(STORE_N, "StoreN");
1938 }
1939
1940 public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
1941 static {
1942 storeOfNodes(STORE_N_OF_CLASS, "StoreN", IS_REPLACED);
1943 }
1944
1945 public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
1946 static {
1947 anyStoreOfNodes(STORE_OF_CLASS, IS_REPLACED);
1948 }
1949
1950 public static void anyStoreOfNodes(String irNodePlaceholder, String fieldHolder) {
1951 storeOfNodes(irNodePlaceholder, "Store(B|C|S|I|L|F|D|P|N)", fieldHolder);
1952 }
1953
1954 public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
1955 static {
1956 String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1957 beforeMatching(STORE_OF_FIELD, regex);
1958 }
1959
1960 public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
1961 static {
1962 beforeMatchingNameRegex(STORE_P, "StoreP");
1963 }
1964
1965 public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
1966 static {
1967 storeOfNodes(STORE_P_OF_CLASS, "StoreP", IS_REPLACED);
1968 }
1969
1970 public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
1971 static {
1972 beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
1973 }
1974
1975 public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
1976 static {
1977 beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
1978 }
1979
1980 public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
1981 static {
1982 beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
1983 }
1984
1985 public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
1986 static {
1987 beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");
2037 vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2038 }
2039
2040 public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2041 static {
2042 vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2043 }
2044
2045 public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2046 static {
2047 vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2048 }
2049
2050 public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2051 static {
2052 vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2053 }
2054
2055 public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2056 static {
2057 String regex = START + "SubTypeCheck" + MID + END;
2058 macroNodes(SUBTYPE_CHECK, regex);
2059 }
2060
2061 public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2062 static {
2063 trapNodes(TRAP, "reason");
2064 }
2065
2066 public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2067 static {
2068 beforeMatchingNameRegex(DIV_HF, "DivHF");
2069 }
2070
2071 public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2072 static {
2073 beforeMatchingNameRegex(UDIV_I, "UDivI");
2074 }
2075
2076 public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2077 static {
2078 beforeMatchingNameRegex(UDIV_L, "UDivL");
2770
2771 public static final String MOD_D = PREFIX + "MOD_D" + POSTFIX;
2772 static {
2773 String regex = START + "ModD" + MID + END;
2774 macroNodes(MOD_D, regex);
2775 }
2776
2777 public static final String BLACKHOLE = PREFIX + "BLACKHOLE" + POSTFIX;
2778 static {
2779 fromBeforeRemoveUselessToFinalCode(BLACKHOLE, "Blackhole");
2780 }
2781
2782 /*
2783 * Utility methods to set up IR_NODE_MAPPINGS.
2784 */
2785
2786 /**
2787 * Apply {@code regex} on all machine independent ideal graph phases up to and including
2788 * {@link CompilePhase#BEFORE_MATCHING}.
2789 */
2790 public static void beforeMatching(String irNodePlaceholder, String regex) {
2791 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2792 }
2793
2794 /**
2795 * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
2796 * including {@link CompilePhase#BEFORE_MATCHING}.
2797 */
2798 private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
2799 String regex = START + irNodeRegex + MID + END;
2800 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2801 }
2802
2803 /**
2804 * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
2805 * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
2806 * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
2807 */
2808 private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
2809 TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
2810 + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
2811 // IS_REPLACED is later replaced with the specific type and size of the vector.
2812 String regex = START + irNodeRegex + MID + IS_REPLACED + END;
2813 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2814 VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
2815 }
2816
2817 /**
2818 * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
2819 */
2820 private static void macroNodes(String irNodePlaceholder, String regex) {
2821 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
2822 CompilePhase.BEFORE_STRINGOPTS,
2823 CompilePhase.BEFORE_MACRO_EXPANSION));
2824 }
2825
2826 private static void callOfNodes(String irNodePlaceholder, String callRegex, String calleeRegex) {
2827 String regex = START + callRegex + MID + calleeRegex + END;
2828 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
2829 }
2830
2831 /**
2832 * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
2833 * {@link CompilePhase#MATCHING}.
2834 */
2835 public static void optoOnly(String irNodePlaceholder, String regex) {
2836 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
2837 }
2838
2839 private static void machOnly(String irNodePlaceholder, String regex) {
2840 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2841 }
2842
2843 private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
2844 String regex = START + irNodeRegex + MID + END;
2845 IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
2846 }
2847
2848 /**
2849 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
2850 */
2851 private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
2852 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2853 CompilePhase.AFTER_CLOOPS,
2854 CompilePhase.FINAL_CODE));
2855 }
2878 * including {@link CompilePhase#BEFORE_MATCHING}
2879 */
2880 private static void afterBarrierExpansionToBeforeMatching(String irNodePlaceholder, String regex) {
2881 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2882 CompilePhase.OPTIMIZE_FINISHED,
2883 CompilePhase.BEFORE_MATCHING));
2884 }
2885
2886 private static void trapNodes(String irNodePlaceholder, String trapReason) {
2887 String regex = START + "CallStaticJava" + MID + "uncommon_trap.*" + trapReason + END;
2888 beforeMatching(irNodePlaceholder, regex);
2889 }
2890
2891 private static void parsePredicateNodes(String irNodePlaceholder, String label) {
2892 String regex = START + "ParsePredicate" + MID + "#" + label + "[ ]*!jvms:" + END;
2893 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.AFTER_PARSING, regex,
2894 CompilePhase.AFTER_PARSING,
2895 CompilePhase.PHASEIDEALLOOP_ITERATIONS));
2896 }
2897
2898 private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex, String loadee) {
2899 String regex = START + irNodeRegex + MID + "@(\\w+: ?)*[\\w/]*\\b" + loadee + LOAD_OF_CLASS_POSTFIX;
2900 beforeMatching(irNodePlaceholder, regex);
2901 }
2902
2903 private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex, String storee) {
2904 String regex = START + irNodeRegex + MID + "@(\\w+: ?)*[\\w/]*\\b" + storee + STORE_OF_CLASS_POSTFIX;
2905 beforeMatching(irNodePlaceholder, regex);
2906 }
2907
2908 private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
2909 String regex = START + irNodeRegex + MID + END;
2910 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2911 CompilePhase.BEFORE_REMOVEUSELESS,
2912 CompilePhase.FINAL_CODE));
2913 }
2914
2915 /**
2916 * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
2917 * first phase that could contain vector nodes from super word.
2918 */
2919 private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
2920 String regex = START + irNodeRegex + MID + END;
2921 IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
2922 CompilePhase.PHASEIDEALLOOP1,
2923 CompilePhase.BEFORE_MATCHING));
2924 }
|