This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug inline-asm/68843] ICE with "u" input constraint


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68843

--- Comment #6 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
How about this?
I think tt should fix both issues.


Index: reg-stack.c
===================================================================
--- reg-stack.c (Revision 231598)
+++ reg-stack.c (Arbeitskopie)
@@ -461,6 +461,7 @@

   char reg_used_as_output[FIRST_PSEUDO_REGISTER];
   char implicitly_dies[FIRST_PSEUDO_REGISTER];
+  char explicitly_used[FIRST_PSEUDO_REGISTER];

   rtx *clobber_reg = 0;
   int n_inputs, n_outputs;
@@ -568,6 +569,7 @@
      popped.  */

   memset (implicitly_dies, 0, sizeof (implicitly_dies));
+  memset (explicitly_used, 0, sizeof (explicitly_used));
   for (i = n_outputs; i < n_outputs + n_inputs; i++)
     if (STACK_REG_P (recog_data.operand[i]))
       {
@@ -581,6 +583,8 @@

        if (j < n_clobbers || op_alt[i].matches >= 0)
          implicitly_dies[REGNO (recog_data.operand[i])] = 1;
+       else if (reg_class_size[(int) op_alt[i].cl] == 1)
+         explicitly_used[REGNO (recog_data.operand[i])] = 1;
       }

   /* Search for first non-popped reg.  */
@@ -600,6 +604,23 @@
       malformed_asm = 1;
     }

+  /* Search for first not-explicitly used reg.  */
+  for (i = FIRST_STACK_REG; i < LAST_STACK_REG + 1; i++)
+    if (! implicitly_dies[i] && ! explicitly_used[i])
+      break;
+
+  /* If there are any other explicitly used regs, that's an error.  */
+  for (; i < LAST_STACK_REG + 1; i++)
+    if (explicitly_used[i])
+      break;
+
+  if (i != LAST_STACK_REG + 1)
+    {
+      error_for_asm (insn,
+                    "explicitly used regs must be grouped at top of stack");
+      malformed_asm = 1;
+    }
+
   /* Enforce rule #3: If any input operand uses the "f" constraint, all
      output constraints must use the "&" earlyclobber.

@@ -607,7 +628,7 @@
      record any earlyclobber.  */

   for (i = n_outputs; i < n_outputs + n_inputs; i++)
-    if (op_alt[i].matches == -1)
+    if (op_alt[i].matches == -1 && STACK_REG_P (recog_data.operand[i]))
       {
        int j;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]