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
27 #include "firm_common_t.h"
33 * Ideally, this macro would check if size bytes could be read at
34 * pointer p. No generic solution.
36 #define POINTER_READ(p, size) (p)
38 /* returns the kind of the thing */
39 firm_kind get_kind(const void *firm_thing) {
40 return POINTER_READ(firm_thing, sizeof(firm_kind)) ? *(firm_kind *)firm_thing : k_BAD;
43 const char *print_firm_kind(void *firm_thing) {
47 switch (*(firm_kind *)firm_thing) {
48 case k_entity : return "k_entity";
49 case k_type : return "k_type";
50 case k_ir_graph : return "k_ir_graph";
51 case k_ir_node : return "k_ir_node";
52 case k_ir_mode : return "k_ir_mode";
53 case k_ir_op : return "k_ir_op";
54 case k_tarval : return "k_tarval";
55 case k_ir_loop : return "k_ir_loop";
56 case k_ir_compound_graph_path : return "k_ir_compound_graph_path";
57 case k_ir_extblk : return "k_ir_extblk";
58 case k_ir_prog : return "k_ir_prog";
59 case k_ir_region : return "k_ir_region";
63 } /* print_firm_kind */
66 * identify a firm thing
68 void firm_identify_thing(void *X) {
74 switch (get_kind(X)) {
76 printf("BAD: (%p)\n", X);
79 printf("entity: %s: %ld (%p)\n", get_entity_name(X), get_entity_nr(X), X);
82 printf("type: %s %s: %ld (%p)\n", get_type_tpop_name(X), get_type_name(X), get_type_nr(X), X);
85 printf("graph: %s: %ld (%p)\n", get_entity_name(get_irg_entity(X)), get_irg_graph_nr(X), X);
88 printf("irnode: %s%s %ld (%p)\n", get_irn_opname(X), get_mode_name(get_irn_mode(X)), get_irn_node_nr(X), X);
91 printf("mode %s: (%p)\n", get_mode_name(X), X);
94 printf("op %s: (%p)\n", get_op_name(X), X);
97 printf("tarval : "); tarval_printf(X); printf(" (%p)\n", X);
100 printf("loop: with depth %d: (%p)\n", get_loop_depth(X), X);
102 case k_ir_compound_graph_path:
103 printf("compound_graph_path: (%p)\n", X);
106 printf("extended block: (%p)\n", X);
109 printf("irp: (%p)\n", X);
112 printf("region: (%p)\n", X);
115 printf("Cannot identify thing at (%p).\n", X);
117 } /* firm_identify_thing */