public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, RFC] Dumping expanded MD files
@ 2012-11-22 17:49 Kirill Yukhin
  2012-11-23  9:26 ` Mike Stump
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Kirill Yukhin @ 2012-11-22 17:49 UTC (permalink / raw)
  To: Richard Henderson, Jakub Jelinek, gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 1004 bytes --]

Hi folks,

This patch adds an utility for dumping MD-files after iterators and
define_substs expanding. The new utility is named genmddump and is
built along with other gen* programs.

I also added new target to Makefile to invoke this utility. However,
I’m not sure it’s general enough to be added to the top-level
makefile, so your suggestions on where we should place it and how it
should be invoked are welcome.

ChangeLog

2012-11-22  Michael Zolotukhin  <michael.v.zolotukhin@intel.com>

        * Makefile.in: Add targets mddump and mddump-gcc for dumping expanded
         MD-files.

gcc/ChangeLog

2012-11-22  Michael Zolotukhin  <michael.v.zolotukhin@intel.com>

        * Makefile.in: Add targets s-mddump, build/genmddump.o.  Extend
        genprogrtl with mddump.

        * genmddump.c: New.
        * gensupport.c (dump_rtl_queue): New.
        (dump_expanded_md): New.
        * gensupport.h: Declare dump_expanded_md.

What do you guys think?

Thanks, K

[-- Attachment #2: md_expanded_dumping-1.patch --]
[-- Type: application/octet-stream, Size: 5614 bytes --]

diff --git a/Makefile.in b/Makefile.in
index 636b2ba..6a1751e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -971,6 +971,22 @@ all:
 @endif gcc-bootstrap
 	&& :
 
+.PHONY: mddump
+mddump:
+	$(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) mddump-gcc
+
+.PHONY: mddump-gcc
+mddump-gcc: configure-gcc maybe-all-build-libiberty
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS)  \
+	(cd $(HOST_SUBDIR)/gcc && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(EXTRA_GCC_FLAGS) \
+		s-mddump)
+
 .PHONY: all-build
 
 all-build: maybe-all-build-libiberty
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 88b29ea..4509dc7 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -3610,6 +3610,10 @@ insn-preds.c: s-preds; @true
 tm-preds.h: s-preds-h; @true
 tm-constrs.h: s-constrs-h; @true
 
+.PHONY: s-mddump
+s-mddump: $(BUILD_RTL) $(MD_DEPS) build/genmddump$(build_exeext)
+	$(RUN_GEN) build/genmddump$(build_exeext) $(md_file) 2> tmp-mddump.md
+
 s-preds: $(MD_DEPS) build/genpreds$(build_exeext)
 	$(RUN_GEN) build/genpreds$(build_exeext) $(md_file) > tmp-preds.c
 	$(SHELL) $(srcdir)/../move-if-change tmp-preds.c insn-preds.c
@@ -3926,6 +3930,8 @@ build/genrecog.o : genrecog.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
   coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
 build/genhooks.o : genhooks.c $(TARGET_DEF) $(C_TARGET_DEF)		\
   $(COMMON_TARGET_DEF) $(BCONFIG_H) $(SYSTEM_H) errors.h
+build/genmddump.o : genmddump.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
+  coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
 
 # Compile the programs that generate insn-* from the machine description.
 # They are compiled with $(COMPILER_FOR_BUILD), and associated libraries,
@@ -3934,7 +3940,7 @@ build/genhooks.o : genhooks.c $(TARGET_DEF) $(C_TARGET_DEF)		\
 
 # All these programs use the RTL reader ($(BUILD_RTL)).
 genprogrtl = attr attr-common attrtab automata codes conditions config emit \
-	     extract flags opinit output peep preds recog
+	     extract flags opinit output peep preds recog mddump
 $(genprogrtl:%=build/gen%$(build_exeext)): $(BUILD_RTL)
 
 # All these programs use the MD reader ($(BUILD_MD)).
diff --git a/gcc/genmddump.c b/gcc/genmddump.c
new file mode 100644
index 0000000..8823c9a
--- /dev/null
+++ b/gcc/genmddump.c
@@ -0,0 +1,55 @@
+/* Generate code from machine description to recognize rtl as insns.
+   Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1997, 1998,
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010,
+   2012 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+
+/* This program is used to produce tmp-mddump.md, which represents
+   md-file with expanded iterators and after define_subst transformation
+   is performed.
+
+   The only argument of the program is a source md-file (e.g.
+   config/i386/i386.md).  STDERR is used for the program output.  */
+
+#include "bconfig.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "rtl.h"
+#include "errors.h"
+#include "read-md.h"
+#include "gensupport.h"
+
+\f
+extern int main (int, char **);
+
+int
+main (int argc, char **argv)
+{
+  progname = "genmddump";
+
+  if (!init_rtx_reader_args (argc, argv))
+    return (FATAL_EXIT_CODE);
+
+  dump_expanded_md ();
+
+  fflush (stderr);
+  return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
+}
+
diff --git a/gcc/gensupport.c b/gcc/gensupport.c
index 00290b0..4aa11bc 100644
--- a/gcc/gensupport.c
+++ b/gcc/gensupport.c
@@ -2949,3 +2949,24 @@ get_pattern_stats (struct pattern_stats *stats, rtvec pattern)
 				  MAX (stats->max_dup_opno,
 				       stats->max_scratch_opno)) + 1;
 }
+
+/* Dump all entries from queue Q.  */
+static void
+dump_rtl_queue (struct queue_elem **q)
+{
+  struct queue_elem *elem;
+  for (elem = *q; elem ; elem = elem->next)
+    debug_rtx (elem->data);
+}
+
+/* Dump all available rtl queues.  */
+void
+dump_expanded_md (void)
+{
+  dump_rtl_queue (&define_attr_queue);
+  dump_rtl_queue (&define_pred_queue);
+  dump_rtl_queue (&define_insn_queue);
+  dump_rtl_queue (&define_cond_exec_queue);
+  dump_rtl_queue (&define_subst_queue);
+  dump_rtl_queue (&other_queue);
+}
diff --git a/gcc/gensupport.h b/gcc/gensupport.h
index 5ae32d5..4185ffa 100644
--- a/gcc/gensupport.h
+++ b/gcc/gensupport.h
@@ -27,6 +27,7 @@ extern struct obstack *rtl_obstack;
 extern bool init_rtx_reader_args_cb (int, char **, bool (*)(const char *));
 extern bool init_rtx_reader_args (int, char **);
 extern rtx read_md_rtx (int *, int *);
+extern void dump_expanded_md (void);
 
 /* Set this to 0 to disable automatic elision of insn patterns which
    can never be used in this configuration.  See genconditions.c.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-12-04 12:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-22 17:49 [PATCH, RFC] Dumping expanded MD files Kirill Yukhin
2012-11-23  9:26 ` Mike Stump
2012-11-24  3:00 ` Hans-Peter Nilsson
2012-11-27 17:34 ` Richard Henderson
2012-11-29  7:22   ` Michael Zolotukhin
2012-11-29 18:41     ` Richard Henderson
2012-11-29 19:06     ` Richard Henderson
2012-11-30  9:10       ` Michael Zolotukhin
2012-11-30 19:13         ` Richard Henderson
2012-12-04 12:59           ` Kirill Yukhin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).