< 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 

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

 929         String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 930         machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
 931     }
 932 
 933     public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
 934     static {
 935         machOnlyNameRegex(G1_STORE_P, "g1StoreP");
 936     }
 937 
 938     public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
 939     static {
 940         String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 941         machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
 942     }
 943 
 944     public static final String IF = PREFIX + "IF" + POSTFIX;
 945     static {
 946         beforeMatchingNameRegex(IF, "If\\b");
 947     }
 948 





 949     public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
 950     static {
 951         trapNodes(INTRINSIC_TRAP, "intrinsic");
 952     }
 953 
 954     // Is only supported on riscv64.
 955     public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
 956     static {
 957         beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
 958     }
 959 
 960     // Is only supported on riscv64.
 961     public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
 962     static {
 963         beforeMatchingNameRegex(IS_FINITE_F, "IsFiniteF");
 964     }
 965 
 966     public static final String IS_INFINITE_D = PREFIX + "IS_INFINITE_D" + POSTFIX;
 967     static {
 968         beforeMatchingNameRegex(IS_INFINITE_D, "IsInfiniteD");
 969     }
 970 
 971     public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
 972     static {
 973         beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
 974     }
 975 
 976     // Only supported on x86.
 977     public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
 978     static {
 979         machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
 980     }
 981 
 982     public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
 983     static {
 984         beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
 985     }
 986 
 987     public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
 988     static {
 989         loadOfNodes(LOAD_OF_CLASS, "Load(B|UB|S|US|I|L|F|D|P|N)");




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

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




2172     }
2173 
2174     public static final String STORE_OF_FIELD = COMPOSITE_PREFIX + "STORE_OF_FIELD" + POSTFIX;
2175     static {
2176         String regex = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
2177         beforeMatching(STORE_OF_FIELD, regex);
2178     }
2179 
2180     public static final String STORE_P = PREFIX + "STORE_P" + POSTFIX;
2181     static {
2182         beforeMatchingNameRegex(STORE_P, "StoreP");
2183     }
2184 
2185     public static final String STORE_P_OF_CLASS = COMPOSITE_PREFIX + "STORE_P_OF_CLASS" + POSTFIX;
2186     static {
2187         storeOfNodes(STORE_P_OF_CLASS, "StoreP");
2188     }
2189 
2190     public static final String STORE_VECTOR = PREFIX + "STORE_VECTOR" + POSTFIX;
2191     static {
2192         beforeMatchingNameRegex(STORE_VECTOR, "StoreVector");
2193     }
2194 
2195     public static final String STORE_VECTOR_SCATTER = PREFIX + "STORE_VECTOR_SCATTER" + POSTFIX;
2196     static {
2197         beforeMatchingNameRegex(STORE_VECTOR_SCATTER, "StoreVectorScatter");
2198     }
2199 
2200     public static final String STORE_VECTOR_MASKED = PREFIX + "STORE_VECTOR_MASKED" + POSTFIX;
2201     static {
2202         beforeMatchingNameRegex(STORE_VECTOR_MASKED, "StoreVectorMasked");
2203     }
2204 
2205     public static final String STORE_VECTOR_SCATTER_MASKED = PREFIX + "STORE_VECTOR_SCATTER_MASKED" + POSTFIX;
2206     static {
2207         beforeMatchingNameRegex(STORE_VECTOR_SCATTER_MASKED, "StoreVectorScatterMasked");

2267         vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2268     }
2269 
2270     public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2271     static {
2272         vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2273     }
2274 
2275     public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2276     static {
2277         vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2278     }
2279 
2280     public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2281     static {
2282         vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2283     }
2284 
2285     public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2286     static {
2287         beforeMatchingNameRegex(SUBTYPE_CHECK, "SubTypeCheck");

2288     }
2289 
2290     public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2291     static {
2292         trapNodes(TRAP, "reason");
2293     }
2294 
2295     public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2296     static {
2297         beforeMatchingNameRegex(DIV_HF, "DivHF");
2298     }
2299 
2300     public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2301     static {
2302         beforeMatchingNameRegex(UDIV_I, "UDivI");
2303     }
2304 
2305     public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2306     static {
2307         beforeMatchingNameRegex(UDIV_L, "UDivL");

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

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

 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 

 836        beforeMatchingNameRegex(DIV_F, "DivF");
 837     }
 838 
 839     public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX;
 840     static {
 841         vectorNode(DIV_VF, "DivVF", TYPE_FLOAT);
 842     }
 843 
 844     public static final String DIV_D = PREFIX + "DIV_D" + POSTFIX;
 845     static {
 846        beforeMatchingNameRegex(DIV_D, "DivD");
 847     }
 848 
 849     public static final String DIV_VD = VECTOR_PREFIX + "DIV_VD" + POSTFIX;
 850     static {
 851         vectorNode(DIV_VD, "DivVD", TYPE_DOUBLE);
 852     }
 853 
 854     public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
 855     static {
 856         callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava", IS_REPLACED);
 857     }
 858 
 859     public static final String EXPAND_BITS = PREFIX + "EXPAND_BITS" + POSTFIX;
 860     static {
 861         beforeMatchingNameRegex(EXPAND_BITS, "ExpandBits");
 862     }
 863 
 864     public static final String FAST_LOCK = PREFIX + "FAST_LOCK" + POSTFIX;
 865     static {
 866         beforeMatchingNameRegex(FAST_LOCK, "FastLock");
 867     }
 868 
 869     public static final String FAST_UNLOCK = PREFIX + "FAST_UNLOCK" + POSTFIX;
 870     static {
 871         String regex = START + "FastUnlock" + MID + END;
 872         fromMacroToBeforeMatching(FAST_UNLOCK, regex);
 873     }
 874 
 875     public static final String FIELD_ACCESS = PREFIX + "FIELD_ACCESS" + POSTFIX;
 876     static {

 972         String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 973         machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex);
 974     }
 975 
 976     public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX;
 977     static {
 978         machOnlyNameRegex(G1_STORE_P, "g1StoreP");
 979     }
 980 
 981     public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX;
 982     static {
 983         String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END;
 984         machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex);
 985     }
 986 
 987     public static final String IF = PREFIX + "IF" + POSTFIX;
 988     static {
 989         beforeMatchingNameRegex(IF, "If\\b");
 990     }
 991 
 992     public static final String INLINE_TYPE = PREFIX + "INLINE_TYPE" + POSTFIX;
 993     static {
 994         beforeMatchingNameRegex(INLINE_TYPE, "InlineType");
 995     }
 996 
 997     public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX;
 998     static {
 999         trapNodes(INTRINSIC_TRAP, "intrinsic");
1000     }
1001 
1002     // Is only supported on riscv64.
1003     public static final String IS_FINITE_D = PREFIX + "IS_FINITE_D" + POSTFIX;
1004     static {
1005         beforeMatchingNameRegex(IS_FINITE_D, "IsFiniteD");
1006     }
1007 
1008     // Is only supported on riscv64.
1009     public static final String IS_FINITE_F = PREFIX + "IS_FINITE_F" + POSTFIX;
1010     static {
1011         beforeMatchingNameRegex(IS_FINITE_F, "IsFiniteF");
1012     }
1013 
1014     public static final String IS_INFINITE_D = PREFIX + "IS_INFINITE_D" + POSTFIX;
1015     static {
1016         beforeMatchingNameRegex(IS_INFINITE_D, "IsInfiniteD");
1017     }
1018 
1019     public static final String IS_INFINITE_F = PREFIX + "IS_INFINITE_F" + POSTFIX;
1020     static {
1021         beforeMatchingNameRegex(IS_INFINITE_F, "IsInfiniteF");
1022     }
1023 
1024     // Only supported on x86.
1025     public static final String LEA_P = PREFIX + "LEA_P" + POSTFIX;
1026     static {
1027         machOnly(LEA_P, "leaP(CompressedOopOffset|(8|32)Narrow)");
1028     }
1029 
1030     public static final String LOAD = PREFIX + "LOAD" + POSTFIX;
1031     static {
1032         beforeMatchingNameRegex(LOAD, "Load(B|UB|S|US|I|L|F|D|P|N)");
1033     }
1034 
1035     public static final String LOAD_OF_CLASS = COMPOSITE_PREFIX + "LOAD_OF_CLASS" + POSTFIX;
1036     static {
1037         anyLoadOfNodes(LOAD_OF_CLASS, IS_REPLACED);
1038     }
1039 
1040     public static void anyLoadOfNodes(String irNodePlaceholder, String fieldHolder) {
1041         loadOfNodes(irNodePlaceholder, "Load(B|UB|S|US|I|L|F|D|P|N)", fieldHolder);
1042     }
1043 
1044     public static final String LOAD_B = PREFIX + "LOAD_B" + POSTFIX;
1045     static {
1046         beforeMatchingNameRegex(LOAD_B, "LoadB");
1047     }
1048 
1049     public static final String LOAD_B_OF_CLASS = COMPOSITE_PREFIX + "LOAD_B_OF_CLASS" + POSTFIX;
1050     static {
1051         loadOfNodes(LOAD_B_OF_CLASS, "LoadB", IS_REPLACED);
1052     }
1053 
1054     public static final String LOAD_D = PREFIX + "LOAD_D" + POSTFIX;
1055     static {
1056         beforeMatchingNameRegex(LOAD_D, "LoadD");
1057     }
1058 
1059     public static final String LOAD_D_OF_CLASS = COMPOSITE_PREFIX + "LOAD_D_OF_CLASS" + POSTFIX;
1060     static {
1061         loadOfNodes(LOAD_D_OF_CLASS, "LoadD", IS_REPLACED);
1062     }
1063 
1064     public static final String LOAD_F = PREFIX + "LOAD_F" + POSTFIX;
1065     static {
1066         beforeMatchingNameRegex(LOAD_F, "LoadF");
1067     }
1068 
1069     public static final String LOAD_F_OF_CLASS = COMPOSITE_PREFIX + "LOAD_F_OF_CLASS" + POSTFIX;
1070     static {
1071         loadOfNodes(LOAD_F_OF_CLASS, "LoadF", IS_REPLACED);
1072     }
1073 
1074     public static final String LOAD_I = PREFIX + "LOAD_I" + POSTFIX;
1075     static {
1076         beforeMatchingNameRegex(LOAD_I, "LoadI");
1077     }
1078 
1079     public static final String LOAD_I_OF_CLASS = COMPOSITE_PREFIX + "LOAD_I_OF_CLASS" + POSTFIX;
1080     static {
1081         loadOfNodes(LOAD_I_OF_CLASS, "LoadI", IS_REPLACED);
1082     }
1083 
1084     public static final String LOAD_KLASS = PREFIX + "LOAD_KLASS" + POSTFIX;
1085     static {
1086         beforeMatchingNameRegex(LOAD_KLASS, "LoadKlass");
1087     }
1088 
1089     public static final String LOAD_NKLASS = PREFIX + "LOAD_NKLASS" + POSTFIX;
1090     static {
1091         beforeMatchingNameRegex(LOAD_NKLASS, "LoadNKlass");
1092     }
1093 
1094     public static final String LOAD_KLASS_OR_NKLASS = PREFIX + "LOAD_KLASS_OR_NKLASS" + POSTFIX;
1095     static {
1096         beforeMatchingNameRegex(LOAD_KLASS_OR_NKLASS, "LoadN?Klass");
1097     }
1098 
1099     public static final String LOAD_L = PREFIX + "LOAD_L" + POSTFIX;
1100     static {
1101         beforeMatchingNameRegex(LOAD_L, "LoadL");
1102     }
1103 
1104     public static final String LOAD_L_OF_CLASS = COMPOSITE_PREFIX + "LOAD_L_OF_CLASS" + POSTFIX;
1105     static {
1106         loadOfNodes(LOAD_L_OF_CLASS, "LoadL", IS_REPLACED);
1107     }
1108 
1109     public static final String LOAD_N = PREFIX + "LOAD_N" + POSTFIX;
1110     static {
1111         beforeMatchingNameRegex(LOAD_N, "LoadN");
1112     }
1113 
1114     public static final String LOAD_N_OF_CLASS = COMPOSITE_PREFIX + "LOAD_N_OF_CLASS" + POSTFIX;
1115     static {
1116         loadOfNodes(LOAD_N_OF_CLASS, "LoadN", IS_REPLACED);
1117     }
1118 
1119     public static final String LOAD_OF_FIELD = COMPOSITE_PREFIX + "LOAD_OF_FIELD" + POSTFIX;
1120     static {
1121         String regex = START + "Load(B|C|S|I|L|F|D|P|N)" + MID + "@.*name=" + IS_REPLACED + ",.*" + END;
1122         beforeMatching(LOAD_OF_FIELD, regex);
1123     }
1124 
1125     public static final String LOAD_P = PREFIX + "LOAD_P" + POSTFIX;
1126     static {
1127         beforeMatchingNameRegex(LOAD_P, "LoadP");
1128     }
1129 
1130     public static final String LOAD_P_OF_CLASS = COMPOSITE_PREFIX + "LOAD_P_OF_CLASS" + POSTFIX;
1131     static {
1132         loadOfNodes(LOAD_P_OF_CLASS, "LoadP", IS_REPLACED);
1133     }
1134 
1135     public static final String LOAD_S = PREFIX + "LOAD_S" + POSTFIX;
1136     static {
1137         beforeMatchingNameRegex(LOAD_S, "LoadS");
1138     }
1139 
1140     public static final String LOAD_S_OF_CLASS = COMPOSITE_PREFIX + "LOAD_S_OF_CLASS" + POSTFIX;
1141     static {
1142         loadOfNodes(LOAD_S_OF_CLASS, "LoadS", IS_REPLACED);
1143     }
1144 
1145     public static final String LOAD_UB = PREFIX + "LOAD_UB" + POSTFIX;
1146     static {
1147         beforeMatchingNameRegex(LOAD_UB, "LoadUB");
1148     }
1149 
1150     public static final String LOAD_UB_OF_CLASS = COMPOSITE_PREFIX + "LOAD_UB_OF_CLASS" + POSTFIX;
1151     static {
1152         loadOfNodes(LOAD_UB_OF_CLASS, "LoadUB", IS_REPLACED);
1153     }
1154 
1155     public static final String LOAD_US = PREFIX + "LOAD_US" + POSTFIX;
1156     static {
1157         beforeMatchingNameRegex(LOAD_US, "LoadUS");
1158     }
1159 
1160     public static final String LOAD_US_OF_CLASS = COMPOSITE_PREFIX + "LOAD_US_OF_CLASS" + POSTFIX;
1161     static {
1162         loadOfNodes(LOAD_US_OF_CLASS, "LoadUS", IS_REPLACED);
1163     }
1164 
1165     public static final String LOAD_VECTOR_B = VECTOR_PREFIX + "LOAD_VECTOR_B" + POSTFIX;
1166     static {
1167         vectorNode(LOAD_VECTOR_B, "LoadVector", TYPE_BYTE);
1168     }
1169 
1170     public static final String LOAD_VECTOR_C = VECTOR_PREFIX + "LOAD_VECTOR_C" + POSTFIX;
1171     static {
1172         vectorNode(LOAD_VECTOR_C, "LoadVector", TYPE_CHAR);
1173     }
1174 
1175     public static final String LOAD_VECTOR_S = VECTOR_PREFIX + "LOAD_VECTOR_S" + POSTFIX;
1176     static {
1177         vectorNode(LOAD_VECTOR_S, "LoadVector", TYPE_SHORT);
1178     }
1179 
1180     public static final String LOAD_VECTOR_I = VECTOR_PREFIX + "LOAD_VECTOR_I" + POSTFIX;
1181     static {
1182         vectorNode(LOAD_VECTOR_I, "LoadVector", TYPE_INT);

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

2323         vectorNode(SUB_VL, "SubVL", TYPE_LONG);
2324     }
2325 
2326     public static final String SUB_VHF = VECTOR_PREFIX + "SUB_VHF" + POSTFIX;
2327     static {
2328         vectorNode(SUB_VHF, "SubVHF", TYPE_SHORT);
2329     }
2330 
2331     public static final String SUB_VF = VECTOR_PREFIX + "SUB_VF" + POSTFIX;
2332     static {
2333         vectorNode(SUB_VF, "SubVF", TYPE_FLOAT);
2334     }
2335 
2336     public static final String SUB_VD = VECTOR_PREFIX + "SUB_VD" + POSTFIX;
2337     static {
2338         vectorNode(SUB_VD, "SubVD", TYPE_DOUBLE);
2339     }
2340 
2341     public static final String SUBTYPE_CHECK = PREFIX + "SUBTYPE_CHECK" + POSTFIX;
2342     static {
2343         String regex = START + "SubTypeCheck" + MID + END;
2344         macroNodes(SUBTYPE_CHECK, regex);
2345     }
2346 
2347     public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
2348     static {
2349         trapNodes(TRAP, "reason");
2350     }
2351 
2352     public static final String DIV_HF = PREFIX + "DIV_HF" + POSTFIX;
2353     static {
2354         beforeMatchingNameRegex(DIV_HF, "DivHF");
2355     }
2356 
2357     public static final String UDIV_I = PREFIX + "UDIV_I" + POSTFIX;
2358     static {
2359         beforeMatchingNameRegex(UDIV_I, "UDivI");
2360     }
2361 
2362     public static final String UDIV_L = PREFIX + "UDIV_L" + POSTFIX;
2363     static {
2364         beforeMatchingNameRegex(UDIV_L, "UDivL");

3338     }
3339 
3340     public static final String REPLICATE_HF_IMM8 = PREFIX + "REPLICATE_HF_IMM8" + POSTFIX;
3341     static {
3342         machOnlyNameRegex(REPLICATE_HF_IMM8, "replicateHF_imm8_gt128b");
3343     }
3344 
3345     public static final String OPAQUE_CONSTANT_BOOL = PREFIX + "OPAQUE_CONSTANT_BOOL" + POSTFIX;
3346     static {
3347         beforeMatchingNameRegex(OPAQUE_CONSTANT_BOOL, "OpaqueConstantBool");
3348     }
3349 
3350     /*
3351      * Utility methods to set up IR_NODE_MAPPINGS.
3352      */
3353 
3354     /**
3355      * Apply {@code regex} on all machine independent ideal graph phases up to and including
3356      * {@link CompilePhase#BEFORE_MATCHING}.
3357      */
3358     public static void beforeMatching(String irNodePlaceholder, String regex) {
3359         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3360     }
3361 
3362     /**
3363      * Apply {@code irNodeRegex} as regex for the IR node name on all machine independent ideal graph phases up to and
3364      * including {@link CompilePhase#BEFORE_MATCHING}.
3365      */
3366     private static void beforeMatchingNameRegex(String irNodePlaceholder, String irNodeRegex) {
3367         String regex = START + irNodeRegex + MID + END;
3368         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3369     }
3370 
3371     /**
3372      * Apply {@code irNodeRegex} as regex for the IR vector node name on all machine independent ideal graph phases up to and
3373      * including {@link CompilePhase#BEFORE_MATCHING}. Since this is a vector node, we can also check the vector element
3374      * type {@code typeString} and the vector size (number of elements), {@see VECTOR_SIZE}.
3375      */
3376     private static void vectorNode(String irNodePlaceholder, String irNodeRegex, String typeString) {
3377         TestFramework.check(isVectorIRNode(irNodePlaceholder), "vectorNode: failed prefix check for irNodePlaceholder "
3378                                                                + irNodePlaceholder + " -> did you use VECTOR_PREFIX?");
3379         // IS_REPLACED is later replaced with the specific type and size of the vector.
3380         String regex = START + irNodeRegex + MID  + IS_REPLACED + END;
3381         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3382         VECTOR_NODE_TYPE.put(irNodePlaceholder, typeString);
3383     }
3384 
3385     /**
3386      * Apply {@code regex} on all ideal graph phases up to and including {@link CompilePhase#BEFORE_MACRO_EXPANSION}.
3387      */
3388     private static void macroNodes(String irNodePlaceholder, String regex) {
3389         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.BEFORE_MACRO_EXPANSION, regex,
3390                                                                           CompilePhase.BEFORE_STRINGOPTS,
3391                                                                           CompilePhase.BEFORE_MACRO_EXPANSION));
3392     }
3393 
3394     private static void callOfNodes(String irNodePlaceholder, String callRegex, String calleeRegex) {
3395         String regex = START + callRegex + MID + calleeRegex + END;
3396         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
3397     }
3398 
3399     /**
3400      * Apply {@code regex} on all machine dependant ideal graph phases (i.e. on the mach graph) starting from
3401      * {@link CompilePhase#MATCHING}.
3402      */
3403     public static void optoOnly(String irNodePlaceholder, String regex) {
3404         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.OPTO_ASSEMBLY, regex));
3405     }
3406 
3407     private static void machOnly(String irNodePlaceholder, String regex) {
3408         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3409     }
3410 
3411     private static void machOnlyNameRegex(String irNodePlaceholder, String irNodeRegex) {
3412         String regex = START + irNodeRegex + MID + END;
3413         IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.MACH, regex));
3414     }
3415 
3416     /**
3417      * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#AFTER_CLOOPS}.
3418      */
3419     private static void fromAfterCountedLoops(String irNodePlaceholder, String regex) {
3420         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3421                                                                           CompilePhase.AFTER_CLOOPS,
3422                                                                           CompilePhase.FINAL_CODE));
3423     }

