From 24a7a5ce654fd8484871fa3337803b820781d1ff Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 17 Dec 2003 16:15:43 +0000 Subject: [PATCH] Added firm_identify_thing() function [r2237] --- ir/common/firm_common.c | 68 ++++++++++++++++++++++++++++++++++------- ir/common/firm_common.h | 3 ++ 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/ir/common/firm_common.c b/ir/common/firm_common.c index ddb17c1fb..bcd54f69e 100644 --- a/ir/common/firm_common.c +++ b/ir/common/firm_common.c @@ -27,17 +27,63 @@ get_kind (const void *firm_thing) { const char* print_firm_kind(void *firm_thing) { - assert (firm_thing); + if (! firm_thing) + return "(NULL)"; + switch (*(firm_kind *)firm_thing) { - case k_entity : { return "k_entity" ;} break; - case k_type : { return "k_type" ;} break; - case k_ir_graph: { return "k_ir_graph";} break; - case k_ir_node : { return "k_ir_node" ;} break; - case k_ir_mode : { return "k_ir_mode" ;} break; - case k_ir_op : { return "k_ir_op" ;} break; - case k_tarval : { return "k_tarval" ;} break; - case k_ir_loop : { return "k_ir_loop" ;} break; - default: break; + case k_entity : return "k_entity"; + case k_type : return "k_type"; + case k_ir_graph : return "k_ir_graph"; + case k_ir_node : return "k_ir_node"; + case k_ir_mode : return "k_ir_mode"; + case k_ir_op : return "k_ir_op"; + case k_tarval : return "k_tarval"; + case k_ir_loop : return "k_ir_loop"; + case k_ir_compound_graph_path : return "k_ir_compound_graph_path"; + default: return ""; + } +} + +/* + * identify a firm thing + */ +void firm_identify_thing(void *X) +{ + firm_kind *p = X; + + if (! p) { + printf("(NULL)\n"); + return; + } + + switch (*p) { + case k_BAD: + printf("BAD: (%p)\n", X); + break; + case k_entity: + printf("entity: %s: %ld (%p)\n", get_entity_name(X), get_entity_nr(X), X); + break; + case k_type: + printf("type: %s %s: %ld (%p)\n", get_type_tpop_name(X), get_type_name(X), get_type_nr(X), X); + break; + case k_ir_graph: + printf("graph: %s: %ld (%p)\n", get_entity_name(get_irg_ent(X)), get_irg_graph_nr(X), X); + break; + case k_ir_node: + printf("irnode: %s%s %ld (%p)\n", get_irn_opname(X), get_mode_name(get_irn_mode(X)), get_irn_node_nr(X), X); + break; + case k_ir_mode: + printf("mode %s: (%p)\n", get_mode_name(X),X); + break; + case k_tarval: + printf("tarval : "); tarval_printf(X); printf(" (%p)\n", X); + break; + case k_ir_loop: + printf("loop: with depth %d: (%p)\n", get_loop_depth(X), X); + break; + case k_ir_op: + case k_ir_compound_graph_path: + default: + printf("Cannot identify thing at (%p).\n", X); } - return ""; } diff --git a/ir/common/firm_common.h b/ir/common/firm_common.h index 25b869081..d77e8f7a6 100644 --- a/ir/common/firm_common.h +++ b/ir/common/firm_common.h @@ -55,4 +55,7 @@ firm_kind get_kind(const void *firm_thing); /** Returns the kind of a thing as a string. */ const char* print_firm_kind(void *firm_thing); +/** Print an identification of a firm thing. */ +void firm_identify_thing(void *X); + # endif /*_FIRM_COMMON_H_ */ -- 2.20.1