< prev index next >

test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java

Print this page

  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package compiler.lib.ir_framework;
  25 
  26 import compiler.lib.ir_framework.driver.irmatching.mapping.*;
  27 import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo;
  28 import compiler.lib.ir_framework.shared.CheckedTestFrameworkException;
  29 import compiler.lib.ir_framework.shared.TestFormat;
  30 import compiler.lib.ir_framework.shared.TestFormatException;

  31 import jdk.test.lib.Platform;
  32 import jdk.test.whitebox.WhiteBox;
  33 
  34 import java.util.HashMap;
  35 import java.util.Map;
  36 
  37 /**
  38  * This class specifies IR node placeholder strings (also referred to as just "IR nodes") with mappings to regexes
  39  * depending on the selected compile phases. The mappings are stored in {@link #IR_NODE_MAPPINGS}. Each IR node
  40  * placeholder string is mapped to a {@link IRNodeMapEntry} instance defined in
  41  * {@link compiler.lib.ir_framework.driver.irmatching.mapping}.
  42  *
  43  * <p>
  44  * IR node placeholder strings can be used in {@link IR#failOn()} and/or {@link IR#counts()} attributes to define IR
  45  * constraints. They usually represent a single C2 IR node or a group of them.
  46  *
  47  * <p>
  48  * Each IR node placeholder string is accompanied by a static block that defines an IR node placeholder to regex(es)
  49  * mapping. The IR framework will automatically replace each IR node placeholder string in a user defined test with a
  50  * regex depending on the selected compile phases in {@link IR#phase} and the provided mapping.

  70  *                                 Using this IR node expects another user provided string in the constraint list of
  71  *                                 {@link IR#failOn()} and {@link IR#counts()}. They cannot be used as normal IR nodes.
  72  *                                 Trying to do so will result in a format violation error.</li>
  73  *     <li><p>Vector IR nodes:  The IR node placeholder string contains an additional {@link #VECTOR_PREFIX}.
  74  *                              Using this IR node, one can check for the type and size of a vector. The type must
  75  *                              be directly specified in {@link #vectorNode}. The size can be specified directly with
  76  *                              an additional argument using {@link #VECTOR_SIZE}, followed by a size tag or a comma
  77  *                              separated list of sizes. If the size argument is not given, then a default size of
  78  *                              {@link #VECTOR_SIZE_MAX} is taken, which is the number of elements that can fit in a
  79  *                              vector of the specified type (depends on the VM flag MaxVectorSize and CPU features).
  80  *                              However, when using {@link IR#failOn} or {@link IR#counts()} with comparison {@code <},
  81  *                              or {@code <=} or {@code =0}, the default size is {@link #VECTOR_SIZE_ANY}, allowing any
  82  *                              size. The motivation for these default values is that in most cases one wants to have
  83  *                              vectorization with maximal vector width, or no vectorization of any vector width.
  84  * </ul>
  85  */
  86 public class IRNode {
  87     /**
  88      * Prefix for normal IR nodes.
  89      */
  90     private static final String PREFIX = "_#";
  91     /**
  92      * Prefix for composite IR nodes.
  93      */
  94     private static final String COMPOSITE_PREFIX = PREFIX + "C#";
  95     /**
  96      * Prefix for vector IR nodes.
  97      */
  98     private static final String VECTOR_PREFIX = PREFIX + "V#";
  99 
 100     private static final String POSTFIX = "#_";
 101 
 102     public static final String START = "(\\d+(\\s){2}(";
 103     public static final String MID = ".*)+(\\s){2}===.*";
 104     public static final String END = ")";
 105 
 106     public static final String IS_REPLACED = "#IS_REPLACED#"; // Is replaced by an additional user-defined string.
 107 
 108     public static final String VECTOR_SIZE = "_@";
 109     public static final String VECTOR_SIZE_TAG_ANY = "any";
 110     public static final String VECTOR_SIZE_TAG_MAX = "max_for_type";

 133     /**
 134      * Map every vectorNode to a type string.
 135      */
 136     private static final Map<String, String> VECTOR_NODE_TYPE = new HashMap<>();
 137 
 138     /*
 139      * Start of IR placeholder string definitions followed by a static block defining the regex-for-compile-phase mapping.
 140      * An IR node placeholder string must start with PREFIX for normal IR nodes or COMPOSITE_PREFIX for composite IR
 141      * nodes, or VECTOR_PREFIX for vector nodes (see class description above).
 142      *
 143      * An IR node definition looks like this:
 144      *
 145      * public static final String IR_NODE = [PREFIX|COMPOSITE_PREFIX|VECTOR_PREFIX] + "IR_NODE" + POSTFIX;
 146      * static {
 147      *    // Define IR_NODE to regex-for-compile-phase mapping. Create a new IRNodeMapEntry object and add it to
 148      *    // IR_NODE_MAPPINGS. This can be done by using the helper methods defined after all IR node placeholder string
 149      *    // definitions.
 150      * }
 151      */
 152 






 153     public static final String ABS_D = PREFIX + "ABS_D" + POSTFIX;
 154     static {
 155         beforeMatchingNameRegex(ABS_D, "AbsD");
 156     }
 157 
 158     public static final String ABS_F = PREFIX + "ABS_F" + POSTFIX;
 159     static {
 160         beforeMatchingNameRegex(ABS_F, "AbsF");
 161     }
 162 
 163     public static final String ABS_I = PREFIX + "ABS_I" + POSTFIX;
 164     static {
 165         beforeMatchingNameRegex(ABS_I, "AbsI");
 166     }
 167 
 168     public static final String ABS_L = PREFIX + "ABS_L" + POSTFIX;
 169     static {
 170         beforeMatchingNameRegex(ABS_L, "AbsL");
 171     }
 172 

 364 
 365     public static final String REARRANGE_VD = VECTOR_PREFIX + "REARRANGE_VD" + POSTFIX;
 366     static {
 367         vectorNode(REARRANGE_VD, "VectorRearrange", TYPE_DOUBLE);
 368     }
 369 
 370     public static final String ADD_P_OF = COMPOSITE_PREFIX + "ADD_P_OF" + POSTFIX;
 371     static {
 372         String regex = START + "addP_" + IS_REPLACED + MID + ".*" + END;
 373         machOnly(ADD_P_OF, regex);
 374     }
 375 
 376     public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
 377     static {
 378         String regex = START + "Allocate\\b" + MID + END;
 379         macroNodes(ALLOC, regex);
 380     }
 381 
 382     public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
 383     static {
 384         String regex = START + "Allocate\\b" + MID + "allocationKlass:.*\\b" + IS_REPLACED + "\\s.*" + END;
 385         macroNodes(ALLOC_OF, regex);




 386     }
 387 
 388     public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
 389     static {
 390         String regex = START + "AllocateArray\\b" + MID + END;
 391         macroNodes(ALLOC_ARRAY,  regex);
 392     }
 393 
 394     public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
 395     static {




 396         // Assuming we are looking for an array of "some/package/MyClass". The printout is
 397         // [Lsome/package/MyClass;
 398         // or, with more dimensions
 399         // [[[Lsome/package/MyClass;
 400 
 401         // Case where the searched string is a not fully qualified name (but maybe partially qualified):
 402         // package/MyClass or MyClass
 403         // The ".*\\b" will eat the "some/" and "some/package/" resp.
 404         String partial_name_prefix = ".+\\b";
 405 
 406         // The thing after "allocationKlass:" (the name of the allocated class) is a sequence of:
 407         // - a non-empty sequence of "["
 408         // - a single character ("L"),
 409         // - maybe a non-empty sequence of characters ending on a word boundary
 410         //   this sequence is omitted if the given name is already fully qualified (exact match)
 411         //   but will eat the package path prefix in the cases described above
 412         // - the name we are looking for
 413         // - the final ";".
 414         String name_part = "\\[+.(" + partial_name_prefix + ")?" + IS_REPLACED + ";";
 415         String regex = START + "AllocateArray\\b" + MID + "allocationKlass:" + name_part + ".*" + END;
 416         macroNodes(ALLOC_ARRAY_OF, regex);
 417     }
 418 
 419     public static final String OR = PREFIX + "OR" + POSTFIX;
 420     static {
 421         beforeMatchingNameRegex(OR, "Or(I|L)");
 422     }
 423 
 424     public static final String AND = PREFIX + "AND" + POSTFIX;
 425     static {
 426         beforeMatchingNameRegex(AND, "And(I|L)");
 427     }
 428 
 429     public static final String AND_I = PREFIX + "AND_I" + POSTFIX;
 430     static {
 431         beforeMatchingNameRegex(AND_I, "AndI");
 432     }
 433 
 434     public static final String AND_L = PREFIX + "AND_L" + POSTFIX;
 435     static {
 436         beforeMatchingNameRegex(AND_L, "AndL");

 461         vectorNode(AND_VL, "AndV", TYPE_LONG);
 462     }
 463 
 464     public static final String AND_V_MASK = PREFIX + "AND_V_MASK" + POSTFIX;
 465     static {
 466         beforeMatchingNameRegex(AND_V_MASK, "AndVMask");
 467     }
 468 
 469     public static final String AND_REDUCTION_V = PREFIX + "AND_REDUCTION_V" + POSTFIX;
 470     static {
 471         superWordNodes(AND_REDUCTION_V, "AndReductionV");
 472     }
 473 
 474     public static final String CALL = PREFIX + "CALL" + POSTFIX;
 475     static {
 476         beforeMatchingNameRegex(CALL, "Call.*Java");
 477     }
 478 
 479     public static final String CALL_OF = COMPOSITE_PREFIX + "CALL_OF" + POSTFIX;
 480     static {
 481         callOfNodes(CALL_OF, "Call.*");
 482     }
 483 
 484     public static final String CALL_OF_METHOD = COMPOSITE_PREFIX + "CALL_OF_METHOD" + POSTFIX;
 485     static {
 486         callOfNodes(CALL_OF_METHOD, "Call.*Java");





 487     }
 488 
 489     public static final String STATIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "STATIC_CALL_OF_METHOD" + POSTFIX;
 490     static {
 491         callOfNodes(STATIC_CALL_OF_METHOD, "CallStaticJava");


















 492     }
 493 
 494     public static final String CAST_II = PREFIX + "CAST_II" + POSTFIX;
 495     static {
 496         beforeMatchingNameRegex(CAST_II, "CastII");
 497     }
 498 
 499     public static final String CAST_LL = PREFIX + "CAST_LL" + POSTFIX;
 500     static {
 501         beforeMatchingNameRegex(CAST_LL, "CastLL");
 502     }
 503 
 504     public static final String CBNZW_HI = PREFIX + "CBNZW_HI" + POSTFIX;
 505     static {
 506         optoOnly(CBNZW_HI, "cbwhi");
 507     }
 508 
 509     public static final String CBZW_LS = PREFIX + "CBZW_LS" + POSTFIX;
 510     static {
 511         optoOnly(CBZW_LS, "cbwls");

 742         beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
 743     }
 744 
 745     public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
 746     static {
 747         vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
 748     }
 749 
 750     public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
 751     static {
 752         vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
 753     }
 754 
 755     public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
 756     static {
 757         vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
 758     }
 759 
 760     public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
 761     static {
 762         callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava");
 763     }
 764 
 765     public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
 766     static {
 767         beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
 768     }
 769 
 770     public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
 771     static {
 772         beforeMatchingNameRegex(FAST_LOCK, "FastLock");
 773     }
 774 
 775     public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
 776     static {
 777         String regex = START + "FastUnlock" + MID + END;
 778         fromMacroToBeforeMatching(FAST_UNLOCK, regex);
 779     }
 780 
 781     public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
 782     static {

 878         String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 879         machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
 880     }
 881 
 882     public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
 883     static {
 884         machOnlyNameRegex(G1_STORE_P, "g1StoreP");
 885     }
 886 
 887     public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
 888     static {
 889         String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 890         machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
 891     }
 892 
 893     public static final String IF = PREFIX + "IF" + POSTFIX;
 894     static {
 895         beforeMatchingNameRegex(IF, "If\\b");
 896     }
 897 





 898     // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
 899     public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
 900     static {
 901         trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
 902     }
 903 
 904     public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
 905     static {
 906         trapNodes(INTRINSIC_TRAP, "intrinsic");
 907     }
 908 
 909     // Is only supported on riscv64.
 910     public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
 911     static {
 912         beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
 913     }
 914 
 915     // Is only supported on riscv64.
 916     public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
 917     static {

 924     }
 925 
 926     public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
 927     static {
 928         beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
 929     }
 930 
 931     // Only supported on x86.
 932     public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
 933     static {
 934         machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
 935     }
 936 
 937     public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
 938     static {
 939         beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
 940     }
 941 
 942     public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
 943     static {
 944         loadOfNodes(LOAD_OF_CLASS, "Load(B|UB|S|US|I|L|F|D|P|N)");




 945     }
 946 
 947     public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
 948     static {
 949         beforeMatchingNameRegex(LOAD_B, "LoadB");
 950     }
 951 
 952     public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
 953     static {
 954         loadOfNodes(LOAD_B_OF_CLASS, "LoadB");
 955     }
 956 
 957     public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
 958     static {
 959         beforeMatchingNameRegex(LOAD_D, "LoadD");
 960     }
 961 
 962     public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
 963     static {
 964         loadOfNodes(LOAD_D_OF_CLASS, "LoadD");
 965     }
 966 
 967     public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
 968     static {
 969         beforeMatchingNameRegex(LOAD_F, "LoadF");
 970     }
 971 
 972     public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
 973     static {
 974         loadOfNodes(LOAD_F_OF_CLASS, "LoadF");
 975     }
 976 
 977     public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
 978     static {
 979         beforeMatchingNameRegex(LOAD_I, "LoadI");
 980     }
 981 
 982     public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
 983     static {
 984         loadOfNodes(LOAD_I_OF_CLASS, "LoadI");
 985     }
 986 
 987     public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
 988     static {
 989         beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
 990     }
 991 
 992     public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
 993     static {
 994         beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
 995     }
 996 
 997     public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
 998     static {
 999         beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
1000     }
1001 
1002     public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
1003     static {
1004         beforeMatchingNameRegex(LOAD_L, "LoadL");
1005     }
1006 
1007     public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
1008     static {
1009         loadOfNodes(LOAD_L_OF_CLASS, "LoadL");
1010     }
1011 
1012     public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1013     static {
1014         beforeMatchingNameRegex(LOAD_N, "LoadN");
1015     }
1016 
1017     public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1018     static {
1019         loadOfNodes(LOAD_N_OF_CLASS, "LoadN");
1020     }
1021 
1022     public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1023     static {
1024         String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1025         beforeMatching(LOAD_OF_FIELD, regex);
1026     }
1027 
1028     public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1029     static {
1030         beforeMatchingNameRegex(LOAD_P, "LoadP");
1031     }
1032 
1033     public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1034     static {
1035         loadOfNodes(LOAD_P_OF_CLASS, "LoadP");
1036     }
1037 
1038     public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1039     static {
1040         beforeMatchingNameRegex(LOAD_S, "LoadS");
1041     }
1042 
1043     public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1044     static {
1045         loadOfNodes(LOAD_S_OF_CLASS, "LoadS");
1046     }
1047 
1048     public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1049     static {
1050         beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1051     }
1052 
1053     public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1054     static {
1055         loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB");
1056     }
1057 
1058     public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1059     static {
1060         beforeMatchingNameRegex(LOAD_US, "LoadUS");
1061     }
1062 
1063     public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1064     static {
1065         loadOfNodes(LOAD_US_OF_CLASS, "LoadUS");
1066     }
1067 
1068     public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1069     static {
1070         vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1071     }
1072 
1073     public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1074     static {
1075         vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1076     }
1077 
1078     public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1079     static {
1080         vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1081     }
1082 
1083     public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1084     static {
1085         vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);

2005         vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
2006     }
2007 
2008     public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
2009     static {
2010         vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
2011     }
2012 
2013     public static final String STORE = PREFIX + "STORE" + POSTFIX;
2014     static {
2015         beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
2016     }
2017 
2018     public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
2019     static {
2020         beforeMatchingNameRegex(STORE_B, "StoreB");
2021     }
2022 
2023     public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
2024     static {
2025         storeOfNodes(STORE_B_OF_CLASS, "StoreB");
2026     }
2027 
2028     public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
2029     static {
2030         beforeMatchingNameRegex(STORE_C, "StoreC");
2031     }
2032 
2033     public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
2034     static {
2035         storeOfNodes(STORE_C_OF_CLASS, "StoreC");
2036     }
2037 
2038     public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
2039     static {
2040         beforeMatchingNameRegex(STORE_D, "StoreD");
2041     }
2042 
2043     public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
2044     static {
2045         storeOfNodes(STORE_D_OF_CLASS, "StoreD");
2046     }
2047 
2048     public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2049     static {
2050         beforeMatchingNameRegex(STORE_F, "StoreF");
2051     }
2052 
2053     public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2054     static {
2055         storeOfNodes(STORE_F_OF_CLASS, "StoreF");
2056     }
2057 
2058     public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2059     static {
2060         beforeMatchingNameRegex(STORE_I, "StoreI");
2061     }
2062 
2063     public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2064     static {
2065         storeOfNodes(STORE_I_OF_CLASS, "StoreI");
2066     }
2067 
2068     public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2069     static {
2070         beforeMatchingNameRegex(STORE_L, "StoreL");
2071     }
2072 
2073     public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2074     static {
2075         storeOfNodes(STORE_L_OF_CLASS, "StoreL");
2076     }
2077 
2078     public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2079     static {
2080         beforeMatchingNameRegex(STORE_N, "StoreN");
2081     }
2082 
2083     public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2084     static {
2085         storeOfNodes(STORE_N_OF_CLASS, "StoreN");
2086     }
2087 
2088     public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2089     static {
2090         storeOfNodes(STORE_OF_CLASS, "Store(B|C|S|I|L|F|D|P|N)");




2091     }
2092 
2093     public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2094     static {
2095         String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2096         beforeMatching(STORE_OF_FIELD, regex);
2097     }
2098 
2099     public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2100     static {
2101         beforeMatchingNameRegex(STORE_P, "StoreP");
2102     }
2103 
2104     public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2105     static {
2106         storeOfNodes(STORE_P_OF_CLASS, "StoreP");
2107     }
2108 
2109     public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2110     static {
2111         beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2112     }
2113 
2114     public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2115     static {
2116         beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2117     }
2118 
2119     public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2120     static {
2121         beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2122     }
2123 
2124     public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2125     static {
2126         beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");

2186         vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2187     }
2188 
2189     public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2190     static {
2191         vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2192     }
2193 
2194     public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2195     static {
2196         vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2197     }
2198 
2199     public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2200     static {
2201         vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2202     }
2203 
2204     public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2205     static {
2206         beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");

2207     }
2208 
2209     public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2210     static {
2211         trapNodes(TRAP, "reason");
2212     }
2213 
2214     public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2215     static {
2216         beforeMatchingNameRegex(DIV_HF, "DivHF");
2217     }
2218 
2219     public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2220     static {
2221         beforeMatchingNameRegex(UDIV_I, "UDivI");
2222     }
2223 
2224     public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2225     static {
2226         beforeMatchingNameRegex(UDIV_L, "UDivL");

3148     }
3149 
3150     public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3151     static {
3152         machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3153     }
3154 
3155     public static final String OPAQUE_CONSTANT_BOOL = PREFIX + "OPAQUE_CONSTANT_BOOL" + POSTFIX;
3156     static {
3157         beforeMatchingNameRegex(OPAQUE_CONSTANT_BOOL, "OpaqueConstantBool");
3158     }
3159 
3160     /*
3161      * Utility methods to set up IR_NODE_MAPPINGS.
3162      */
3163 
3164     /**
3165      * Apply {@code regex} on all machine independent ideal graph phases up to and including
3166      * {@link CompilePhase#BEFORE_MATCHING}.
3167      */
3168     private static void beforeMatching(String irNodePlaceholder, String regex) {
3169         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3170     }
3171 
3172     /**
3173      * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3174      * including {@link CompilePhase#BEFORE_MATCHING}.
3175      */
3176     private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3177         String regex = START + irNodeRegex + MID + END;
3178         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3179     }
3180 
3181     /**
3182      * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3183      * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3184      * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3185      */
3186     private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3187         TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3188                                                                + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3189         // IS_REPLACED is later replaced with the specific type and size of the vector.
3190         String regex = START + irNodeRegex + MID  + IS_REPLACED + END;
3191         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3192         VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3193     }
3194 
3195     /**
3196      * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3197      */
3198     private static void macroNodes(String irNodePlaceholder, String regex) {
3199         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3200                                                                           CompilePhase.BEFORE_STRINGOPTS,
3201                                                                           CompilePhase.BEFORE_MACRO_EXPANSION));
3202     }
3203 
3204     private static void callOfNodes(String irNodePlaceholder, String callRegex) {
3205         String regex = START + callRegex + MID + IS_REPLACED + " " +  END;
3206         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3207     }
3208 
3209     /**
3210      * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3211      * {@link CompilePhase#MATCHING}.
3212      */
3213     private static void optoOnly(String irNodePlaceholder, String regex) {
3214         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3215     }
3216 
3217     private static void machOnly(String irNodePlaceholder, String regex) {
3218         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3219     }
3220 
3221     private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3222         String regex = START + irNodeRegex + MID + END;
3223         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3224     }
3225 
3226     /**
3227      * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3228      */
3229     private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3230         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3231                                                                           CompilePhase.AFTER_CLOOPS,
3232                                                                           CompilePhase.FINAL_CODE));
3233     }

