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]

[patch] naming unnamed insns



An idea I had while trying to debug some rtx dumps and generated
assembler.  Easier than counting patterns to find "movsi-5".

2000-11-15  DJ Delorie  <dj@redhat.com>

	* rtl.c (read_rtx): Provide suitable names for unnamed
	define_insn and define_insn_and_split patterns, based on file
	and line numbers.


Index: rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.c,v
retrieving revision 1.81
diff -p -2 -r1.81  rtl.c
*** rtl.c	2000/10/29 19:34:52	1.81
--- rtl.c	2000/11/16 00:43:26
*************** read_rtx (infile)
*** 1039,1042 ****
--- 1039,1043 ----
  	  int saw_paren = 0;
  	  register char *stringbuf;
+ 	  int saw_anything = 0;
  
  	  c = read_skip_spaces (infile);
*************** read_rtx (infile)
*** 1071,1074 ****
--- 1072,1097 ----
  
  	      obstack_1grow (&rtl_obstack, c);
+ 	      saw_anything = 1;
+ 	    }
+ 
+ 	  /* For insn patterns, we want to provide a default name
+ 	     based on the file and line, like "*foo.md:12", if the
+ 	     given name is blank.  These are only for define_insn and
+ 	     define_insn_and_split, to aid debugging.  */
+ 	  if (!saw_anything
+ 	      && i == 0
+ 	      && (GET_CODE (return_rtx) == DEFINE_INSN
+ 		  || GET_CODE (return_rtx) == DEFINE_INSN_AND_SPLIT))
+ 	    {
+ 	      char line_name[20];
+ 	      const char *fn = (read_rtx_filename ? read_rtx_filename : "rtx");
+ 	      char *slash;
+ 	      for (slash = fn; *slash; slash ++)
+ 		if (*slash == '/' || *slash == '\\' || *slash == ':')
+ 		  fn = slash + 1;
+ 	      obstack_1grow (&rtl_obstack, '*');
+ 	      obstack_grow (&rtl_obstack, fn, strlen (fn));
+ 	      sprintf (line_name, ":%d", read_rtx_lineno);
+ 	      obstack_grow (&rtl_obstack, line_name, strlen (line_name));
  	    }
  

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