< 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 

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




 397     }
 398 
 399     public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
 400     static {
 401         String regex = START + "AllocateArray\\b" + MID + END;
 402         macroNodes(ALLOC_ARRAY,  regex);
 403     }
 404 
 405     public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
 406     static {




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

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





 498     }
 499 
 500     public static final String STATIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "STATIC_CALL_OF_METHOD" + POSTFIX;
 501     static {
 502         callOfNodes(STATIC_CALL_OF_METHOD, "CallStaticJava");


















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

 609     public static final String CMP_UL = PREFIX + "CMP_UL" + POSTFIX;
 610     static {
 611         beforeMatchingNameRegex(CMP_UL, "CmpUL");
 612     }
 613 
 614     public static final String CMP_UL3 = PREFIX + "CMP_UL3" + POSTFIX;
 615     static {
 616         beforeMatchingNameRegex(CMP_UL3, "CmpUL3");
 617     }
 618 
 619     public static final String CMP_P = PREFIX + "CMP_P" + POSTFIX;
 620     static {
 621         beforeMatchingNameRegex(CMP_P, "CmpP");
 622     }
 623 
 624     public static final String CMP_N = PREFIX + "CMP_N" + POSTFIX;
 625     static {
 626         beforeMatchingNameRegex(CMP_N, "CmpN");
 627     }
 628 





 629     public static final String CMP_LT_MASK = PREFIX + "CMP_LT_MASK" + POSTFIX;
 630     static {
 631         beforeMatchingNameRegex(CMP_LT_MASK, "CmpLTMask");
 632     }
 633 
 634     public static final String ROUND_F = PREFIX + "ROUND_F" + POSTFIX;
 635     static {
 636         beforeMatchingNameRegex(ROUND_F, "RoundF");
 637     }
 638 
 639     public static final String ROUND_D = PREFIX + "ROUND_D" + POSTFIX;
 640     static {
 641         beforeMatchingNameRegex(ROUND_D, "RoundD");
 642     }
 643 
 644     public static final String COMPRESS_BITS = PREFIX + "COMPRESS_BITS" + POSTFIX;
 645     static {
 646         beforeMatchingNameRegex(COMPRESS_BITS, "CompressBits");
 647     }
 648 

 773        beforeMatchingNameRegex(DIV_F, "DivF");
 774     }
 775 
 776     public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
 777     static {
 778         vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
 779     }
 780 
 781     public static final String DIV_D = PREFIX + "DIV_D" + POSTFIX;
 782     static {
 783        beforeMatchingNameRegex(DIV_D, "DivD");
 784     }
 785 
 786     public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
 787     static {
 788         vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
 789     }
 790 
 791     public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
 792     static {
 793         callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava");
 794     }
 795 
 796     public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
 797     static {
 798         beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
 799     }
 800 
 801     public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
 802     static {
 803         beforeMatchingNameRegex(FAST_LOCK, "FastLock");
 804     }
 805 
 806     public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
 807     static {
 808         String regex = START + "FastUnlock" + MID + END;
 809         fromMacroToBeforeMatching(FAST_UNLOCK, regex);
 810     }
 811 
 812     public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
 813     static {

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

 955     }
 956 
 957     public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
 958     static {
 959         beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
 960     }
 961 
 962     // Only supported on x86.
 963     public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
 964     static {
 965         machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
 966     }
 967 
 968     public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
 969     static {
 970         beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
 971     }
 972 
 973     public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
 974     static {
 975         loadOfNodes(LOAD_OF_CLASS, "Load(B|UB|S|US|I|L|F|D|P|N)");




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

2072         vectorNode(SQRT_VF, "SqrtVF", TYPE_FLOAT);
2073     }
2074 
2075     public static final String SQRT_VD = VECTOR_PREFIX + "SQRT_VD" + POSTFIX;
2076     static {
2077         vectorNode(SQRT_VD, "SqrtVD", TYPE_DOUBLE);
2078     }
2079 
2080     public static final String STORE = PREFIX + "STORE" + POSTFIX;
2081     static {
2082         beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
2083     }
2084 
2085     public static final String STORE_B = PREFIX + "STORE_B" + POSTFIX;
2086     static {
2087         beforeMatchingNameRegex(STORE_B, "StoreB");
2088     }
2089 
2090     public static final String STORE_B_OF_CLASS = COMPOSITE_PREFIX + "STORE_B_OF_CLASS" + POSTFIX;
2091     static {
2092         storeOfNodes(STORE_B_OF_CLASS, "StoreB");
2093     }
2094 
2095     public static final String STORE_C = PREFIX + "STORE_C" + POSTFIX;
2096     static {
2097         beforeMatchingNameRegex(STORE_C, "StoreC");
2098     }
2099 
2100     public static final String STORE_C_OF_CLASS = COMPOSITE_PREFIX + "STORE_C_OF_CLASS" + POSTFIX;
2101     static {
2102         storeOfNodes(STORE_C_OF_CLASS, "StoreC");
2103     }
2104 
2105     public static final String STORE_D = PREFIX + "STORE_D" + POSTFIX;
2106     static {
2107         beforeMatchingNameRegex(STORE_D, "StoreD");
2108     }
2109 
2110     public static final String STORE_D_OF_CLASS = COMPOSITE_PREFIX + "STORE_D_OF_CLASS" + POSTFIX;
2111     static {
2112         storeOfNodes(STORE_D_OF_CLASS, "StoreD");
2113     }
2114 
2115     public static final String STORE_F = PREFIX + "STORE_F" + POSTFIX;
2116     static {
2117         beforeMatchingNameRegex(STORE_F, "StoreF");
2118     }
2119 
2120     public static final String STORE_F_OF_CLASS = COMPOSITE_PREFIX + "STORE_F_OF_CLASS" + POSTFIX;
2121     static {
2122         storeOfNodes(STORE_F_OF_CLASS, "StoreF");
2123     }
2124 
2125     public static final String STORE_I = PREFIX + "STORE_I" + POSTFIX;
2126     static {
2127         beforeMatchingNameRegex(STORE_I, "StoreI");
2128     }
2129 
2130     public static final String STORE_I_OF_CLASS = COMPOSITE_PREFIX + "STORE_I_OF_CLASS" + POSTFIX;
2131     static {
2132         storeOfNodes(STORE_I_OF_CLASS, "StoreI");
2133     }
2134 
2135     public static final String STORE_L = PREFIX + "STORE_L" + POSTFIX;
2136     static {
2137         beforeMatchingNameRegex(STORE_L, "StoreL");
2138     }
2139 
2140     public static final String STORE_L_OF_CLASS = COMPOSITE_PREFIX + "STORE_L_OF_CLASS" + POSTFIX;
2141     static {
2142         storeOfNodes(STORE_L_OF_CLASS, "StoreL");
2143     }
2144 
2145     public static final String STORE_N = PREFIX + "STORE_N" + POSTFIX;
2146     static {
2147         beforeMatchingNameRegex(STORE_N, "StoreN");
2148     }
2149 
2150     public static final String STORE_N_OF_CLASS = COMPOSITE_PREFIX + "STORE_N_OF_CLASS" + POSTFIX;
2151     static {
2152         storeOfNodes(STORE_N_OF_CLASS, "StoreN");
2153     }
2154 
2155     public static final String STORE_OF_CLASS = COMPOSITE_PREFIX + "STORE_OF_CLASS" + POSTFIX;
2156     static {
2157         storeOfNodes(STORE_OF_CLASS, "Store(B|C|S|I|L|F|D|P|N)");




2158     }
2159 
2160     public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2161     static {
2162         String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2163         beforeMatching(STORE_OF_FIELD, regex);
2164     }
2165 
2166     public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2167     static {
2168         beforeMatchingNameRegex(STORE_P, "StoreP");
2169     }
2170 
2171     public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2172     static {
2173         storeOfNodes(STORE_P_OF_CLASS, "StoreP");
2174     }
2175 
2176     public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2177     static {
2178         beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2179     }
2180 
2181     public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2182     static {
2183         beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2184     }
2185 
2186     public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2187     static {
2188         beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2189     }
2190 
2191     public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2192     static {
2193         beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");

2253         vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2254     }
2255 
2256     public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2257     static {
2258         vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2259     }
2260 
2261     public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2262     static {
2263         vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2264     }
2265 
2266     public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2267     static {
2268         vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2269     }
2270 
2271     public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2272     static {
2273         beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");

2274     }
2275 
2276     public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2277     static {
2278         trapNodes(TRAP, "reason");
2279     }
2280 
2281     public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2282     static {
2283         beforeMatchingNameRegex(DIV_HF, "DivHF");
2284     }
2285 
2286     public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2287     static {
2288         beforeMatchingNameRegex(UDIV_I, "UDivI");
2289     }
2290 
2291     public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2292     static {
2293         beforeMatchingNameRegex(UDIV_L, "UDivL");

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

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

3590         if (isCompositeIRNode(irNodeString)) {
3591             TestFramework.check(irNodeString.length() > COMPOSITE_PREFIX.length() + POSTFIX.length(),
3592                                 "Invalid composite node placeholder: " + irNodeString);
3593             prefixLength = COMPOSITE_PREFIX.length();
3594         } else if (isVectorIRNode(irNodeString)) {
3595             TestFramework.check(irNodeString.length() > VECTOR_PREFIX.length() + POSTFIX.length(),
3596                                 "Invalid vector node placeholder: " + irNodeString);
3597             prefixLength = VECTOR_PREFIX.length();
3598         } else {
3599             prefixLength = PREFIX.length();
3600         }
3601         return "IRNode." + irNodeString.substring(prefixLength, irNodeString.length() - POSTFIX.length());
3602     }
3603 
3604     /**
3605      * Is this IR node supported on current platform, used VM build, etc.?
3606      * Throws a {@link CheckedTestFrameworkException} if the IR node is unsupported.
3607      */
3608     public static void checkIRNodeSupported(String node) throws CheckedTestFrameworkException {
3609         switch (node) {
3610             case INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP -> {
3611                 if (!WhiteBox.getWhiteBox().isJVMCISupportedByGC()) {
3612                     throw new CheckedTestFrameworkException("INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP is unsupported " +
3613                                                             "in builds without JVMCI.");
3614                 }
3615             }
3616             case CHECKCAST_ARRAYCOPY -> {
3617                 if (Platform.isS390x()) {
3618                     throw new CheckedTestFrameworkException("CHECKCAST_ARRAYCOPY is unsupported on s390.");
3619                 }
3620             }
3621             case IS_FINITE_D, IS_FINITE_F -> {
3622                 if (!Platform.isRISCV64()) {
3623                     throw new CheckedTestFrameworkException("IS_FINITE_* is only supported on riscv64.");
3624                 }
3625             }
3626             // default: do nothing -> IR node is supported and can be used by the user.
3627         }
3628     }
3629 
3630     /**
3631      * Get the regex of an IR node for a specific compile phase. If {@code irNode} is not an IR node placeholder string
3632      * or if there is no regex specified for {@code compilePhase}, a {@link TestFormatException} is reported.
3633      */
3634     public static String getRegexForCompilePhase(String irNode, CompilePhase compilePhase) {
3635         IRNodeMapEntry entry = IR_NODE_MAPPINGS.get(irNode);

  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 

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

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

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

 816        beforeMatchingNameRegex(DIV_F, "DivF");
 817     }
 818 
 819     public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
 820     static {
 821         vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
 822     }
 823 
 824     public static final String DIV_D = PREFIX + "DIV_D" + POSTFIX;
 825     static {
 826        beforeMatchingNameRegex(DIV_D, "DivD");
 827     }
 828 
 829     public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
 830     static {
 831         vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
 832     }
 833 
 834     public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
 835     static {
 836         callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava", IS_REPLACED);
 837     }
 838 
 839     public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
 840     static {
 841         beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
 842     }
 843 
 844     public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
 845     static {
 846         beforeMatchingNameRegex(FAST_LOCK, "FastLock");
 847     }
 848 
 849     public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
 850     static {
 851         String regex = START + "FastUnlock" + MID + END;
 852         fromMacroToBeforeMatching(FAST_UNLOCK, regex);
 853     }
 854 
 855     public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
 856     static {

 952         String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 953         machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
 954     }
 955 
 956     public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
 957     static {
 958         machOnlyNameRegex(G1_STORE_P, "g1StoreP");
 959     }
 960 
 961     public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
 962     static {
 963         String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 964         machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
 965     }
 966 
 967     public static final String IF = PREFIX + "IF" + POSTFIX;
 968     static {
 969         beforeMatchingNameRegex(IF, "If\\b");
 970     }
 971 
 972     public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;

 973     static {
 974         beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
 975     }
 976 
 977     public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
 978     static {
 979         trapNodes(INTRINSIC_TRAP, "intrinsic");
 980     }
 981 
 982     // Is only supported on riscv64.
 983     public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
 984     static {
 985         beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
 986     }
 987 
 988     // Is only supported on riscv64.
 989     public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
 990     static {
 991         beforeMatchingNameRegex(IS_FINITE_F, "IsFiniteF");
 992     }
 993 
 994     public static final String IS_INFINITE_D = PREFIX + "IS_INFINITE_D" + POSTFIX;

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

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

