2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
29 #include "firm_common_t.h"
35 * Ideally, this macro would check if size bytes could be read at
36 * pointer p. No generic solution.
38 #define POINTER_READ(p, size) (p)
40 /* returns the kind of the thing */
41 firm_kind get_kind(const void *firm_thing) {
42 return POINTER_READ(firm_thing, sizeof(firm_kind)) ? *(firm_kind *)firm_thing : k_BAD;
45 const char *print_firm_kind(void *firm_thing) {
49 switch (*(firm_kind *)firm_thing) {
50 case k_entity : return "k_entity";
51 case k_type : return "k_type";
52 case k_ir_graph : return "k_ir_graph";
53 case k_ir_node : return "k_ir_node";
54 case k_ir_mode : return "k_ir_mode";
55 case k_ir_op : return "k_ir_op";
56 case k_tarval : return "k_tarval";
57 case k_ir_loop : return "k_ir_loop";
58 case k_ir_compound_graph_path : return "k_ir_compound_graph_path";
59 case k_ir_extblk : return "k_ir_extblk";
60 case k_ir_prog : return "k_ir_prog";
61 case k_ir_region : return "k_ir_region";
65 } /* print_firm_kind */
68 * identify a firm thing
70 void firm_identify_thing(void *X) {
76 switch (get_kind(X)) {
78 printf("BAD: (%p)\n", X);
81 printf("entity: %s: %ld (%p)\n", get_entity_name(X), get_entity_nr(X), X);
84 printf("type: %s %s: %ld (%p)\n", get_type_tpop_name(X), get_type_name(X), get_type_nr(X), X);
87 printf("graph: %s: %ld (%p)\n", get_entity_name(get_irg_entity(X)), get_irg_graph_nr(X), X);
90 printf("irnode: %s%s %ld (%p)\n", get_irn_opname(X), get_mode_name(get_irn_mode(X)), get_irn_node_nr(X), X);
93 printf("mode %s: (%p)\n", get_mode_name(X), X);
96 printf("op %s: (%p)\n", get_op_name(X), X);
99 printf("tarval : "); tarval_printf(X); printf(" (%p)\n", X);
102 printf("loop: with depth %d: (%p)\n", get_loop_depth(X), X);
104 case k_ir_compound_graph_path:
105 printf("compound_graph_path: (%p)\n", X);
108 printf("extended block: (%p)\n", X);
111 printf("irp: (%p)\n", X);
114 printf("region: (%p)\n", X);
117 printf("Cannot identify thing at (%p).\n", X);
119 } /* firm_identify_thing */