3477     // @ptrtype:fully/qualified/package/name/to/TheClass:ptrlattice+12
3478     // with ptrtype being the kind of the type such as instptr, aryptr, etc, and ptrlattice being
3479     // the kind of the value such as BotPTR, NotNull, etc.
3480     // And variation:
3481     // - after ptrtype, we can have "stable:" or other labels, with optional space after ':'
3482     // - the class can actually be a nested class, with $ separator (and it must be ok to give only the deepest one
3483     // - after the class name, we can have a comma-separated list of implemented interfaces enclosed in parentheses
3484     // Worst case, it can be something like:
3485     // @bla: bli:a/b/c$d$e (f/g,h/i/j):NotNull+24
3486 
3487     // @ matches the start character of the pattern
3488     // (\w+: ?)+ tries to match the pattern 'ptrtype:' or 'stable:' with optional trailing whitespaces
3489     // [\\w/\\$] tries to match the pattern such as 'a/b/', 'a/b', or '/b' but also nested class such as '$c' or '$c$d'
3490     // \b asserts that the next character is a word character
3491     private static final String LOAD_STORE_PREFIX = "@(\\w+: ?)+[\\w/\\$]*\\b";
3492     // ( \([^\)]+\))? tries to match the pattern ' (f/g,h/i/j)'
3493     // :\w+ tries to match the pattern ':NotNull'
3494     // .* tries to match the remaining of the pattern
3495     private static final String LOAD_STORE_SUFFIX = "( \\([^\\)]+\\))?:\\w+.*";
3496 
3497     private static void loadOfNodes(String irNodePlaceholder, String irNodeRegex, String loadee) {
3498         String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + loadee + LOAD_STORE_SUFFIX + END;
3499         beforeMatching(irNodePlaceholder, regex);
3500     }
3501 
3502     private static void storeOfNodes(String irNodePlaceholder, String irNodeRegex, String storee) {
3503         String regex = START + irNodeRegex + MID + LOAD_STORE_PREFIX + storee + LOAD_STORE_SUFFIX + END;
3504         beforeMatching(irNodePlaceholder, regex);
3505     }
3506 
3507     private static void safepointScalarobjectOfNodes(String irNodePlaceholder, String irNodeRegex) {
3508         String regex = START + irNodeRegex + MID + ".*" + IS_REPLACED + ".*" + END;
3509         beforeMatching(irNodePlaceholder, regex);
3510     }
3511 
3512     private static void fromBeforeRemoveUselessToFinalCode(String irNodePlaceholder, String irNodeRegex) {
3513         String regex = START + irNodeRegex + MID + END;
3514         IR_NODE_MAPPINGS.put(irNodePlaceholder, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
3515                 CompilePhase.BEFORE_REMOVEUSELESS,
3516                 CompilePhase.FINAL_CODE));
3517     }
3518 
3519     /**
3520      * Apply {@code regex} on all ideal graph phases starting from {@link CompilePhase#PHASEIDEALLOOP1} which is the
3521      * first phase that could contain vector nodes from super word.
3522      */
3523     private static void superWordNodes(String irNodePlaceholder, String irNodeRegex) {
< prev index next >