2303         vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2304     }
2305 
2306     public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2307     static {
2308         vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2309     }
2310 
2311     public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2312     static {
2313         vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2314     }
2315 
2316     public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2317     static {
2318         vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2319     }
2320 
2321     public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2322     static {
2323         String regex = START + "SubTypeCheck" + MID + END;
2324         macroNodes(SUBTYPE_CHECK, regex);
2325     }
2326 
2327     public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2328     static {
2329         trapNodes(TRAP, "reason");
2330     }
2331 
2332     public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2333     static {
2334         beforeMatchingNameRegex(DIV_HF, "DivHF");
2335     }
2336 
2337     public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2338     static {
2339         beforeMatchingNameRegex(UDIV_I, "UDivI");
2340     }
2341 
2342     public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2343     static {
2344         beforeMatchingNameRegex(UDIV_L, "UDivL");

3282     }
3283 
3284     public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3285     static {
3286         machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3287     }
3288 
3289     public static final String OPAQUE_CONSTANT_BOOL = PREFIX + "OPAQUE_CONSTANT_BOOL" + POSTFIX;
3290     static {
3291         beforeMatchingNameRegex(OPAQUE_CONSTANT_BOOL, "OpaqueConstantBool");
3292     }
3293 
3294     /*
3295      * Utility methods to set up IR_NODE_MAPPINGS.
3296      */
3297 
3298     /**
3299      * Apply {@code regex} on all machine independent ideal graph phases up to and including
3300      * {@link CompilePhase#BEFORE_MATCHING}.
3301      */
3302     public static void beforeMatching(String irNodePlaceholder, String regex) {
3303         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3304     }
3305 
3306     /**
3307      * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3308      * including {@link CompilePhase#BEFORE_MATCHING}.
3309      */
3310     private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3311         String regex = START + irNodeRegex + MID + END;
3312         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3313     }
3314 
3315     /**
3316      * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3317      * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3318      * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3319      */
3320     private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3321         TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3322                                                                + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3323         // IS_REPLACED is later replaced with the specific type and size of the vector.
3324         String regex = START + irNodeRegex + MID  + IS_REPLACED + END;
3325         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3326         VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3327     }
3328 
3329     /**
3330      * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3331      */
3332     private static void macroNodes(String irNodePlaceholder, String regex) {
3333         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3334                                                                           CompilePhase.BEFORE_STRINGOPTS,
3335                                                                           CompilePhase.BEFORE_MACRO_EXPANSION));
3336     }
3337 
3338     private static void callOfNodes(String irNodePlaceholder, String callRegex, String calleeRegex) {
3339         String regex = START + callRegex + MID + calleeRegex + END;
3340         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3341     }
3342 
3343     /**
3344      * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3345      * {@link CompilePhase#MATCHING}.
3346      */
3347     public static void optoOnly(String irNodePlaceholder, String regex) {
3348         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3349     }
3350 
3351     private static void machOnly(String irNodePlaceholder, String regex) {
3352         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3353     }
3354 
3355     private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3356         String regex = START + irNodeRegex + MID + END;
3357         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3358     }
3359 
3360     /**
3361      * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3362      */
3363     private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3364         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3365                                                                           CompilePhase.AFTER_CLOOPS,
3366                                                                           CompilePhase.FINAL_CODE));
3367     }

