diff options
author | Søren Sandmann Pedersen <ssp@l3000.localdomain> | 2011-03-27 12:02:04 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@l3000.localdomain> | 2011-03-27 13:31:09 -0400 |
commit | cc8358022bd6f173a629ab49472eadcd8fd8d87c (patch) | |
tree | a0e7fdc5ccefad9158d87d51fb391c6f59f25d09 | |
parent | e1d9586ba3daab2690ff0077b738f3ead3665650 (diff) |
Some more debug spew
-rw-r--r-- | main.c | 8 | ||||
-rw-r--r-- | node.c | 15 | ||||
-rw-r--r-- | optimize.c | 25 |
3 files changed, 35 insertions, 13 deletions
@@ -502,7 +502,7 @@ dump_type_spec (ast_type_spec_t *type_spec) } } -static void +void real_dump_graph (node_t *node) { while (node) @@ -512,7 +512,7 @@ real_dump_graph (node_t *node) switch (node->common.type) { case NODE_GOTO: - g_print (" goto %p\n", node->goto_.label); + g_print ("%p goto %p\n", node, node->goto_.label); break; case NODE_DYN_GOTO: g_print (" dyn goto\n"); @@ -568,13 +568,13 @@ real_dump_graph (node_t *node) g_print (" store_array\n"); break; case NODE_LOAD: - g_print (" load %s\n", node->load.definition->name); + g_print ("%p load %s\n", node, node->load.definition->name); break; case NODE_LOAD_IND: g_print (" load_ind\n"); break; case NODE_LOAD_ARRAY: - g_print (" load_array\n"); + g_print ("%p load_array\n", node); break; case NODE_NOP: g_print ("%p nop\n", node); @@ -17,10 +17,23 @@ */ #include "ast.h" +static void +node_unlink (node_t *node) +{ + if (node->common.prev) + node->common.prev->common.next = node->common.next; + if (node->common.next) + node->common.next->common.prev = node->common.prev; + node->common.prev = NULL; + node->common.next = NULL; +} + node_t * node_insert_after (node_t *node, node_t *pred) { + node_unlink (node); + node->common.next = pred->common.next; if (pred->common.next) pred->common.next->common.prev = node; @@ -40,6 +53,8 @@ node_new (node_type_t type, new->common.type = type; new->common.ast = ast; + new->common.next = NULL; + new->common.prev = NULL; if (node) node_insert_after (new, node); @@ -410,9 +410,7 @@ optimize (ast_t *ast) { GList *list; node_t **node = NULL; -#if 0 - ast_program_t *p = &ast->program; -#endif + node_t **entry = NULL; for (list = ast->common.children->head; list != NULL; list = list->next) optimize (list->data); @@ -421,34 +419,43 @@ optimize (ast_t *ast) { ast_program_t *program = &ast->program; - node = &(program->enter); + entry = &(program->enter); } else if (ast_is (ast, AST_DEFINITION, AST_FUNCTION_DEFINITION)) { ast_function_definition_t *function = &ast->definition.function; - node = &(function->enter); + entry = &(function->enter); } - if (node) + if (entry) { gboolean changed; + node = entry; + do { #if 0 - dump_graph (p); + real_dump_graph (*entry); #endif changed = FALSE; *node = peephole (*node, &changed); + +#if 0 + real_dump_graph (*entry); + + g_print ("-=-=-=- nops \n"); +#endif + *node = remove_nops (*node, &changed); #if 0 - dump_graph (p); + real_dump_graph (*entry); - g_print ("-----------------------------------------------------"); + g_print ("---------------done----------------------------------\n"); #endif } while (changed); |