3287     // @ptrtype:fully/qualified/package/name/to/TheClass:ptrlattice+12
3288     // with ptrtype being the kind of the type such as instptr, aryptr, etc, and ptrlattice being
3289     // the kind of the value such as BotPTR, NotNull, etc.
3290     // And variation:
3291     // - after ptrtype, we can have "stable:" or other labels, with optional space after ':'
3292     // - the class can actually be a nested class, with $ separator (and it must be ok to give only the deepest one
3293     // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3294     // Worst case, it can be something like:
3295     // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24
3296 
3297     // @ matches the start character of the pattern
3298     // (\w+: ?)+ tries to match the pattern 'ptrtype:' or 'stable:' with optional trailing whitespaces
3299     // [\\w/\\$] tries to match the pattern such as 'a/b/', 'a/b', or '/b' but also nested class such as '$c' or '$c$d'
3300     // \b asserts that the next character is a word character
3301     private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)+[\\w/\\$]*\\b";
3302     // ( \([^\)]+\))? tries to match the pattern ' (f/g,h/i/j)'
3303     // :\w+ tries to match the pattern ':NotNull'
3304     // .* tries to match the remaining of the pattern
3305     private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?:\\w+.*";
3306 
3307     private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex) {
3308         String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + IS_REPLACED + LOAD_STORE_SUFFIX + END;
3309         beforeMatching(irNodePlaceholder, regex);
3310     }
3311 
3312     private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex) {
3313         String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + IS_REPLACED + LOAD_STORE_SUFFIX + END;
3314         beforeMatching(irNodePlaceholder, regex);
3315     }
3316 
3317     private static void safepointScalarobjectOfNodes(String irNodePlaceholder, String irNodeRegex) {
3318         String regex = START + irNodeRegex + MID + ".*" + IS_REPLACED + ".*" + END;
3319         beforeMatching(irNodePlaceholder, regex);
3320     }
3321 
3322     private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3323         String regex = START + irNodeRegex + MID + END;
3324         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3325                 CompilePhase.BEFORE_REMOVEUSELESS,
3326                 CompilePhase.FINAL_CODE));
3327     }
3328 
3329     /**
3330      * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3331      * first phase that could contain vector nodes from super word.
3332      */
3333     private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {

  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package compiler.lib.ir_framework;
  25 
  26 import compiler.lib.ir_framework.driver.irmatching.mapping.*;
  27 import compiler.lib.ir_framework.driver.irmatching.parser.VMInfo;
  28 import compiler.lib.ir_framework.shared.CheckedTestFrameworkException;
  29 import compiler.lib.ir_framework.shared.TestFormat;
  30 import compiler.lib.ir_framework.shared.TestFormatException;
  31 import compiler.valhalla.inlinetypes.InlineTypeIRNode;
  32 import jdk.test.lib.Platform;
  33 import jdk.test.whitebox.WhiteBox;
  34 
  35 import java.util.HashMap;
  36 import java.util.Map;
  37 
  38 /**
  39  * This class specifies IR node placeholder strings (also referred to as just "IR nodes") with mappings to regexes
  40  * depending on the selected compile phases. The mappings are stored in {@link #IR_NODE_MAPPINGS}. Each IR node
  41  * placeholder string is mapped to a {@link IRNodeMapEntry} instance defined in
  42  * {@link compiler.lib.ir_framework.driver.irmatching.mapping}.
  43  *
  44  * <p>
  45  * IR node placeholder strings can be used in {@link IR#failOn()} and/or {@link IR#counts()} attributes to define IR
  46  * constraints. They usually represent a single C2 IR node or a group of them.
  47  *
  48  * <p>
  49  * Each IR node placeholder string is accompanied by a static block that defines an IR node placeholder to regex(es)
  50  * mapping. The IR framework will automatically replace each IR node placeholder string in a user defined test with a
  51  * regex depending on the selected compile phases in {@link IR#phase} and the provided mapping.

  71  *                                 Using this IR node expects another user provided string in the constraint list of
  72  *                                 {@link IR#failOn()} and {@link IR#counts()}. They cannot be used as normal IR nodes.
  73  *                                 Trying to do so will result in a format violation error.</li>
  74  *     <li><p>Vector IR nodes:  The IR node placeholder string contains an additional {@link #VECTOR_PREFIX}.
  75  *                              Using this IR node, one can check for the type and size of a vector. The type must
  76  *                              be directly specified in {@link #vectorNode}. The size can be specified directly with
  77  *                              an additional argument using {@link #VECTOR_SIZE}, followed by a size tag or a comma
  78  *                              separated list of sizes. If the size argument is not given, then a default size of
  79  *                              {@link #VECTOR_SIZE_MAX} is taken, which is the number of elements that can fit in a
  80  *                              vector of the specified type (depends on the VM flag MaxVectorSize and CPU features).
  81  *                              However, when using {@link IR#failOn} or {@link IR#counts()} with comparison {@code <},
  82  *                              or {@code <=} or {@code =0}, the default size is {@link #VECTOR_SIZE_ANY}, allowing any
  83  *                              size. The motivation for these default values is that in most cases one wants to have
  84  *                              vectorization with maximal vector width, or no vectorization of any vector width.
  85  * </ul>
  86  */
  87 public class IRNode {
  88     /**
  89      * Prefix for normal IR nodes.
  90      */
  91     public static final String PREFIX = "_#";
  92     /**
  93      * Prefix for composite IR nodes.
  94      */
  95     private static final String COMPOSITE_PREFIX = PREFIX + "C#";
  96     /**
  97      * Prefix for vector IR nodes.
  98      */
  99     private static final String VECTOR_PREFIX = PREFIX + "V#";
 100 
 101     private static final String POSTFIX = "#_";
 102 
 103     public static final String START = "(\\d+(\\s){2}(";
 104     public static final String MID = ".*)+(\\s){2}===.*";
 105     public static final String END = ")";
 106 
 107     public static final String IS_REPLACED = "#IS_REPLACED#"; // Is replaced by an additional user-defined string.
 108 
 109     public static final String VECTOR_SIZE = "_@";
 110     public static final String VECTOR_SIZE_TAG_ANY = "any";
 111     public static final String VECTOR_SIZE_TAG_MAX = "max_for_type";

 134     /**
 135      * Map every vectorNode to a type string.
 136      */
 137     private static final Map<String, String> VECTOR_NODE_TYPE = new HashMap<>();
 138 
 139     /*
 140      * Start of IR placeholder string definitions followed by a static block defining the regex-for-compile-phase mapping.
 141      * An IR node placeholder string must start with PREFIX for normal IR nodes or COMPOSITE_PREFIX for composite IR
 142      * nodes, or VECTOR_PREFIX for vector nodes (see class description above).
 143      *
 144      * An IR node definition looks like this:
 145      *
 146      * public static final String IR_NODE = [PREFIX|COMPOSITE_PREFIX|VECTOR_PREFIX] + "IR_NODE" + POSTFIX;
 147      * static {
 148      *    // Define IR_NODE to regex-for-compile-phase mapping. Create a new IRNodeMapEntry object and add it to
 149      *    // IR_NODE_MAPPINGS. This can be done by using the helper methods defined after all IR node placeholder string
 150      *    // definitions.
 151      * }
 152      */
 153 
 154     // Valhalla: Make sure that all Valhalla specific IR nodes are also properly initialized. Doing it here also
 155     //           ensures that the Flag VM is able to pick up the correct compile phases.
 156     static {
 157         InlineTypeIRNode.forceStaticInitialization();
 158     }
 159 
 160     public static final String ABS_D = PREFIX + "ABS_D" + POSTFIX;
 161     static {
 162         beforeMatchingNameRegex(ABS_D, "AbsD");
 163     }
 164 
 165     public static final String ABS_F = PREFIX + "ABS_F" + POSTFIX;
 166     static {
 167         beforeMatchingNameRegex(ABS_F, "AbsF");
 168     }
 169 
 170     public static final String ABS_I = PREFIX + "ABS_I" + POSTFIX;
 171     static {
 172         beforeMatchingNameRegex(ABS_I, "AbsI");
 173     }
 174 
 175     public static final String ABS_L = PREFIX + "ABS_L" + POSTFIX;
 176     static {
 177         beforeMatchingNameRegex(ABS_L, "AbsL");
 178     }
 179 

 371 
 372     public static final String REARRANGE_VD = VECTOR_PREFIX + "REARRANGE_VD" + POSTFIX;
 373     static {
 374         vectorNode(REARRANGE_VD, "VectorRearrange", TYPE_DOUBLE);
 375     }
 376 
 377     public static final String ADD_P_OF = COMPOSITE_PREFIX + "ADD_P_OF" + POSTFIX;
 378     static {
 379         String regex = START + "addP_" + IS_REPLACED + MID + ".*" + END;
 380         machOnly(ADD_P_OF, regex);
 381     }
 382 
 383     public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
 384     static {
 385         String regex = START + "Allocate\\b" + MID + END;
 386         macroNodes(ALLOC, regex);
 387     }
 388 
 389     public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
 390     static {
 391         allocateOfNodes(ALLOC_OF, IS_REPLACED);
 392     }
 393 
 394     public static void allocateOfNodes(String irNodePlaceholder, String allocatee) {
 395         String regex = START + "Allocate\\b" + MID + "allocationKlass:.*\\b" + allocatee + "\\s.*" + END;
 396         macroNodes(irNodePlaceholder, regex);
 397     }
 398 
 399     public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
 400     static {
 401         String regex = START + "AllocateArray\\b" + MID + END;
 402         macroNodes(ALLOC_ARRAY,  regex);
 403     }
 404 
 405     public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
 406     static {
 407         allocateArrayOfNodes(ALLOC_ARRAY_OF, IS_REPLACED);
 408     }
 409 
 410     public static void allocateArrayOfNodes(String irNodePlaceholder, String allocatee) {
 411         // Assuming we are looking for an array of "some/package/MyClass". The printout is
 412         // [Lsome/package/MyClass;
 413         // or, with more dimensions
 414         // [[[Lsome/package/MyClass;
 415 
 416         // Case where the searched string is a not fully qualified name (but maybe partially qualified):
 417         // package/MyClass or MyClass
 418         // The ".*\\b" will eat the "some/" and "some/package/" resp.
 419         String partial_name_prefix = ".+\\b";
 420 
 421         // The thing after "allocationKlass:" (the name of the allocated class) is a sequence of:
 422         // - a non-empty sequence of "["
 423         // - a single character ("L"),
 424         // - maybe a non-empty sequence of characters ending on a word boundary
 425         //   this sequence is omitted if the given name is already fully qualified (exact match)
 426         //   but will eat the package path prefix in the cases described above
 427         // - the name we are looking for
 428         // - the final ";".
 429         String name_part = "\\[+.(" + partial_name_prefix + ")?" + allocatee + ";";
 430         String regex = START + "AllocateArray\\b" + MID + "allocationKlass:" + name_part + ".*" + END;
 431         macroNodes(irNodePlaceholder, regex);
 432     }
 433 
 434     public static final String OR = PREFIX + "OR" + POSTFIX;
 435     static {
 436         beforeMatchingNameRegex(OR, "Or(I|L)");
 437     }
 438 
 439     public static final String AND = PREFIX + "AND" + POSTFIX;
 440     static {
 441         beforeMatchingNameRegex(AND, "And(I|L)");
 442     }
 443 
 444     public static final String AND_I = PREFIX + "AND_I" + POSTFIX;
 445     static {
 446         beforeMatchingNameRegex(AND_I, "AndI");
 447     }
 448 
 449     public static final String AND_L = PREFIX + "AND_L" + POSTFIX;
 450     static {
 451         beforeMatchingNameRegex(AND_L, "AndL");

 476         vectorNode(AND_VL, "AndV", TYPE_LONG);
 477     }
 478 
 479     public static final String AND_V_MASK = PREFIX + "AND_V_MASK" + POSTFIX;
 480     static {
 481         beforeMatchingNameRegex(AND_V_MASK, "AndVMask");
 482     }
 483 
 484     public static final String AND_REDUCTION_V = PREFIX + "AND_REDUCTION_V" + POSTFIX;
 485     static {
 486         superWordNodes(AND_REDUCTION_V, "AndReductionV");
 487     }
 488 
 489     public static final String CALL = PREFIX + "CALL" + POSTFIX;
 490     static {
 491         beforeMatchingNameRegex(CALL, "Call.*Java");
 492     }
 493 
 494     public static final String CALL_OF = COMPOSITE_PREFIX + "CALL_OF" + POSTFIX;
 495     static {
 496         callOfNodes(CALL_OF, "Call.*", IS_REPLACED + " " );
 497     }
 498 
 499     public static final String CALL_OF_METHOD = COMPOSITE_PREFIX + "CALL_OF_METHOD" + POSTFIX;
 500     static {
 501         callOfNodes(CALL_OF_METHOD, "Call.*Java", IS_REPLACED + " ");
 502     }
 503 
 504     public static final String STATIC_CALL = PREFIX + "STATIC_CALL" + POSTFIX;
 505     static {
 506         beforeMatchingNameRegex(STATIC_CALL, "CallStaticJava");
 507     }
 508 
 509     public static final String STATIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "STATIC_CALL_OF_METHOD" + POSTFIX;
 510     static {
 511         staticCallOfMethodNodes(STATIC_CALL_OF_METHOD, IS_REPLACED + " ");
 512     }
 513 
 514     public static void staticCallOfMethodNodes(String irNodePlaceholder, String calleeRegex) {
 515         callOfNodes(irNodePlaceholder, "CallStaticJava", calleeRegex);
 516     }
 517 
 518     public static final String CALL_LEAF_NO_FP = PREFIX + "CALL_LEAF_NO_FP" + POSTFIX;
 519     static {
 520         beforeMatchingNameRegex(CALL_LEAF_NO_FP, "CallLeafNoFP");
 521     }
 522 
 523     public static final String CALL_LEAF_NO_FP_OF_METHOD = COMPOSITE_PREFIX + "CALL_LEAF_NO_FP_OF_METHOD" + POSTFIX;
 524     static {
 525         callLeafNoFpOfMethodNodes(CALL_LEAF_NO_FP_OF_METHOD, IS_REPLACED);
 526     }
 527 
 528     public static void callLeafNoFpOfMethodNodes(String irNodePlaceholder, String calleeRegex) {
 529         callOfNodes(irNodePlaceholder, "CallLeafNoFP", calleeRegex);
 530     }
 531 
 532     public static final String CAST_II = PREFIX + "CAST_II" + POSTFIX;
 533     static {
 534         beforeMatchingNameRegex(CAST_II, "CastII");
 535     }
 536 
 537     public static final String CAST_LL = PREFIX + "CAST_LL" + POSTFIX;
 538     static {
 539         beforeMatchingNameRegex(CAST_LL, "CastLL");
 540     }
 541 
 542     public static final String CBNZW_HI = PREFIX + "CBNZW_HI" + POSTFIX;
 543     static {
 544         optoOnly(CBNZW_HI, "cbwhi");
 545     }
 546 
 547     public static final String CBZW_LS = PREFIX + "CBZW_LS" + POSTFIX;
 548     static {
 549         optoOnly(CBZW_LS, "cbwls");

 780         beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
 781     }
 782 
 783     public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
 784     static {
 785         vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
 786     }
 787 
 788     public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
 789     static {
 790         vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
 791     }
 792 
 793     public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
 794     static {
 795         vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
 796     }
 797 
 798     public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
 799     static {
 800         callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava", IS_REPLACED);
 801     }
 802 
 803     public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
 804     static {
 805         beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
 806     }
 807 
 808     public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
 809     static {
 810         beforeMatchingNameRegex(FAST_LOCK, "FastLock");
 811     }
 812 
 813     public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
 814     static {
 815         String regex = START + "FastUnlock" + MID + END;
 816         fromMacroToBeforeMatching(FAST_UNLOCK, regex);
 817     }
 818 
 819     public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
 820     static {

 916         String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 917         machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
 918     }
 919 
 920     public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
 921     static {
 922         machOnlyNameRegex(G1_STORE_P, "g1StoreP");
 923     }
 924 
 925     public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
 926     static {
 927         String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 928         machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
 929     }
 930 
 931     public static final String IF = PREFIX + "IF" + POSTFIX;
 932     static {
 933         beforeMatchingNameRegex(IF, "If\\b");
 934     }
 935 
 936     public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;
 937     static {
 938         beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
 939     }
 940 
 941     // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
 942     public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
 943     static {
 944         trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
 945     }
 946 
 947     public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
 948     static {
 949         trapNodes(INTRINSIC_TRAP, "intrinsic");
 950     }
 951 
 952     // Is only supported on riscv64.
 953     public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
 954     static {
 955         beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
 956     }
 957 
 958     // Is only supported on riscv64.
 959     public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
 960     static {

 967     }
 968 
 969     public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
 970     static {
 971         beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
 972     }
 973 
 974     // Only supported on x86.
 975     public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
 976     static {
 977         machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
 978     }
 979 
 980     public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
 981     static {
 982         beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
 983     }
 984 
 985     public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
 986     static {
 987         anyLoadOfNodes(LOAD_OF_CLASS, IS_REPLACED);
 988     }
 989 
 990     public static void anyLoadOfNodes(String irNodePlaceholder, String fieldHolder) {
 991         loadOfNodes(irNodePlaceholder, "Load(B|UB|S|US|I|L|F|D|P|N)", fieldHolder);
 992     }
 993 
 994     public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
 995     static {
 996         beforeMatchingNameRegex(LOAD_B, "LoadB");
 997     }
 998 
 999     public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
1000     static {
1001         loadOfNodes(LOAD_B_OF_CLASS, "LoadB", IS_REPLACED);
1002     }
1003 
1004     public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
1005     static {
1006         beforeMatchingNameRegex(LOAD_D, "LoadD");
1007     }
1008 
1009     public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
1010     static {
1011         loadOfNodes(LOAD_D_OF_CLASS, "LoadD", IS_REPLACED);
1012     }
1013 
1014     public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
1015     static {
1016         beforeMatchingNameRegex(LOAD_F, "LoadF");
1017     }
1018 
1019     public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
1020     static {
1021         loadOfNodes(LOAD_F_OF_CLASS, "LoadF", IS_REPLACED);
1022     }
1023 
1024     public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
1025     static {
1026         beforeMatchingNameRegex(LOAD_I, "LoadI");
1027     }
1028 
1029     public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
1030     static {
1031         loadOfNodes(LOAD_I_OF_CLASS, "LoadI", IS_REPLACED);
1032     }
1033 
1034     public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
1035     static {
1036         beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
1037     }
1038 
1039     public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
1040     static {
1041         beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
1042     }
1043 
1044     public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
1045     static {
1046         beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
1047     }
1048 
1049     public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
1050     static {
1051         beforeMatchingNameRegex(LOAD_L, "LoadL");
1052     }
1053 
1054     public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
1055     static {
1056         loadOfNodes(LOAD_L_OF_CLASS, "LoadL", IS_REPLACED);
1057     }
1058 
1059     public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1060     static {
1061         beforeMatchingNameRegex(LOAD_N, "LoadN");
1062     }
1063 
1064     public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1065     static {
1066         loadOfNodes(LOAD_N_OF_CLASS, "LoadN", IS_REPLACED);
1067     }
1068 
1069     public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1070     static {
1071         String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1072         beforeMatching(LOAD_OF_FIELD, regex);
1073     }
1074 
1075     public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1076     static {
1077         beforeMatchingNameRegex(LOAD_P, "LoadP");
1078     }
1079 
1080     public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1081     static {
1082         loadOfNodes(LOAD_P_OF_CLASS, "LoadP", IS_REPLACED);
1083     }
1084 
1085     public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1086     static {
1087         beforeMatchingNameRegex(LOAD_S, "LoadS");
1088     }
1089 
1090     public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1091     static {
1092         loadOfNodes(LOAD_S_OF_CLASS, "LoadS", IS_REPLACED);
1093     }
1094 
1095     public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1096     static {
1097         beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1098     }
1099 
1100     public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1101     static {
1102         loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB", IS_REPLACED);
1103     }
1104 
1105     public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1106     static {
1107         beforeMatchingNameRegex(LOAD_US, "LoadUS");
1108     }
1109 
1110     public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1111     static {
1112         loadOfNodes(LOAD_US_OF_CLASS, "LoadUS", IS_REPLACED);
1113     }
1114 
1115     public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1116     static {
1117         vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1118     }
1119 
1120     public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1121     static {
1122         vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1123     }
1124 
1125     public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1126     static {
1127         vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1128     }
1129 
1130     public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1131     static {
1132         vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);

2052         vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
2053     }
2054 
2055     public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
2056     static {
2057         vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
2058     }
2059 
2060     public static final String STORE = PREFIX + "STORE" + POSTFIX;
2061     static {
2062         beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
2063     }
2064 
2065     public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
2066     static {
2067         beforeMatchingNameRegex(STORE_B, "StoreB");
2068     }
2069 
2070     public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
2071     static {
2072         storeOfNodes(STORE_B_OF_CLASS, "StoreB", IS_REPLACED);
2073     }
2074 
2075     public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
2076     static {
2077         beforeMatchingNameRegex(STORE_C, "StoreC");
2078     }
2079 
2080     public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
2081     static {
2082         storeOfNodes(STORE_C_OF_CLASS, "StoreC", IS_REPLACED);
2083     }
2084 
2085     public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
2086     static {
2087         beforeMatchingNameRegex(STORE_D, "StoreD");
2088     }
2089 
2090     public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
2091     static {
2092         storeOfNodes(STORE_D_OF_CLASS, "StoreD", IS_REPLACED);
2093     }
2094 
2095     public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2096     static {
2097         beforeMatchingNameRegex(STORE_F, "StoreF");
2098     }
2099 
2100     public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2101     static {
2102         storeOfNodes(STORE_F_OF_CLASS, "StoreF", IS_REPLACED);
2103     }
2104 
2105     public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2106     static {
2107         beforeMatchingNameRegex(STORE_I, "StoreI");
2108     }
2109 
2110     public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2111     static {
2112         storeOfNodes(STORE_I_OF_CLASS, "StoreI", IS_REPLACED);
2113     }
2114 
2115     public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2116     static {
2117         beforeMatchingNameRegex(STORE_L, "StoreL");
2118     }
2119 
2120     public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2121     static {
2122         storeOfNodes(STORE_L_OF_CLASS, "StoreL", IS_REPLACED);
2123     }
2124 
2125     public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2126     static {
2127         beforeMatchingNameRegex(STORE_N, "StoreN");
2128     }
2129 
2130     public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2131     static {
2132         storeOfNodes(STORE_N_OF_CLASS, "StoreN", IS_REPLACED);
2133     }
2134 
2135     public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2136     static {
2137         anyStoreOfNodes(STORE_OF_CLASS, IS_REPLACED);
2138     }
2139 
2140     public static void anyStoreOfNodes(String irNodePlaceholder, String fieldHolder) {
2141         storeOfNodes(irNodePlaceholder, "Store(B|C|S|I|L|F|D|P|N)", fieldHolder);
2142     }
2143 
2144     public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2145     static {
2146         String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2147         beforeMatching(STORE_OF_FIELD, regex);
2148     }
2149 
2150     public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2151     static {
2152         beforeMatchingNameRegex(STORE_P, "StoreP");
2153     }
2154 
2155     public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2156     static {
2157         storeOfNodes(STORE_P_OF_CLASS, "StoreP", IS_REPLACED);
2158     }
2159 
2160     public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2161     static {
2162         beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2163     }
2164 
2165     public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2166     static {
2167         beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2168     }
2169 
2170     public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2171     static {
2172         beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2173     }
2174 
2175     public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2176     static {
2177         beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");

2237         vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2238     }
2239 
2240     public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2241     static {
2242         vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2243     }
2244 
2245     public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2246     static {
2247         vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2248     }
2249 
2250     public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2251     static {
2252         vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2253     }
2254 
2255     public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2256     static {
2257         String regex = START + "SubTypeCheck" + MID + END;
2258         macroNodes(SUBTYPE_CHECK, regex);
2259     }
2260 
2261     public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2262     static {
2263         trapNodes(TRAP, "reason");
2264     }
2265 
2266     public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2267     static {
2268         beforeMatchingNameRegex(DIV_HF, "DivHF");
2269     }
2270 
2271     public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2272     static {
2273         beforeMatchingNameRegex(UDIV_I, "UDivI");
2274     }
2275 
2276     public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2277     static {
2278         beforeMatchingNameRegex(UDIV_L, "UDivL");

3200     }
3201 
3202     public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3203     static {
3204         machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3205     }
3206 
3207     public static final String OPAQUE_CONSTANT_BOOL = PREFIX + "OPAQUE_CONSTANT_BOOL" + POSTFIX;
3208     static {
3209         beforeMatchingNameRegex(OPAQUE_CONSTANT_BOOL, "OpaqueConstantBool");
3210     }
3211 
3212     /*
3213      * Utility methods to set up IR_NODE_MAPPINGS.
3214      */
3215 
3216     /**
3217      * Apply {@code regex} on all machine independent ideal graph phases up to and including
3218      * {@link CompilePhase#BEFORE_MATCHING}.
3219      */
3220     public static void beforeMatching(String irNodePlaceholder, String regex) {
3221         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3222     }
3223 
3224     /**
3225      * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3226      * including {@link CompilePhase#BEFORE_MATCHING}.
3227      */
3228     private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3229         String regex = START + irNodeRegex + MID + END;
3230         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3231     }
3232 
3233     /**
3234      * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3235      * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3236      * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3237      */
3238     private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3239         TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3240                                                                + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3241         // IS_REPLACED is later replaced with the specific type and size of the vector.
3242         String regex = START + irNodeRegex + MID  + IS_REPLACED + END;
3243         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3244         VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3245     }
3246 
3247     /**
3248      * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3249      */
3250     private static void macroNodes(String irNodePlaceholder, String regex) {
3251         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3252                                                                           CompilePhase.BEFORE_STRINGOPTS,
3253                                                                           CompilePhase.BEFORE_MACRO_EXPANSION));
3254     }
3255 
3256     private static void callOfNodes(String irNodePlaceholder, String callRegex, String calleeRegex) {
3257         String regex = START + callRegex + MID + calleeRegex + END;
3258         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3259     }
3260 
3261     /**
3262      * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3263      * {@link CompilePhase#MATCHING}.
3264      */
3265     public static void optoOnly(String irNodePlaceholder, String regex) {
3266         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3267     }
3268 
3269     private static void machOnly(String irNodePlaceholder, String regex) {
3270         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3271     }
3272 
3273     private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3274         String regex = START + irNodeRegex + MID + END;
3275         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3276     }
3277 
3278     /**
3279      * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3280      */
3281     private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3282         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3283                                                                           CompilePhase.AFTER_CLOOPS,
3284                                                                           CompilePhase.FINAL_CODE));
3285     }

