This adds log output to avr_address_cost.

Ok for trunk?

Johann

        PR target/50566
        * config/avr/avr-protos.h (avr_log_t): New field address_cost.
        * config/avr/avr.c (avr_address_cost): Use it.
        * config/avr/avr-log.c (avr_log_set_avr_log): Initialize it.
        (avr_log_vadump): Unknown %-codes finish printing.

Index: config/avr/avr-log.c
===================================================================
--- config/avr/avr-log.c	(revision 179378)
+++ config/avr/avr-log.c	(working copy)
@@ -283,7 +283,12 @@ avr_log_vadump (FILE *file, const char *
               abort();
               
             default:
-              fputc (*(fmt-1), file);
+              /* Unknown %-code: Stop printing */
+              
+              fprintf (file, "??? %%%c ???\n", *(fmt-1));
+              fmt = "";
+              
+              break;
             }
           break; /* % */
         }
@@ -318,6 +323,7 @@ avr_log_set_avr_log (void)
       SET_DUMP_DETAIL (legitimize_address);
       SET_DUMP_DETAIL (legitimize_reload_address);
       SET_DUMP_DETAIL (constraints);
+      SET_DUMP_DETAIL (address_cost);
 
 #undef SET_DUMP_DETAIL
     }
Index: config/avr/avr-protos.h
===================================================================
--- config/avr/avr-protos.h	(revision 179378)
+++ config/avr/avr-protos.h	(working copy)
@@ -129,6 +129,7 @@ typedef struct
   unsigned legitimize_address :1;
   unsigned legitimize_reload_address :1;
   unsigned constraints :1;
+  unsigned address_cost :1;
 } avr_log_t;
 
 extern avr_log_t avr_log;
Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c	(revision 179378)
+++ config/avr/avr.c	(working copy)
@@ -6573,23 +6573,33 @@ avr_rtx_costs (rtx x, int codearg, int o
   return done;
 }
 
-/* Calculate the cost of a memory address.  */
+
+/* Implement `TARGET_ADDRESS_COST'.  */
 
 static int
 avr_address_cost (rtx x, bool speed ATTRIBUTE_UNUSED)
 {
+  int cost = 4;
+  
   if (GET_CODE (x) == PLUS
-      && GET_CODE (XEXP (x,1)) == CONST_INT
-      && (REG_P (XEXP (x,0)) || GET_CODE (XEXP (x,0)) == SUBREG)
-      && INTVAL (XEXP (x,1)) >= 61)
-    return 18;
-  if (CONSTANT_ADDRESS_P (x))
+      && CONST_INT_P (XEXP (x, 1))
+      && (REG_P (XEXP (x, 0))
+          || GET_CODE (XEXP (x, 0)) == SUBREG))
+    {
+      if (INTVAL (XEXP (x, 1)) >= 61)
+        cost = 18;
+    }
+  else if (CONSTANT_ADDRESS_P (x))
     {
-      if (optimize > 0 && io_address_operand (x, QImode))
-	return 2;
-      return 4;
+      if (optimize > 0
+          && io_address_operand (x, QImode))
+        cost = 2;
     }
-  return 4;
+
+  if (avr_log.address_cost)
+    avr_edump ("\n%?: %d = %r\n", cost, x);
+  
+  return cost;
 }
 
 /* Test for extra memory constraint 'Q'.

Reply via email to