X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana2%2Fpto.c;h=12547832e5dfd4fc1ebc2f59baddbeaa1d5f2636;hb=7ecdba3dcec0d0ad84f029bb74665da37a5be727;hp=a94b54eb47def96fb888530f9c6f654cf032c33d;hpb=41b022e5d3a77bd3743f6a7b4444b13179dbd2e0;p=libfirm diff --git a/ir/ana2/pto.c b/ir/ana2/pto.c index a94b54eb4..12547832e 100644 --- a/ir/ana2/pto.c +++ b/ir/ana2/pto.c @@ -1,134 +1,171 @@ /* -*- c -*- */ /* - * Project: libFIRM - * File name: ir/ana2/pto.c - * Purpose: Pto - * Author: Florian - * Modified by: - * Created: Mon 18 Oct 2004 - * CVS-ID: $Id$ - * Copyright: (c) 1999-2004 Universität Karlsruhe - * Licence: This file is protected by GPL - GNU GENERAL PUBLIC LICENSE. - */ - - -# ifdef HAVE_CONFIG_H -# include -# endif + Project: libFIRM + File name: ir/ana/pto.c + Purpose: Entry to PTO + Author: Florian + Modified by: + Created: Tue Nov 23 18:37:09 CET 2004 + CVS-ID: $Id$ + Copyright: (c) 1999-2004 Universität Karlsruhe + Licence: This file is protected by the GPL - GNU GENERAL PUBLIC LICENSE. +*/ -# include "pto.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +/* + pto: Entry to PTO +*/ -# include "entity.h" +#ifdef HAVE_STRING_H +# include +#endif +# include "pto.h" # include "irnode_t.h" -# include "irprog_t.h" - -/* # include "eset.h" */ -# include "irgraph.h" -# include "irgwalk.h" -# include "irgmod.h" -# include "irvrfy.h" -# include "trvrfy.h" +# include "irprog.h" # include "xmalloc.h" -# include "irmemwalk.h" +# include "pto_debug.h" +# include "pto_init.h" +# include "pto_name.h" +# include "pto_ctx.h" +# include "ecg.h" -# ifndef TRUE -# define TRUE 1 -# define FALSE 0 -# endif /* not defined TRUE */ +/* Local Defines: */ -/* BEGIN TEST */ -/* -static void pto_node_pre (ir_node *node, void *__unused) -{ - fprintf (stdout, "PRE MEM Node (0x%08x) (%s)\n", - (int) node, - get_op_name (get_irn_op (node))); - } -*/ +/* Local Data Types: */ + +/* Local Variables: */ +extern char *spaces; + +/* Local Prototypes: */ -static void pto_node_post (ir_node *node, void *__unused) +/* =================================================== + Local Implementation: + =================================================== */ + +/* Helper to pto_init */ +static void pto_init_graph_wrapper (graph_info_t *ginfo, void *_unused) { - const opcode op = get_irn_opcode (node); - - - if (iro_Call == op) { - entity *ent = NULL; - ir_graph *graph = NULL; - fprintf (stdout, "POST MEM Call Node (0x%08x)\n", - (int) node); - - ir_node *ptr = get_Call_ptr (node); - - if (iro_Sel == get_irn_opcode (ptr)) { - ent = get_Sel_entity (ptr); - } else if (iro_SymConst == get_irn_opcode (ptr)) { - if (get_SymConst_kind(ptr) == symconst_addr_ent) { - ent = get_SymConst_entity (ptr); - } - } - - if (NULL != ent) { - graph = get_entity_irg (ent); - if (NULL != graph) { - if (! get_irg_is_mem_visited (graph)) { - - fprintf (stdout, " -> visit graph (0x%08x) of \"%s.%s\"\n", - (int) graph, - get_type_name (get_entity_owner (get_irg_entity (graph))), - get_entity_name (get_irg_entity (graph))); - - /* irg_walk_mem (graph, pto_node_pre, pto_node_post, NULL); */ - irg_walk_mem (graph, NULL, pto_node_post, NULL); - } - } - } - } else { - fprintf (stdout, "POST MEM Node (0x%08x) (%s)\n", - (int) node, - get_op_name (get_irn_op (node))); - } + ir_graph *graph = ginfo->graph; + + pto_init_graph (graph); } +/* =================================================== + Exported Implementation: + =================================================== */ +/* Initialise the module (not in pto_init.c because it's the entry to pto) */ +void pto_init (int lvl) +{ + set_dbg_lvl (lvl); -/* END TEST */ + ecg_init (1); -/* - Test irg_walk_mem -*/ -void pto_test_mem () + /* Initialise the name module */ + pto_name_init (); + + /* Initialise the init module */ + pto_init_init (); + + /* allocate ctx-sens names for allocs and set ... etc etc */ + pto_init_type_names (); + + /* initialise all graphs with the static names */ + ecg_iterate_graphs (pto_init_graph_wrapper, NULL); + + /* debugging only */ + spaces = xmalloc (512 * sizeof (char)); + memset (spaces, ' ', 512); + spaces += 511; + *spaces = '\0'; + + /* initialise for the CTX-sensitive ecg-traversal */ + set_curr_ctx (get_main_ctx ()); +} + +void pto_run (void) { - int i; + ir_graph *save; + ir_graph *graph = get_irp_main_irg (); + + pto_reset_graph_pto (graph, 0); + fake_main_args (graph); - fprintf (stdout, "START PTO TEST\n"); + DBGPRINT (1, (stdout, "START PTO\n")); + DBGPRINT (1, (stdout, "START GRAPH (0x%08x) of \"%s.%s\"\n", + (int) graph, + get_type_name (get_entity_owner (get_irg_entity (graph))), + get_entity_name (get_irg_entity (graph)))); - for (i = 0; i < get_irp_n_irgs(); i++) { - ir_graph *graph = get_irp_irg (i); + /* we need some kind of environment here: NULL */ + save = get_current_ir_graph (); + pto_graph (graph, 0, NULL); + set_current_ir_graph (save); + + DBGPRINT (1, (stdout, "END PTO\n")); +} - fprintf (stdout, "START GRAPH (0x%08x) of \"%s.%s\"\n", - (int) graph, - get_type_name (get_entity_owner (get_irg_entity (graph))), - get_entity_name (get_irg_entity (graph))); - /* irg_walk_mem (graph, pto_node_pre, pto_node_post, NULL); */ - irg_walk_mem (graph, NULL, pto_node_post, NULL); - fprintf (stdout, "END GRAPH (0x%08x)\n", (int) graph); - } +/* Dump all interesting stuff to a bunch of files */ +void pto_dump (void) +{ + pto_dump_names ("names.dot"); +} - fprintf (stdout, "END PTO TEST\n"); +void pto_cleanup (void) +{ + /* todo: clean up our own mess */ + spaces -= 511; /* hope that all changes to spaces are + properly nested */ + memset (spaces, 0x00, 512); + free (spaces); + + /* Cleanup the name module */ + pto_name_cleanup (); + /* Cleanup the Init module */ + pto_init_cleanup (); + + /* clean up ecg infos */ + ecg_cleanup (); } /* - * $Log$ - * Revision 1.2 2004/10/21 11:09:37 liekweg - * Moved memwalk stuf into irmemwalk - * Moved lset stuff into lset - * Moved typalise stuff into typalise - * - * Revision 1.1 2004/10/20 14:59:42 liekweg - * Added ana2, added ecg and pto - * - */ + $Log$ + Revision 1.17 2005/01/10 17:26:34 liekweg + fixup printfs, don't put environments on the stack + + Revision 1.16 2004/12/22 14:43:14 beck + made allocations C-like + + Revision 1.15 2004/12/21 14:26:53 beck + removed C99 constructs + + Revision 1.14 2004/12/20 17:41:14 liekweg + __unused -> _unused + + Revision 1.13 2004/12/20 17:34:34 liekweg + fix recursion handling + + Revision 1.12 2004/12/02 16:17:51 beck + fixed config.h include + + Revision 1.11 2004/11/30 15:49:27 liekweg + include 'dump' + + Revision 1.10 2004/11/30 14:46:41 liekweg + Correctly reset main graph; remove dbugging stuff + + Revision 1.9 2004/11/26 16:01:56 liekweg + debugging annotations + + Revision 1.8 2004/11/24 14:54:21 liekweg + Added pto.c as main entry point + + +*/