8234394: C2: Dynamic register class support in ADLC
authorjbhateja
Tue, 26 Nov 2019 16:09:25 +0300
changeset 59278 8375560db76b
parent 59277 31272cef28e2
child 59279 f9905e7c96aa
8234394: C2: Dynamic register class support in ADLC Reviewed-by: vlivanov, sviswanathan, thartmann, kvn
src/hotspot/share/adlc/adlparse.cpp
src/hotspot/share/adlc/archDesc.cpp
src/hotspot/share/adlc/formsopt.cpp
src/hotspot/share/adlc/formsopt.hpp
src/hotspot/share/adlc/output_c.cpp
--- a/src/hotspot/share/adlc/adlparse.cpp	Tue Nov 26 16:09:23 2019 +0300
+++ b/src/hotspot/share/adlc/adlparse.cpp	Tue Nov 26 16:09:25 2019 +0300
@@ -123,6 +123,7 @@
     parse_err(SEMERR, "Did not declare 'register' definitions");
   }
   regBlock->addSpillRegClass();
+  regBlock->addDynamicRegClass();
 
   // Done with parsing, check consistency.
 
--- a/src/hotspot/share/adlc/archDesc.cpp	Tue Nov 26 16:09:23 2019 +0300
+++ b/src/hotspot/share/adlc/archDesc.cpp	Tue Nov 26 16:09:25 2019 +0300
@@ -808,6 +808,8 @@
     return "RegMask::Empty";
   } else if (strcmp(reg_class_name,"stack_slots")==0) {
     return "(Compile::current()->FIRST_STACK_mask())";
+  } else if (strcmp(reg_class_name, "dynamic")==0) {
+    return "*_opnds[0]->in_RegMask(0)";
   } else {
     char       *rc_name = toUpper(reg_class_name);
     const char *mask    = "_mask";
@@ -870,7 +872,7 @@
   }
 
   // Instructions producing 'Universe' use RegMask::Empty
-  if( strcmp(result,"Universe")==0 ) {
+  if (strcmp(result,"Universe") == 0) {
     return "RegMask::Empty";
   }
 
--- a/src/hotspot/share/adlc/formsopt.cpp	Tue Nov 26 16:09:23 2019 +0300
+++ b/src/hotspot/share/adlc/formsopt.cpp	Tue Nov 26 16:09:25 2019 +0300
@@ -80,6 +80,15 @@
   _regClass.Insert(rc_name,reg_class);
 }
 
+// Called after parsing the Register block.  Record the register class
+// for operands which are overwritten after matching.
+void RegisterForm::addDynamicRegClass() {
+  const char *rc_name = "dynamic";
+  RegClass* reg_class = new RegClass(rc_name);
+  reg_class->set_stack_version(false);
+  _rclasses.addName(rc_name);
+  _regClass.Insert(rc_name,reg_class);
+}
 
 // Provide iteration over all register definitions
 // in the order used by the register allocator
--- a/src/hotspot/share/adlc/formsopt.hpp	Tue Nov 26 16:09:23 2019 +0300
+++ b/src/hotspot/share/adlc/formsopt.hpp	Tue Nov 26 16:09:25 2019 +0300
@@ -104,6 +104,7 @@
 
   AllocClass *addAllocClass(char *allocName);
   void        addSpillRegClass();
+  void        addDynamicRegClass();
 
   // Provide iteration over all register definitions
   // in the order used by the register allocator
--- a/src/hotspot/share/adlc/output_c.cpp	Tue Nov 26 16:09:23 2019 +0300
+++ b/src/hotspot/share/adlc/output_c.cpp	Tue Nov 26 16:09:25 2019 +0300
@@ -2781,6 +2781,8 @@
       // Return the sole RegMask.
       if (strcmp(first_reg_class, "stack_slots") == 0) {
         fprintf(fp,"  return &(Compile::current()->FIRST_STACK_mask());\n");
+      } else if (strcmp(first_reg_class, "dynamic") == 0) {
+        fprintf(fp,"  return &RegMask::Empty;\n");
       } else {
         const char* first_reg_class_to_upper = toUpper(first_reg_class);
         fprintf(fp,"  return &%s_mask();\n", first_reg_class_to_upper);