< 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.network.testvm.java.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";

 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     public static final String ABS_D = PREFIX + "ABS_D" + POSTFIX;
 155     static {
 156         beforeMatchingNameRegex(ABS_D, "AbsD");
 157     }
 158 
 159     public static final String ABS_F = PREFIX + "ABS_F" + POSTFIX;
 160     static {
 161         beforeMatchingNameRegex(ABS_F, "AbsF");
 162     }
 163 
 164     public static final String ABS_I = PREFIX + "ABS_I" + POSTFIX;
 165     static {
 166         beforeMatchingNameRegex(ABS_I, "AbsI");
 167     }
 168 
 169     public static final String ABS_L = PREFIX + "ABS_L" + POSTFIX;
 170     static {
 171         beforeMatchingNameRegex(ABS_L, "AbsL");
 172     }
 173 

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




 392     }
 393 
 394     public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
 395     static {
 396         String regex = START + "AllocateArray\\b" + MID + END;
 397         macroNodes(ALLOC_ARRAY,  regex);
 398     }
 399 
 400     public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
 401     static {




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

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





 493     }
 494 
 495     public static final String STATIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "STATIC_CALL_OF_METHOD" + POSTFIX;
 496     static {
 497         callOfNodes(STATIC_CALL_OF_METHOD, "CallStaticJava");


















 498     }
 499 
 500     public static final String CAST_II = PREFIX + "CAST_II" + POSTFIX;
 501     static {
 502         beforeMatchingNameRegex(CAST_II, "CastII");
 503     }
 504 
 505     public static final String CAST_LL = PREFIX + "CAST_LL" + POSTFIX;
 506     static {
 507         beforeMatchingNameRegex(CAST_LL, "CastLL");
 508     }
 509 
 510     public static final String CBNZW_HI = PREFIX + "CBNZW_HI" + POSTFIX;
 511     static {
 512         optoOnly(CBNZW_HI, "cbwhi");
 513     }
 514 
 515     public static final String CBZW_LS = PREFIX + "CBZW_LS" + POSTFIX;
 516     static {
 517         optoOnly(CBZW_LS, "cbwls");

 604     public static final String CMP_UL = PREFIX + "CMP_UL" + POSTFIX;
 605     static {
 606         beforeMatchingNameRegex(CMP_UL, "CmpUL");
 607     }
 608 
 609     public static final String CMP_UL3 = PREFIX + "CMP_UL3" + POSTFIX;
 610     static {
 611         beforeMatchingNameRegex(CMP_UL3, "CmpUL3");
 612     }
 613 
 614     public static final String CMP_P = PREFIX + "CMP_P" + POSTFIX;
 615     static {
 616         beforeMatchingNameRegex(CMP_P, "CmpP");
 617     }
 618 
 619     public static final String CMP_N = PREFIX + "CMP_N" + POSTFIX;
 620     static {
 621         beforeMatchingNameRegex(CMP_N, "CmpN");
 622     }
 623 





 624     public static final String CMP_LT_MASK = PREFIX + "CMP_LT_MASK" + POSTFIX;
 625     static {
 626         beforeMatchingNameRegex(CMP_LT_MASK, "CmpLTMask");
 627     }
 628 
 629     public static final String ROUND_F = PREFIX + "ROUND_F" + POSTFIX;
 630     static {
 631         beforeMatchingNameRegex(ROUND_F, "RoundF");
 632     }
 633 
 634     public static final String ROUND_D = PREFIX + "ROUND_D" + POSTFIX;
 635     static {
 636         beforeMatchingNameRegex(ROUND_D, "RoundD");
 637     }
 638 
 639     public static final String COMPRESS_BITS = PREFIX + "COMPRESS_BITS" + POSTFIX;
 640     static {
 641         beforeMatchingNameRegex(COMPRESS_BITS, "CompressBits");
 642     }
 643 

 758         beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
 759     }
 760 
 761     public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
 762     static {
 763         vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
 764     }
 765 
 766     public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
 767     static {
 768         vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
 769     }
 770 
 771     public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
 772     static {
 773         vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
 774     }
 775 
 776     public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
 777     static {
 778         callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava");
 779     }
 780 
 781     public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
 782     static {
 783         beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
 784     }
 785 
 786     public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
 787     static {
 788         beforeMatchingNameRegex(FAST_LOCK, "FastLock");
 789     }
 790 
 791     public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
 792     static {
 793         String regex = START + "FastUnlock" + MID + END;
 794         fromMacroToBeforeMatching(FAST_UNLOCK, regex);
 795     }
 796 
 797     public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
 798     static {

 894         String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 895         machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
 896     }
 897 
 898     public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
 899     static {
 900         machOnlyNameRegex(G1_STORE_P, "g1StoreP");
 901     }
 902 
 903     public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
 904     static {
 905         String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 906         machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
 907     }
 908 
 909     public static final String IF = PREFIX + "IF" + POSTFIX;
 910     static {
 911         beforeMatchingNameRegex(IF, "If\\b");
 912     }
 913 





 914     // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
 915     public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
 916     static {
 917         trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
 918     }
 919 
 920     public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
 921     static {
 922         trapNodes(INTRINSIC_TRAP, "intrinsic");
 923     }
 924 
 925     // Is only supported on riscv64.
 926     public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
 927     static {
 928         beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
 929     }
 930 
 931     // Is only supported on riscv64.
 932     public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
 933     static {

 940     }
 941 
 942     public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
 943     static {
 944         beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
 945     }
 946 
 947     // Only supported on x86.
 948     public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
 949     static {
 950         machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
 951     }
 952 
 953     public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
 954     static {
 955         beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
 956     }
 957 
 958     public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
 959     static {
 960         loadOfNodes(LOAD_OF_CLASS, "Load(B|UB|S|US|I|L|F|D|P|N)");




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

2047         vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
2048     }
2049 
2050     public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
2051     static {
2052         vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
2053     }
2054 
2055     public static final String STORE = PREFIX + "STORE" + POSTFIX;
2056     static {
2057         beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
2058     }
2059 
2060     public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
2061     static {
2062         beforeMatchingNameRegex(STORE_B, "StoreB");
2063     }
2064 
2065     public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
2066     static {
2067         storeOfNodes(STORE_B_OF_CLASS, "StoreB");
2068     }
2069 
2070     public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
2071     static {
2072         beforeMatchingNameRegex(STORE_C, "StoreC");
2073     }
2074 
2075     public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
2076     static {
2077         storeOfNodes(STORE_C_OF_CLASS, "StoreC");
2078     }
2079 
2080     public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
2081     static {
2082         beforeMatchingNameRegex(STORE_D, "StoreD");
2083     }
2084 
2085     public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
2086     static {
2087         storeOfNodes(STORE_D_OF_CLASS, "StoreD");
2088     }
2089 
2090     public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2091     static {
2092         beforeMatchingNameRegex(STORE_F, "StoreF");
2093     }
2094 
2095     public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2096     static {
2097         storeOfNodes(STORE_F_OF_CLASS, "StoreF");
2098     }
2099 
2100     public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2101     static {
2102         beforeMatchingNameRegex(STORE_I, "StoreI");
2103     }
2104 
2105     public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2106     static {
2107         storeOfNodes(STORE_I_OF_CLASS, "StoreI");
2108     }
2109 
2110     public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2111     static {
2112         beforeMatchingNameRegex(STORE_L, "StoreL");
2113     }
2114 
2115     public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2116     static {
2117         storeOfNodes(STORE_L_OF_CLASS, "StoreL");
2118     }
2119 
2120     public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2121     static {
2122         beforeMatchingNameRegex(STORE_N, "StoreN");
2123     }
2124 
2125     public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2126     static {
2127         storeOfNodes(STORE_N_OF_CLASS, "StoreN");
2128     }
2129 
2130     public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2131     static {
2132         storeOfNodes(STORE_OF_CLASS, "Store(B|C|S|I|L|F|D|P|N)");




2133     }
2134 
2135     public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2136     static {
2137         String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2138         beforeMatching(STORE_OF_FIELD, regex);
2139     }
2140 
2141     public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2142     static {
2143         beforeMatchingNameRegex(STORE_P, "StoreP");
2144     }
2145 
2146     public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2147     static {
2148         storeOfNodes(STORE_P_OF_CLASS, "StoreP");
2149     }
2150 
2151     public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2152     static {
2153         beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2154     }
2155 
2156     public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2157     static {
2158         beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2159     }
2160 
2161     public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2162     static {
2163         beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2164     }
2165 
2166     public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2167     static {
2168         beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");

2228         vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2229     }
2230 
2231     public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2232     static {
2233         vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2234     }
2235 
2236     public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2237     static {
2238         vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2239     }
2240 
2241     public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2242     static {
2243         vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2244     }
2245 
2246     public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2247     static {
2248         beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");

2249     }
2250 
2251     public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2252     static {
2253         trapNodes(TRAP, "reason");
2254     }
2255 
2256     public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2257     static {
2258         beforeMatchingNameRegex(DIV_HF, "DivHF");
2259     }
2260 
2261     public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2262     static {
2263         beforeMatchingNameRegex(UDIV_I, "UDivI");
2264     }
2265 
2266     public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2267     static {
2268         beforeMatchingNameRegex(UDIV_L, "UDivL");

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

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

 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     // Valhalla: Make sure that all Valhalla specific IR nodes are also properly initialized. Doing it here also
 156     //           ensures that the Flag VM is able to pick up the correct compile phases.
 157     static {
 158         InlineTypeIRNode.forceStaticInitialization();
 159     }
 160 
 161     public static final String ABS_D = PREFIX + "ABS_D" + POSTFIX;
 162     static {
 163         beforeMatchingNameRegex(ABS_D, "AbsD");
 164     }
 165 
 166     public static final String ABS_F = PREFIX + "ABS_F" + POSTFIX;
 167     static {
 168         beforeMatchingNameRegex(ABS_F, "AbsF");
 169     }
 170 
 171     public static final String ABS_I = PREFIX + "ABS_I" + POSTFIX;
 172     static {
 173         beforeMatchingNameRegex(ABS_I, "AbsI");
 174     }
 175 
 176     public static final String ABS_L = PREFIX + "ABS_L" + POSTFIX;
 177     static {
 178         beforeMatchingNameRegex(ABS_L, "AbsL");
 179     }
 180 

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

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

 642     public static final String CMP_UL = PREFIX + "CMP_UL" + POSTFIX;
 643     static {
 644         beforeMatchingNameRegex(CMP_UL, "CmpUL");
 645     }
 646 
 647     public static final String CMP_UL3 = PREFIX + "CMP_UL3" + POSTFIX;
 648     static {
 649         beforeMatchingNameRegex(CMP_UL3, "CmpUL3");
 650     }
 651 
 652     public static final String CMP_P = PREFIX + "CMP_P" + POSTFIX;
 653     static {
 654         beforeMatchingNameRegex(CMP_P, "CmpP");
 655     }
 656 
 657     public static final String CMP_N = PREFIX + "CMP_N" + POSTFIX;
 658     static {
 659         beforeMatchingNameRegex(CMP_N, "CmpN");
 660     }
 661 
 662     public static final String CMP_P_OR_N = PREFIX + "CMP_P_OR_N" + POSTFIX;
 663     static {
 664         beforeMatchingNameRegex(CMP_P_OR_N, "Cmp(P|N)");
 665     }
 666 
 667     public static final String CMP_LT_MASK = PREFIX + "CMP_LT_MASK" + POSTFIX;
 668     static {
 669         beforeMatchingNameRegex(CMP_LT_MASK, "CmpLTMask");
 670     }
 671 
 672     public static final String ROUND_F = PREFIX + "ROUND_F" + POSTFIX;
 673     static {
 674         beforeMatchingNameRegex(ROUND_F, "RoundF");
 675     }
 676 
 677     public static final String ROUND_D = PREFIX + "ROUND_D" + POSTFIX;
 678     static {
 679         beforeMatchingNameRegex(ROUND_D, "RoundD");
 680     }
 681 
 682     public static final String COMPRESS_BITS = PREFIX + "COMPRESS_BITS" + POSTFIX;
 683     static {
 684         beforeMatchingNameRegex(COMPRESS_BITS, "CompressBits");
 685     }
 686 

 801         beforeMatchingNameRegex(DIV_MOD_L, "DivModL");
 802     }
 803 
 804     public static final String DIV_VHF = VECTOR_PREFIX + "DIV_VHF" + POSTFIX;
 805     static {
 806         vectorNode(DIV_VHF, "DivVHF", TYPE_SHORT);
 807     }
 808 
 809     public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
 810     static {
 811         vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
 812     }
 813 
 814     public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
 815     static {
 816         vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
 817     }
 818 
 819     public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
 820     static {
 821         callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava", IS_REPLACED);
 822     }
 823 
 824     public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
 825     static {
 826         beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
 827     }
 828 
 829     public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
 830     static {
 831         beforeMatchingNameRegex(FAST_LOCK, "FastLock");
 832     }
 833 
 834     public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
 835     static {
 836         String regex = START + "FastUnlock" + MID + END;
 837         fromMacroToBeforeMatching(FAST_UNLOCK, regex);
 838     }
 839 
 840     public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
 841     static {

 937         String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 938         machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
 939     }
 940 
 941     public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
 942     static {
 943         machOnlyNameRegex(G1_STORE_P, "g1StoreP");
 944     }
 945 
 946     public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
 947     static {
 948         String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 949         machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
 950     }
 951 
 952     public static final String IF = PREFIX + "IF" + POSTFIX;
 953     static {
 954         beforeMatchingNameRegex(IF, "If\\b");
 955     }
 956 
 957     public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;
 958     static {
 959         beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
 960     }
 961 
 962     // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built).
 963     public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX;
 964     static {
 965         trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining");
 966     }
 967 
 968     public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
 969     static {
 970         trapNodes(INTRINSIC_TRAP, "intrinsic");
 971     }
 972 
 973     // Is only supported on riscv64.
 974     public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
 975     static {
 976         beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
 977     }
 978 
 979     // Is only supported on riscv64.
 980     public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
 981     static {

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

2099         vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
2100     }
2101 
2102     public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
2103     static {
2104         vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
2105     }
2106 
2107     public static final String STORE = PREFIX + "STORE" + POSTFIX;
2108     static {
2109         beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
2110     }
2111 
2112     public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
2113     static {
2114         beforeMatchingNameRegex(STORE_B, "StoreB");
2115     }
2116 
2117     public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
2118     static {
2119         storeOfNodes(STORE_B_OF_CLASS, "StoreB", IS_REPLACED);
2120     }
2121 
2122     public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
2123     static {
2124         beforeMatchingNameRegex(STORE_C, "StoreC");
2125     }
2126 
2127     public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
2128     static {
2129         storeOfNodes(STORE_C_OF_CLASS, "StoreC", IS_REPLACED);
2130     }
2131 
2132     public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
2133     static {
2134         beforeMatchingNameRegex(STORE_D, "StoreD");
2135     }
2136 
2137     public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
2138     static {
2139         storeOfNodes(STORE_D_OF_CLASS, "StoreD", IS_REPLACED);
2140     }
2141 
2142     public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2143     static {
2144         beforeMatchingNameRegex(STORE_F, "StoreF");
2145     }
2146 
2147     public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2148     static {
2149         storeOfNodes(STORE_F_OF_CLASS, "StoreF", IS_REPLACED);
2150     }
2151 
2152     public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2153     static {
2154         beforeMatchingNameRegex(STORE_I, "StoreI");
2155     }
2156 
2157     public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2158     static {
2159         storeOfNodes(STORE_I_OF_CLASS, "StoreI", IS_REPLACED);
2160     }
2161 
2162     public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2163     static {
2164         beforeMatchingNameRegex(STORE_L, "StoreL");
2165     }
2166 
2167     public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2168     static {
2169         storeOfNodes(STORE_L_OF_CLASS, "StoreL", IS_REPLACED);
2170     }
2171 
2172     public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2173     static {
2174         beforeMatchingNameRegex(STORE_N, "StoreN");
2175     }
2176 
2177     public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2178     static {
2179         storeOfNodes(STORE_N_OF_CLASS, "StoreN", IS_REPLACED);
2180     }
2181 
2182     public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2183     static {
2184         anyStoreOfNodes(STORE_OF_CLASS, IS_REPLACED);
2185     }
2186 
2187     public static void anyStoreOfNodes(String irNodePlaceholder, String fieldHolder) {
2188         storeOfNodes(irNodePlaceholder, "Store(B|C|S|I|L|F|D|P|N)", fieldHolder);
2189     }
2190 
2191     public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2192     static {
2193         String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2194         beforeMatching(STORE_OF_FIELD, regex);
2195     }
2196 
2197     public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2198     static {
2199         beforeMatchingNameRegex(STORE_P, "StoreP");
2200     }
2201 
2202     public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2203     static {
2204         storeOfNodes(STORE_P_OF_CLASS, "StoreP", IS_REPLACED);
2205     }
2206 
2207     public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2208     static {
2209         beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2210     }
2211 
2212     public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2213     static {
2214         beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2215     }
2216 
2217     public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2218     static {
2219         beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2220     }
2221 
2222     public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2223     static {
2224         beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");

2284         vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2285     }
2286 
2287     public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2288     static {
2289         vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2290     }
2291 
2292     public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2293     static {
2294         vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2295     }
2296 
2297     public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2298     static {
2299         vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2300     }
2301 
2302     public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2303     static {
2304         String regex = START + "SubTypeCheck" + MID + END;
2305         macroNodes(SUBTYPE_CHECK, regex);
2306     }
2307 
2308     public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2309     static {
2310         trapNodes(TRAP, "reason");
2311     }
2312 
2313     public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2314     static {
2315         beforeMatchingNameRegex(DIV_HF, "DivHF");
2316     }
2317 
2318     public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2319     static {
2320         beforeMatchingNameRegex(UDIV_I, "UDivI");
2321     }
2322 
2323     public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2324     static {
2325         beforeMatchingNameRegex(UDIV_L, "UDivL");

3258     }
3259 
3260     public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3261     static {
3262         machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3263     }
3264 
3265     public static final String OPAQUE_CONSTANT_BOOL = PREFIX + "OPAQUE_CONSTANT_BOOL" + POSTFIX;
3266     static {
3267         beforeMatchingNameRegex(OPAQUE_CONSTANT_BOOL, "OpaqueConstantBool");
3268     }
3269 
3270     /*
3271      * Utility methods to set up IR_NODE_MAPPINGS.
3272      */
3273 
3274     /**
3275      * Apply {@code regex} on all machine independent ideal graph phases up to and including
3276      * {@link CompilePhase#BEFORE_MATCHING}.
3277      */
3278     public static void beforeMatching(String irNodePlaceholder, String regex) {
3279         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3280     }
3281 
3282     /**
3283      * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3284      * including {@link CompilePhase#BEFORE_MATCHING}.
3285      */
3286     private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3287         String regex = START + irNodeRegex + MID + END;
3288         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3289     }
3290 
3291     /**
3292      * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3293      * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3294      * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3295      */
3296     private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3297         TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3298                                                                + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3299         // IS_REPLACED is later replaced with the specific type and size of the vector.
3300         String regex = START + irNodeRegex + MID  + IS_REPLACED + END;
3301         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3302         VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3303     }
3304 
3305     /**
3306      * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3307      */
3308     private static void macroNodes(String irNodePlaceholder, String regex) {
3309         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3310                                                                           CompilePhase.BEFORE_STRINGOPTS,
3311                                                                           CompilePhase.BEFORE_MACRO_EXPANSION));
3312     }
3313 
3314     private static void callOfNodes(String irNodePlaceholder, String callRegex, String calleeRegex) {
3315         String regex = START + callRegex + MID + calleeRegex + END;
3316         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3317     }
3318 
3319     /**
3320      * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3321      * {@link CompilePhase#MATCHING}.
3322      */
3323     public static void optoOnly(String irNodePlaceholder, String regex) {
3324         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3325     }
3326 
3327     private static void machOnly(String irNodePlaceholder, String regex) {
3328         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3329     }
3330 
3331     private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3332         String regex = START + irNodeRegex + MID + END;
3333         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3334     }
3335 
3336     /**
3337      * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3338      */
3339     private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3340         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3341                                                                           CompilePhase.AFTER_CLOOPS,
3342                                                                           CompilePhase.FINAL_CODE));
3343     }