3339     // @ptrtype:fully/qualified/package/name/to/TheClass:ptrlattice+12
3340     // with ptrtype being the kind of the type such as instptr, aryptr, etc, and ptrlattice being
3341     // the kind of the value such as BotPTR, NotNull, etc.
3342     // And variation:
3343     // - after ptrtype, we can have "stable:" or other labels, with optional space after ':'
3344     // - the class can actually be a nested class, with $ separator (and it must be ok to give only the deepest one
3345     // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3346     // Worst case, it can be something like:
3347     // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24
3348 
3349     // @ matches the start character of the pattern
3350     // (\w+: ?)+ tries to match the pattern 'ptrtype:' or 'stable:' with optional trailing whitespaces
3351     // [\\w/\\$] tries to match the pattern such as 'a/b/', 'a/b', or '/b' but also nested class such as '$c' or '$c$d'
3352     // \b asserts that the next character is a word character
3353     private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)+[\\w/\\$]*\\b";
3354     // ( \([^\)]+\))? tries to match the pattern ' (f/g,h/i/j)'
3355     // :\w+ tries to match the pattern ':NotNull'
3356     // .* tries to match the remaining of the pattern
3357     private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?:\\w+.*";
3358 
3359     private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex, String loadee) {
3360         String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + loadee + LOAD_STORE_SUFFIX + END;
3361         beforeMatching(irNodePlaceholder, regex);
3362     }
3363 
3364     private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex, String storee) {
3365         String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + storee + LOAD_STORE_SUFFIX + END;
3366         beforeMatching(irNodePlaceholder, regex);
3367     }
3368 
3369     private static void safepointScalarobjectOfNodes(String irNodePlaceholder, String irNodeRegex) {
3370         String regex = START + irNodeRegex + MID + ".*" + IS_REPLACED + ".*" + END;
3371         beforeMatching(irNodePlaceholder, regex);
3372     }
3373 
3374     private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3375         String regex = START + irNodeRegex + MID + END;
3376         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3377                 CompilePhase.BEFORE_REMOVEUSELESS,
3378                 CompilePhase.FINAL_CODE));
3379     }
3380 
3381     /**
3382      * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3383      * first phase that could contain vector nodes from super word.
3384      */
3385     private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
< prev index next >