3 * File name: ir/common/firm_common.c
5 * Author: Martin Trapp, Christian Schaefer
6 * Modified by: Goetz Lindenmaier
9 * Copyright: (c) 1998-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
18 #include "firm_common_t.h"
24 * Ideally, this macro would check if size bytes could be read at
25 * pointer p. No generic solution.
27 #define POINTER_READ(p, size) (p)
29 /* returns the kind of the thing */
31 get_kind (const void *firm_thing) {
32 return POINTER_READ(firm_thing, sizeof(firm_kind)) ? *(firm_kind *)firm_thing : k_BAD;
36 const char* print_firm_kind(void *firm_thing) {
40 switch (*(firm_kind *)firm_thing) {
41 case k_entity : return "k_entity";
42 case k_type : return "k_type";
43 case k_ir_graph : return "k_ir_graph";
44 case k_ir_node : return "k_ir_node";
45 case k_ir_mode : return "k_ir_mode";
46 case k_ir_op : return "k_ir_op";
47 case k_tarval : return "k_tarval";
48 case k_ir_loop : return "k_ir_loop";
49 case k_ir_compound_graph_path : return "k_ir_compound_graph_path";
50 case k_ir_extblk : return "k_ir_extblk";
56 * identify a firm thing
58 void firm_identify_thing(void *X)
69 printf("BAD: (%p)\n", X);
72 printf("entity: %s: %ld (%p)\n", get_entity_name(X), get_entity_nr(X), X);
75 printf("type: %s %s: %ld (%p)\n", get_type_tpop_name(X), get_type_name(X), get_type_nr(X), X);
78 printf("graph: %s: %ld (%p)\n", get_entity_name(get_irg_entity(X)), get_irg_graph_nr(X), X);
81 printf("irnode: %s%s %ld (%p)\n", get_irn_opname(X), get_mode_name(get_irn_mode(X)), get_irn_node_nr(X), X);
84 printf("mode %s: (%p)\n", get_mode_name(X), X);
87 printf("op %s: (%p)\n", get_op_name(X), X);
90 printf("tarval : "); tarval_printf(X); printf(" (%p)\n", X);
93 printf("loop: with depth %d: (%p)\n", get_loop_depth(X), X);
95 case k_ir_compound_graph_path:
96 printf("compound_graph_path: (%p)\n", X);
99 printf("extended block: (%p)\n", X);
102 printf("Cannot identify thing at (%p).\n", X);