summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2008-09-06 15:23:57 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2008-09-06 15:23:57 +0000
commit6b06353678b47ae92251138f50faba5b545f6a5c (patch)
tree2ababb312ca230f1a70079a2a3ac4e234aaaa970
parent21c8dcf71715bf9163a579b38d62665fe8672412 (diff)
downloadgcc-6b06353678b47ae92251138f50faba5b545f6a5c.tar.gz
2008-09-06 Basile Starynkevitch <basile@starynkevitch.net>
* diagnostic.h (dump_gimple_seq): new exported function. * gimple-pretty-print.c (dump_gimple_seq): previously static function made public. * pretty-print.h (pp_construct_routdata, pp_destruct): declared new functions. * pretty-print.c (pp_construct_routdata, pp_destruct): added new functions. * basilys.h (basilysgc_ppstrbuf_gimple) (basilysgc_ppstrbuf_gimple_seq): declared new functions. * basilys.c (basilysgc_ppstrbuf_gimple) (basilysgc_ppstrbuf_gimple_seq): added new functions (ppgimpleflushdata_st) new structure. (ppgimple_flushrout) new static routine. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@140062 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog.melt15
-rw-r--r--gcc/basilys.c69
-rw-r--r--gcc/basilys.h6
-rw-r--r--gcc/diagnostic.h1
-rw-r--r--gcc/gimple-pretty-print.c2
-rw-r--r--gcc/pretty-print.c25
-rw-r--r--gcc/pretty-print.h6
7 files changed, 123 insertions, 1 deletions
diff --git a/gcc/ChangeLog.melt b/gcc/ChangeLog.melt
index 1341591d628..4b0bda2a818 100644
--- a/gcc/ChangeLog.melt
+++ b/gcc/ChangeLog.melt
@@ -1,4 +1,19 @@
2008-09-06 Basile Starynkevitch <basile@starynkevitch.net>
+ * diagnostic.h (dump_gimple_seq): new exported function.
+ * gimple-pretty-print.c (dump_gimple_seq): previously static
+ function made public.
+ * pretty-print.h (pp_construct_routdata, pp_destruct): declared
+ new functions.
+ * pretty-print.c (pp_construct_routdata, pp_destruct): added new
+ functions.
+ * basilys.h (basilysgc_ppstrbuf_gimple)
+ (basilysgc_ppstrbuf_gimple_seq): declared new functions.
+ * basilys.c (basilysgc_ppstrbuf_gimple)
+ (basilysgc_ppstrbuf_gimple_seq): added new functions
+ (ppgimpleflushdata_st) new structure.
+ (ppgimple_flushrout) new static routine.
+
+2008-09-06 Basile Starynkevitch <basile@starynkevitch.net>
* compiler-probe (comprobe_get_gimple_position)
(added_infopoint_display_gimple): added (int) casts.
diff --git a/gcc/basilys.c b/gcc/basilys.c
index f949ff814f5..17910169b2a 100644
--- a/gcc/basilys.c
+++ b/gcc/basilys.c
@@ -7739,6 +7739,75 @@ end:
#undef dstrv
}
+/* wrapping gimple & tree prettyprinting for MELT debug */
+
+/* the gimple prettyprinter buflushdata */
+#define PPGIMPLE_MAGIC 0x094f2de3
+struct ppgimpleflushdata_st {
+ int gf_magic; /* always PPGIMPLE_MAGIC*/
+ basilys_ptr_t* gf_sbufad; /* adress of pointer to sbuf */
+ pretty_printer gf_pp;
+};
+
+static void ppgimple_flushrout(const char*txt, void*data)
+{
+ struct ppgimpleflushdata_st* fldata = (struct ppgimpleflushdata_st*)data;
+ gcc_assert(fldata->gf_magic == PPGIMPLE_MAGIC);
+ basilysgc_add_strbuf(*fldata->gf_sbufad, txt);
+}
+
+/* pretty print into an sbuf a gimple */
+void basilysgc_ppstrbuf_gimple(basilys_ptr_t sbuf_p, int indentsp, gimple gstmt)
+{
+ struct ppgimpleflushdata_st ppgdat = {0, (basilys_ptr_t*)0};
+#define sbufv curfram__.varptr[0]
+ BASILYS_ENTERFRAME (2, NULL);
+ sbufv = sbuf_p;
+ if (!sbufv || basilys_magic_discr(sbufv) != OBMAG_STRBUF) goto end;
+ if (!gstmt)
+ {
+ basilysgc_add_strbuf(sbufv, "%nullgimple%");
+ goto end;
+ }
+ memset(&ppgdat, 0, sizeof(ppgdat));
+ ppgdat.gf_sbufad = (basilys_ptr_t*)&sbufv;
+ ppgdat.gf_magic = PPGIMPLE_MAGIC;
+ pp_construct_routdata(&ppgdat.gf_pp, NULL, 72, ppgimple_flushrout, (void*)&ppgdat);
+ dump_gimple_stmt(&ppgdat.gf_pp, gstmt, indentsp, TDF_LINENO | TDF_SLIM | TDF_VOPS);
+ pp_flush(&ppgdat.gf_pp);
+ pp_destruct(&ppgdat.gf_pp);
+end:
+ memset(&ppgdat, 0, sizeof(ppgdat));
+ BASILYS_EXITFRAME ();
+#undef sbufv
+}
+
+/* pretty print into an sbuf a gimple seq */
+void basilysgc_ppstrbuf_gimple_seq(basilys_ptr_t sbuf_p, int indentsp, gimple_seq gseq)
+{
+ struct ppgimpleflushdata_st ppgdat = {0, (basilys_ptr_t*)0};
+#define sbufv curfram__.varptr[0]
+ BASILYS_ENTERFRAME (2, NULL);
+ sbufv = sbuf_p;
+ if (!sbufv || basilys_magic_discr(sbufv) != OBMAG_STRBUF) goto end;
+ if (!gseq)
+ {
+ basilysgc_add_strbuf(sbufv, "%nullgimpleseq%");
+ goto end;
+ }
+ memset(&ppgdat, 0, sizeof(ppgdat));
+ ppgdat.gf_sbufad = (basilys_ptr_t*)&sbufv;
+ ppgdat.gf_magic = PPGIMPLE_MAGIC;
+ pp_construct_routdata(&ppgdat.gf_pp, NULL, 72, ppgimple_flushrout, (void*)&ppgdat);
+ dump_gimple_seq(&ppgdat.gf_pp, gseq, indentsp, TDF_LINENO | TDF_SLIM | TDF_VOPS);
+ pp_flush(&ppgdat.gf_pp);
+ pp_destruct(&ppgdat.gf_pp);
+end:
+ memset(&ppgdat, 0, sizeof(ppgdat));
+ BASILYS_EXITFRAME ();
+#undef sbufv
+}
+
/***********************************************************
* generate C code for a basilys unit name
***********************************************************/
diff --git a/gcc/basilys.h b/gcc/basilys.h
index 76166d604e8..e33be95effe 100644
--- a/gcc/basilys.h
+++ b/gcc/basilys.h
@@ -2155,6 +2155,12 @@ basilysgc_strbuf_printf (struct basilysstrbuf_st *strbuf_p, const char *fmt,
void basilysgc_strbuf_add_indent (struct basilysstrbuf_st *strbuf_p,
int indeptn, int linethresh);
+/* pretty print into an sbuf a gimple */
+void basilysgc_ppstrbuf_gimple(basilys_ptr_t sbuf_p, int indentsp, gimple gstmt);
+
+/* pretty print into an sbuf a gimple seq */
+void basilysgc_ppstrbuf_gimple_seq(basilys_ptr_t sbuf_p, int indentsp, gimple_seq gseq);
+
/**************************** misc *****************************/
/* a random generator */
long basilys_lrand (void);
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index 19bc5e9c8d0..c22aac85222 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -232,5 +232,6 @@ extern void print_gimple_seq (FILE *, gimple_seq, int, int);
extern void print_gimple_stmt (FILE *, gimple, int, int);
extern void print_gimple_expr (FILE *, gimple, int, int);
extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
+extern void dump_gimple_seq (pretty_printer *, gimple_seq, int, int);
#endif /* ! GCC_DIAGNOSTIC_H */
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index ae08ce874b2..27a36d05b31 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -116,7 +116,7 @@ print_gimple_expr (FILE *file, gimple g, int spc, int flags)
/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion
spaces and FLAGS as in dump_gimple_stmt. */
-static void
+void
dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
{
gimple_stmt_iterator i;
diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index 999d4ed8174..32d1457ef3a 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -723,6 +723,31 @@ pp_construct (pretty_printer *pp, const char *prefix, int maximum_length)
pp_set_prefix (pp, prefix);
}
+void
+pp_construct_routdata (pretty_printer *pp, const char *prefix, int maximum_length, void (*flushrout)(const char*,void*), void *flushdata)
+{
+ memset (pp, 0, sizeof (pretty_printer));
+ pp->buffer = XCNEW (output_buffer);
+ obstack_init (&pp->buffer->chunk_obstack);
+ obstack_init (&pp->buffer->formatted_obstack);
+ pp->buffer->obstack = &pp->buffer->formatted_obstack;
+ pp->buffer->bufstream = NULL;
+ pp->buffer->buflushroutine = flushrout;
+ pp->buffer->buflushdata = flushdata;
+ pp_line_cutoff (pp) = maximum_length;
+ pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
+ pp_set_prefix (pp, prefix);
+}
+
+
+void pp_destruct(pretty_printer *pp)
+{
+ pp_write_text_to_stream (pp);
+ pp_clear_state (pp);
+ XDELETE(pp->buffer);
+ memset(pp, 0, sizeof (pretty_printer));
+}
+
/* Append a string delimited by START and END to the output area of
PRETTY-PRINTER. No line wrapping is done. However, if beginning a
new line then emit PRETTY-PRINTER's prefix and skip any leading
diff --git a/gcc/pretty-print.h b/gcc/pretty-print.h
index 8fcd7b4c88a..ab64f75467a 100644
--- a/gcc/pretty-print.h
+++ b/gcc/pretty-print.h
@@ -292,7 +292,13 @@ struct pretty_print_info
this macro to return a pointer to the base pretty_printer structure. */
#define pp_base(PP) (PP)
+/* construct a pretty printer on stderr */
extern void pp_construct (pretty_printer *, const char *, int);
+/* construct a pretty printer to a routine with data */
+extern void pp_construct_routdata(pretty_printer *pp, const char *prefix, int maximum_length, void (*flushrout)(const char*,void*), void *flushdata);
+/* destruct a pretty printer */
+extern void pp_destruct (pretty_printer *);
+
extern void pp_base_set_line_maximum_length (pretty_printer *, int);
extern void pp_base_set_prefix (pretty_printer *, const char *);
extern void pp_base_destroy_prefix (pretty_printer *);