3397     // @ptrtype:fully/qualified/package/name/to/TheClass:ptrlattice+12
3398     // with ptrtype being the kind of the type such as instptr, aryptr, etc, and ptrlattice being
3399     // the kind of the value such as BotPTR, NotNull, etc.
3400     // And variation:
3401     // - after ptrtype, we can have "stable:" or other labels, with optional space after ':'
3402     // - the class can actually be a nested class, with $ separator (and it must be ok to give only the deepest one
3403     // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3404     // Worst case, it can be something like:
3405     // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24
3406 
3407     // @ matches the start character of the pattern
3408     // (\w+: ?)+ tries to match the pattern 'ptrtype:' or 'stable:' with optional trailing whitespaces
3409     // [\\w/\\$] tries to match the pattern such as 'a/b/', 'a/b', or '/b' but also nested class such as '$c' or '$c$d'
3410     // \b asserts that the next character is a word character
3411     private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)+[\\w/\\$]*\\b";
3412     // ( \([^\)]+\))? tries to match the pattern ' (f/g,h/i/j)'
3413     // :\w+ tries to match the pattern ':NotNull'
3414     // .* tries to match the remaining of the pattern
3415     private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?:\\w+.*";
3416 
3417     private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex, String loadee) {
3418         String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + loadee + LOAD_STORE_SUFFIX + END;
3419         beforeMatching(irNodePlaceholder, regex);
3420     }
3421 
3422     private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex, String storee) {
3423         String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + storee + LOAD_STORE_SUFFIX + END;
3424         beforeMatching(irNodePlaceholder, regex);
3425     }
3426 
3427     private static void safepointScalarobjectOfNodes(String irNodePlaceholder, String irNodeRegex) {
3428         String regex = START + irNodeRegex + MID + ".*" + IS_REPLACED + ".*" + END;
3429         beforeMatching(irNodePlaceholder, regex);
3430     }
3431 
3432     private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3433         String regex = START + irNodeRegex + MID + END;
3434         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3435                 CompilePhase.BEFORE_REMOVEUSELESS,
3436                 CompilePhase.FINAL_CODE));
3437     }
3438 
3439     /**
3440      * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3441      * first phase that could contain vector nodes from super word.
3442      */
3443     private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
< prev index next >