8234387: C2: Better support of operands with multiple match rules in AD files
authorjbhateja
Tue, 26 Nov 2019 16:09:23 +0300
changeset 59277 31272cef28e2
parent 59276 94a84abb873b
child 59278 8375560db76b
8234387: C2: Better support of operands with multiple match rules in AD files Reviewed-by: vlivanov, sviswanathan, thartmann, dlong
src/hotspot/cpu/x86/x86_32.ad
src/hotspot/cpu/x86/x86_64.ad
src/hotspot/share/adlc/archDesc.cpp
--- a/src/hotspot/cpu/x86/x86_32.ad	Tue Nov 26 16:09:21 2019 +0300
+++ b/src/hotspot/cpu/x86/x86_32.ad	Tue Nov 26 16:09:23 2019 +0300
@@ -3917,6 +3917,13 @@
   interface(REG_INTER);
 %}
 
+operand eDXRegP(eRegP reg) %{
+  constraint(ALLOC_IN_RC(edx_reg));
+  match(reg);
+  format %{ "EDX" %}
+  interface(REG_INTER);
+%}
+
 operand eSIRegP(eRegP reg) %{
   constraint(ALLOC_IN_RC(esi_reg));
   match(reg);
@@ -8977,7 +8984,7 @@
   %}
 
   ins_pipe(ialu_reg_reg);
-%} 
+%}
 
 //----------Long Instructions------------------------------------------------
 // Add Long Register with Register
--- a/src/hotspot/cpu/x86/x86_64.ad	Tue Nov 26 16:09:21 2019 +0300
+++ b/src/hotspot/cpu/x86/x86_64.ad	Tue Nov 26 16:09:23 2019 +0300
@@ -267,6 +267,9 @@
 // Singleton class for RSI pointer register
 reg_class ptr_rsi_reg(RSI, RSI_H);
 
+// Singleton class for RBP pointer register
+reg_class ptr_rbp_reg(RBP, RBP_H);
+
 // Singleton class for RDI pointer register
 reg_class ptr_rdi_reg(RDI, RDI_H);
 
@@ -3530,6 +3533,16 @@
   interface(REG_INTER);
 %}
 
+operand rbp_RegP()
+%{
+  constraint(ALLOC_IN_RC(ptr_rbp_reg));
+  match(RegP);
+  match(rRegP);
+
+  format %{ %}
+  interface(REG_INTER);
+%}
+
 // Used in rep stosq
 operand rdi_RegP()
 %{
--- a/src/hotspot/share/adlc/archDesc.cpp	Tue Nov 26 16:09:21 2019 +0300
+++ b/src/hotspot/share/adlc/archDesc.cpp	Tue Nov 26 16:09:23 2019 +0300
@@ -245,12 +245,12 @@
     // Construct chain rules
     build_chain_rule(op);
 
-    MatchRule &mrule = *op->_matrule;
-    Predicate *pred  =  op->_predicate;
+    MatchRule *mrule = op->_matrule;
+    Predicate *pred  = op->_predicate;
 
     // Grab the machine type of the operand
     const char  *rootOp    = op->_ident;
-    mrule._machType  = rootOp;
+    mrule->_machType  = rootOp;
 
     // Check for special cases
     if (strcmp(rootOp,"Universe")==0) continue;
@@ -271,10 +271,13 @@
 
     // Find result type for match.
     const char *result      = op->reduce_result();
-    bool        has_root    = false;
 
-    // Construct a MatchList for this entry
-    buildMatchList(op->_matrule, result, rootOp, pred, cost);
+    // Construct a MatchList for this entry.
+    // Iterate over the list to enumerate all match cases for operands with multiple match rules.
+    for (; mrule != NULL; mrule = mrule->_next) {
+      mrule->_machType = rootOp;
+      buildMatchList(mrule, result, rootOp, pred, cost);
+    }
   }
 }