From: Sebastian Hack Date: Mon, 13 Dec 2004 11:17:45 +0000 (+0000) Subject: Some bugfixes. Added bitset dumping support. X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=e9352f2230ca2eebba43b208aedb4f7094d69669;p=libfirm Some bugfixes. Added bitset dumping support. [r4644] --- diff --git a/ir/ir/irprintf.c b/ir/ir/irprintf.c index 50ec748ce..96ded1ae5 100644 --- a/ir/ir/irprintf.c +++ b/ir/ir/irprintf.c @@ -39,6 +39,7 @@ #include "irprintf.h" #include "pset.h" #include "iterator.h" +#include "bitset.h" /** @@ -322,7 +323,31 @@ static void ir_common_vprintf(const appender_t *app, void *object, { char fmt_str[16]; snprintf(fmt_str, sizeof(fmt_str), "%%%s%c", len_str, ch); - vsnprintf(buf, sizeof(buf), fmt_str, args); + + switch(len) { + case len_char: + case len_short: + case len_int: + { + int arg = va_arg(args, int); + snprintf(buf, sizeof(buf), fmt_str, arg); + } + break; + + case len_long: + { + long arg = va_arg(args, long); + snprintf(buf, sizeof(buf), fmt_str, arg); + } + break; + + case len_long_long: + { + long long arg = va_arg(args, long long); + snprintf(buf, sizeof(buf), fmt_str, arg); + } + break; + } } break; @@ -362,11 +387,29 @@ static void ir_common_vprintf(const appender_t *app, void *object, str = get_mode_name(va_arg(args, ir_mode *)); break; - case 'b': + case 'B': snprintf(buf, sizeof(buf), "%ld", get_irn_node_nr(get_nodes_block(va_arg(args, ir_node *)))); break; + case 'b': + { + const bitset_t *bs = va_arg(args, const bitset_t *); + const char *prefix = ""; + unsigned long i; + + DUMP_CH('['); + for(i = bitset_next_set(bs, 0); i != -1; i = bitset_next_set(bs, i + 1)) { + snprintf(buf, sizeof(buf), "%ld", i); + DUMP_STR(prefix); + DUMP_STR(buf); + prefix = ", "; + } + DUMP_CH(']'); + buf[0] = '\0'; + } + break; + case '*': { iterator_t *it = va_arg(args, iterator_t *); diff --git a/ir/ir/irprintf.h b/ir/ir/irprintf.h index 794554659..7023d2a95 100644 --- a/ir/ir/irprintf.h +++ b/ir/ir/irprintf.h @@ -52,10 +52,11 @@ typedef void (ir_printf_cb_t)(const appender_t *app, void *object, size_t limit, * - @%e An entity name. * - @%E An entity ld_name. * - @%n A full description of a node. - * - @%o The opcode name of an ir node. + * - @%O The opcode name of an ir node. * - @%m The mode name of an ir mode. * - @%N The node number of an ir node. - * - @%b The block node number of the nodes block. + * - @%B The block node number of the nodes block. + * - @%b A bitset. * - @%t A tarval. * * Each of these can be prepended by a '+' which means, that the given