< 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 

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




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




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

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





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


















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

 599     public static final String CMP_UL = PREFIX + "CMP_UL" + POSTFIX;
 600     static {
 601         beforeMatchingNameRegex(CMP_UL, "CmpUL");
 602     }
 603 
 604     public static final String CMP_UL3 = PREFIX + "CMP_UL3" + POSTFIX;
 605     static {
 606         beforeMatchingNameRegex(CMP_UL3, "CmpUL3");
 607     }
 608 
 609     public static final String CMP_P = PREFIX + "CMP_P" + POSTFIX;
 610     static {
 611         beforeMatchingNameRegex(CMP_P, "CmpP");
 612     }
 613 
 614     public static final String CMP_N = PREFIX + "CMP_N" + POSTFIX;
 615     static {
 616         beforeMatchingNameRegex(CMP_N, "CmpN");
 617     }
 618 





 619     public static final String CMP_LT_MASK = PREFIX + "CMP_LT_MASK" + POSTFIX;
 620     static {
 621         beforeMatchingNameRegex(CMP_LT_MASK, "CmpLTMask");
 622     }
 623 
 624     public static final String ROUND_F = PREFIX + "ROUND_F" + POSTFIX;
 625     static {
 626         beforeMatchingNameRegex(ROUND_F, "RoundF");
 627     }
 628 
 629     public static final String ROUND_D = PREFIX + "ROUND_D" + POSTFIX;
 630     static {
 631         beforeMatchingNameRegex(ROUND_D, "RoundD");
 632     }
 633 
 634     public static final String COMPRESS_BITS = PREFIX + "COMPRESS_BITS" + POSTFIX;
 635     static {
 636         beforeMatchingNameRegex(COMPRESS_BITS, "CompressBits");
 637     }
 638 

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

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





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

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




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

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




2103     }
2104 
2105     public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2106     static {
2107         String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2108         beforeMatching(STORE_OF_FIELD, regex);
2109     }
2110 
2111     public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2112     static {
2113         beforeMatchingNameRegex(STORE_P, "StoreP");
2114     }
2115 
2116     public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2117     static {
2118         storeOfNodes(STORE_P_OF_CLASS, "StoreP");
2119     }
2120 
2121     public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2122     static {
2123         beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2124     }
2125 
2126     public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2127     static {
2128         beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2129     }
2130 
2131     public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2132     static {
2133         beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2134     }
2135 
2136     public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2137     static {
2138         beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");

2198         vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2199     }
2200 
2201     public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2202     static {
2203         vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2204     }
2205 
2206     public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2207     static {
2208         vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2209     }
2210 
2211     public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2212     static {
2213         vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2214     }
2215 
2216     public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2217     static {
2218         beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");

2219     }
2220 
2221     public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2222     static {
2223         trapNodes(TRAP, "reason");
2224     }
2225 
2226     public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2227     static {
2228         beforeMatchingNameRegex(DIV_HF, "DivHF");
2229     }
2230 
2231     public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2232     static {
2233         beforeMatchingNameRegex(UDIV_I, "UDivI");
2234     }
2235 
2236     public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2237     static {
2238         beforeMatchingNameRegex(UDIV_L, "UDivL");

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

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

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

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

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

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

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

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

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

2254         vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2255     }
2256 
2257     public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2258     static {
2259         vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2260     }
2261 
2262     public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2263     static {
2264         vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2265     }
2266 
2267     public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2268     static {
2269         vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2270     }
2271 
2272     public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2273     static {
2274         String regex = START + "SubTypeCheck" + MID + END;
2275         macroNodes(SUBTYPE_CHECK, regex);
2276     }
2277 
2278     public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2279     static {
2280         trapNodes(TRAP, "reason");
2281     }
2282 
2283     public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2284     static {
2285         beforeMatchingNameRegex(DIV_HF, "DivHF");
2286     }
2287 
2288     public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2289     static {
2290         beforeMatchingNameRegex(UDIV_I, "UDivI");
2291     }
2292 
2293     public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2294     static {
2295         beforeMatchingNameRegex(UDIV_L, "UDivL");

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

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