This is the mail archive of the gcc-patches@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]

help with insn-emit.c debugging


For those cases when you want to know which splitter it is that
was responsible for lossage in gen_split_1009.  Not quite as
good as #line numbers, but still an improvement.


r~


        * genemit.c (gen_insn): Print file:lineno comment before function.
        (main): likewise.
        * gensupport.c (struct queue_elem): Add filename member.
        (queue_pattern): Initialize it; update all callers.
        (process_include): Don't free filename.
        (read_md_rtx): Set read_rtx_filename.

Index: genemit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/genemit.c,v
retrieving revision 1.73
diff -c -p -d -u -r1.73 genemit.c
--- genemit.c	20 Mar 2002 21:58:52 -0000	1.73
+++ genemit.c	23 May 2002 21:27:25 -0000
@@ -59,7 +59,7 @@ static void max_operand_1		PARAMS ((rtx)
 static int max_operand_vec		PARAMS ((rtx, int));
 static void print_code			PARAMS ((RTX_CODE));
 static void gen_exp			PARAMS ((rtx, enum rtx_code, char *));
-static void gen_insn			PARAMS ((rtx));
+static void gen_insn			PARAMS ((rtx, int));
 static void gen_expand			PARAMS ((rtx));
 static void gen_split			PARAMS ((rtx));
 static void output_add_clobbers		PARAMS ((void));
@@ -297,8 +297,9 @@ gen_exp (x, subroutine_type, used)
 /* Generate the `gen_...' function for a DEFINE_INSN.  */
 
 static void
-gen_insn (insn)
+gen_insn (insn, lineno)
      rtx insn;
+     int lineno;
 {
   int operands;
   int i;
@@ -383,6 +384,8 @@ gen_insn (insn)
   if (XSTR (insn, 0)[0] == 0 || XSTR (insn, 0)[0] == '*')
     return;
 
+  printf ("/* %s:%d */\n", read_rtx_filename, lineno);
+
   /* Find out how many operands this function has,
      and also whether any of them have register constraints.  */
   register_constraints = 0;
@@ -838,7 +841,7 @@ from the machine description file `md'. 
   printf ("#include \"toplev.h\"\n");
   printf ("#include \"ggc.h\"\n\n");
   printf ("#define FAIL return (end_sequence (), _val)\n");
-  printf ("#define DONE return (_val = gen_sequence (), end_sequence (), _val)\n");
+  printf ("#define DONE return (_val = gen_sequence (), end_sequence (), _val)\n\n");
 
   /* Read the machine description.  */
 
@@ -852,25 +855,28 @@ from the machine description file `md'. 
 
       switch (GET_CODE (desc))
 	{
-	  case DEFINE_INSN:
-	      gen_insn (desc);
-	      break;
+	case DEFINE_INSN:
+	  gen_insn (desc, line_no);
+	  break;
 
-	  case DEFINE_EXPAND:
-	      gen_expand (desc);
-	      break;
+	case DEFINE_EXPAND:
+	  printf ("/* %s:%d */\n", read_rtx_filename, line_no);
+	  gen_expand (desc);
+	  break;
 
-	  case DEFINE_SPLIT:
-	      gen_split (desc);
-	      break;
+	case DEFINE_SPLIT:
+	  printf ("/* %s:%d */\n", read_rtx_filename, line_no);
+	  gen_split (desc);
+	  break;
 
-	  case DEFINE_PEEPHOLE2:
-	      gen_split (desc);
-	      break;
+	case DEFINE_PEEPHOLE2:
+	  printf ("/* %s:%d */\n", read_rtx_filename, line_no);
+	  gen_split (desc);
+	  break;
 
-	  default:
-	      break;
-	 }
+	default:
+	  break;
+	}
       ++insn_index_number;
     }
 