3421     // @ptrtype:fully/qualified/package/name/to/TheClass:ptrlattice+12
3422     // with ptrtype being the kind of the type such as instptr, aryptr, etc, and ptrlattice being
3423     // the kind of the value such as BotPTR, NotNull, etc.
3424     // And variation:
3425     // - after ptrtype, we can have "stable:" or other labels, with optional space after ':'
3426     // - the class can actually be a nested class, with $ separator (and it must be ok to give only the deepest one
3427     // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3428     // Worst case, it can be something like:
3429     // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24
3430 
3431     // @ matches the start character of the pattern
3432     // (\w+: ?)+ tries to match the pattern 'ptrtype:' or 'stable:' with optional trailing whitespaces
3433     // [\\w/\\$] tries to match the pattern such as 'a/b/', 'a/b', or '/b' but also nested class such as '$c' or '$c$d'
3434     // \b asserts that the next character is a word character
3435     private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)+[\\w/\\$]*\\b";
3436     // ( \([^\)]+\))? tries to match the pattern ' (f/g,h/i/j)'
3437     // :\w+ tries to match the pattern ':NotNull'
3438     // .* tries to match the remaining of the pattern
3439     private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?:\\w+.*";
3440 
3441     private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex, String loadee) {
3442         String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + loadee + LOAD_STORE_SUFFIX + END;
3443         beforeMatching(irNodePlaceholder, regex);
3444     }
3445 
3446     private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex, String storee) {
3447         String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + storee + LOAD_STORE_SUFFIX + END;
3448         beforeMatching(irNodePlaceholder, regex);
3449     }
3450 
3451     private static void safepointScalarobjectOfNodes(String irNodePlaceholder, String irNodeRegex) {
3452         String regex = START + irNodeRegex + MID + ".*" + IS_REPLACED + ".*" + END;
3453         beforeMatching(irNodePlaceholder, regex);
3454     }
3455 
3456     private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3457         String regex = START + irNodeRegex + MID + END;
3458         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3459                 CompilePhase.BEFORE_REMOVEUSELESS,
3460                 CompilePhase.FINAL_CODE));
3461     }
3462 
3463     /**
3464      * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3465      * first phase that could contain vector nodes from super word.
3466      */
3467     private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {

3641         if (isCompositeIRNode(irNodeString)) {
3642             TestFramework.check(irNodeString.length() > COMPOSITE_PREFIX.length() + POSTFIX.length(),
3643                                 "Invalid composite node placeholder: " + irNodeString);
3644             prefixLength = COMPOSITE_PREFIX.length();
3645         } else if (isVectorIRNode(irNodeString)) {
3646             TestFramework.check(irNodeString.length() > VECTOR_PREFIX.length() + POSTFIX.length(),
3647                                 "Invalid vector node placeholder: " + irNodeString);
3648             prefixLength = VECTOR_PREFIX.length();
3649         } else {
3650             prefixLength = PREFIX.length();
3651         }
3652         return "IRNode." + irNodeString.substring(prefixLength, irNodeString.length() - POSTFIX.length());
3653     }
3654 
3655     /**
3656      * Is this IR node supported on current platform, used VM build, etc.?
3657      * Throws a {@link CheckedTestFrameworkException} if the IR node is unsupported.
3658      */
3659     public static void checkIRNodeSupported(String node) throws CheckedTestFrameworkException {
3660         switch (node) {






3661             case CHECKCAST_ARRAYCOPY -> {
3662                 if (Platform.isS390x()) {
3663                     throw new CheckedTestFrameworkException("CHECKCAST_ARRAYCOPY is unsupported on s390.");
3664                 }
3665             }
3666             case IS_FINITE_D, IS_FINITE_F -> {
3667                 if (!Platform.isRISCV64()) {
3668                     throw new CheckedTestFrameworkException("IS_FINITE_* is only supported on riscv64.");
3669                 }
3670             }
3671             // default: do nothing -> IR node is supported and can be used by the user.
3672         }
3673     }
3674 
3675     /**
3676      * Get the regex of an IR node for a specific compile phase. If {@code irNode} is not an IR node placeholder string
3677      * or if there is no regex specified for {@code compilePhase}, a {@link TestFormatException} is reported.
3678      */
3679     public static String getRegexForCompilePhase(String irNode, CompilePhase compilePhase) {
3680         IRNodeMapEntry entry = IR_NODE_MAPPINGS.get(irNode);
< prev index next >