diff mbox

[AVR] : PR50566: Better log output with -mdeb/-mlog= [3/n]

Message ID 4E85B35C.9050300@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay Sept. 30, 2011, 12:17 p.m. UTC
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.

Comments

Weddington, Eric Sept. 30, 2011, 1:33 p.m. UTC | #1
> -----Original Message-----
> From: Georg-Johann Lay [mailto:avr@gjlay.de]
> Sent: Friday, September 30, 2011 6:18 AM
> To: gcc-patches@gcc.gnu.org
> Cc: Denis Chertykov; Weddington, Eric
> Subject: Re: [Patch,AVR]: PR50566: Better log output with -mdeb/-mlog=
> [3/n]
> 
> 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.

Please commit.

Eric
diff mbox

Patch

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'.