Index: gensupport.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gensupport.c,v
retrieving revision 1.31
diff -c -p -d -u -r1.31 gensupport.c
--- gensupport.c	20 May 2002 01:17:14 -0000	1.31
+++ gensupport.c	23 May 2002 21:27:25 -0000
@@ -50,6 +50,7 @@ static char *base_dir = NULL;
 struct queue_elem
 {
   rtx data;
+  const char *filename;
   int lineno;
   struct queue_elem *next;
 };
@@ -63,7 +64,8 @@ static struct queue_elem **define_cond_e
 static struct queue_elem *other_queue;
 static struct queue_elem **other_tail = &other_queue;
 
-static void queue_pattern PARAMS ((rtx, struct queue_elem ***, int));
+static void queue_pattern PARAMS ((rtx, struct queue_elem ***,
+				   const char *, int));
 
 /* Current maximum length of directory names in the search path
    for include files.  (Altered as we get more of them.)  */
@@ -131,13 +133,15 @@ gen_rtx_CONST_INT (mode, arg)
 /* Queue PATTERN on LIST_TAIL.  */
 
 static void
-queue_pattern (pattern, list_tail, lineno)
+queue_pattern (pattern, list_tail, filename, lineno)
      rtx pattern;
      struct queue_elem ***list_tail;
+     const char *filename;
      int lineno;
 {
   struct queue_elem *e = (struct queue_elem *) xmalloc (sizeof (*e));
   e->data = pattern;
+  e->filename = filename;
   e->lineno = lineno;
   e->next = NULL;
   **list_tail = e;
@@ -248,11 +252,13 @@ process_include (desc, lineno)
       process_rtx (desc, lineno);
     }
 
+  /* Do not free pathname.  It is attached to the various rtx queue
+     elements.  */
+
   read_rtx_filename = old_filename;
   read_rtx_lineno = old_lineno;
 
   fclose (input_file);
-  free (pathname);
 }
 
 /* Process a top level rtx in some way, queueing as appropriate.  */
@@ -265,15 +271,15 @@ process_rtx (desc, lineno)
   switch (GET_CODE (desc))
     {
     case DEFINE_INSN:
-      queue_pattern (desc, &define_insn_tail, lineno);
+      queue_pattern (desc, &define_insn_tail, read_rtx_filename, lineno);
       break;
 
     case DEFINE_COND_EXEC:
-      queue_pattern (desc, &define_cond_exec_tail, lineno);
+      queue_pattern (desc, &define_cond_exec_tail, read_rtx_filename, lineno);
       break;
 
     case DEFINE_ATTR:
-      queue_pattern (desc, &define_attr_tail, lineno);
+      queue_pattern (desc, &define_attr_tail, read_rtx_filename, lineno);
       break;
 
     case INCLUDE:
@@ -324,13 +330,13 @@ process_rtx (desc, lineno)
 	XVEC (desc, 4) = attr;
 
 	/* Queue them.  */
-	queue_pattern (desc, &define_insn_tail, lineno);
-	queue_pattern (split, &other_tail, lineno);
+	queue_pattern (desc, &define_insn_tail, read_rtx_filename, lineno);
+	queue_pattern (split, &other_tail, read_rtx_filename, lineno);
 	break;
       }
 
     default:
-      queue_pattern (desc, &other_tail, lineno);
+      queue_pattern (desc, &other_tail, read_rtx_filename, lineno);
       break;
     }
 }
@@ -850,7 +856,8 @@ process_one_cond_exec (ce_elem)
 	 patterns into the define_insn chain just after their generator
 	 is something we'll have to experiment with.  */
 
-      queue_pattern (insn, &other_tail, insn_elem->lineno);
+      queue_pattern (insn, &other_tail, insn_elem->filename,
+		     insn_elem->lineno);
     }
 }
 
@@ -1011,6 +1018,7 @@ read_md_rtx (lineno, seqnr)
   elem = *queue;
   *queue = elem->next;
   desc = elem->data;
+  read_rtx_filename = elem->filename;
   *lineno = elem->lineno;
   *seqnr = sequence_num;
 


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