2 * Copyright (C) 1995-2011 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 * @brief Write text representation of firm to file.
23 * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Hubert Schmidt,
34 #include "irgraph_t.h"
47 static ir_dump_verbosity_t verbosity = dump_verbosity_max;
49 void ir_set_dump_verbosity(ir_dump_verbosity_t new_verbosity)
51 verbosity = new_verbosity;
54 ir_dump_verbosity_t ir_get_dump_verbosity(void)
59 /* Write the irnode and all its attributes to the file passed. */
60 void dump_irnode_to_file(FILE *F, ir_node *n)
65 dump_node_opcode(F, n);
66 fprintf(F, " %ld\n", get_irn_node_nr(n));
68 fprintf(F, " index: %u\n", get_irn_idx(n));
69 if (ir_get_dump_flags() & ir_dump_flag_analysed_types)
70 fprintf (F, " addr: %p\n", (void *)n);
71 fprintf (F, " mode: %s\n", get_mode_name(get_irn_mode(n)));
72 fprintf (F, " visited: %lu\n", get_irn_visited(n));
74 if (irg != get_const_code_irg())
75 fprintf (F, " irg: %s\n", get_ent_dump_name(get_irg_entity(irg)));
77 if (get_irn_pinned(n) == op_pin_state_floats &&
78 get_irg_pinned(get_irn_irg(n)) == op_pin_state_floats) {
79 fprintf(F, " node was pinned in ");
80 dump_node_opcode(F, get_irn_n(n, -1));
81 fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, -1)));
84 fprintf(F, " arity: %d\n", get_irn_arity(n));
85 /* show all predecessor nodes */
86 fprintf(F, " pred nodes:\n");
89 dump_node_opcode(F, get_irn_n(n, -1));
90 fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, -1)));
95 for (i = 0; i < get_irn_arity(n); ++i) {
96 fprintf(F, " %d: %s ", i, is_backedge(n, i) ? "be" : " ");
97 dump_node_opcode(F, get_irn_n(n, i));
98 fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, i)));
102 fprintf(F, " Private Attributes:\n");
105 ir_node *pred = get_Proj_pred(n);
106 long pn = get_Proj_proj(n);
107 fprintf(F, " proj nr: %ld\n", pn);
108 if (is_Switch(pred)) {
109 const ir_switch_table *table = get_Switch_table(pred);
110 size_t n_entries = ir_switch_table_get_n_entries(table);
112 for (i = 0; i < n_entries; ++i) {
113 const ir_switch_table_entry *entry
114 = ir_switch_table_get_entry_const(table, i);
115 if (entry->pn == pn && entry->min != NULL && entry->max != NULL) {
116 ir_tarval *min = entry->min;
117 ir_tarval *max = entry->max;
119 ir_fprintf(F, " switch case %+F .. %+F\n", min, max);
121 ir_fprintf(F, " switch case %+F\n", min);
128 if (is_fragile_op(n)) {
129 fprintf(F, " pinned state: %s\n", get_op_pin_state_name(get_irn_pinned(n)));
130 /* not dumped: frag array */
133 /* This is not nice, output it as a marker in the predecessor list. */
134 if (is_Block(n) || get_irn_op(n) == op_Phi) {
136 fprintf(F, " backedges:");
138 for (i = 0; i < get_irn_arity(n); i++)
139 if (is_backedge(n, i)) { fprintf(F, "%c %d", comma, i); comma = ','; }
143 /* Loop node. Someone else please tell me what's wrong ... */
144 if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO)) {
145 ir_loop *loop = get_irn_loop(n);
147 fprintf(F, " in loop %ld with depth %u\n",
148 get_loop_loop_nr(loop), get_loop_depth(loop));
153 switch (get_irn_opcode(n)) {
155 if (has_Block_entity(n))
156 fprintf(F, " Label: %lu\n", get_entity_label(get_Block_entity(n)));
157 fprintf(F, " block visited: %lu\n", get_Block_block_visited(n));
158 fprintf(F, " block marked: %u\n", get_Block_mark(n));
159 if (is_irg_state(get_irn_irg(n), IR_GRAPH_STATE_CONSISTENT_DOMINANCE)) {
160 fprintf(F, " dom depth %d\n", get_Block_dom_depth(n));
161 fprintf(F, " domtree pre num %u\n", get_Block_dom_tree_pre_num(n));
162 fprintf(F, " max subtree pre num %u\n", get_Block_dom_max_subtree_pre_num(n));
164 if (is_irg_state(get_irn_irg(n), IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE)) {
165 fprintf(F, " pdom depth %d\n", get_Block_postdom_depth(n));
166 fprintf(F, " pdomtree pre num %u\n", get_Block_pdom_tree_pre_num(n));
167 fprintf(F, " max pdomsubtree pre num %u\n", get_Block_pdom_max_subtree_pre_num(n));
170 /* not dumped: graph_arr */
171 /* not dumped: mature */
175 ir_type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
176 ir_fprintf(F, " start of method of type %+F\n", tp);
177 for (i = 0; i < get_method_n_params(tp); ++i)
178 ir_fprintf(F, " param %d type: %+F\n", i, get_method_param_type(tp, i));
181 if (get_Cond_jmp_pred(n) != COND_JMP_PRED_NONE) {
182 fprintf(F, " jump prediction: %s\n",
183 get_cond_jmp_predicate_name(get_Cond_jmp_pred(n)));
187 ir_fprintf(F, " allocating entity of type: %+F\n", get_Alloc_type(n));
188 fprintf(F, " allocating on: the %s\n", (get_Alloc_where(n) == stack_alloc) ? "stack" : "heap");
191 ir_fprintf(F, " freeing entity of type %+F\n", get_Free_type(n));
192 fprintf(F, " allocated on: the %s\n", (get_Free_where(n) == stack_alloc) ? "stack" : "heap");
195 ir_entity *ent = get_Sel_entity(n);
197 fprintf(F, " Selecting entity %s (%ld)\n", get_entity_name(ent), get_entity_nr(ent));
198 ir_fprintf(F, " of type %+F\n", get_entity_type(ent));
199 ir_fprintf(F, " with owner %+F.\n", get_entity_owner(ent));
201 fprintf(F, " <NULL entity>\n");
205 ir_type *tp = get_Call_type(n);
206 if (get_Call_tail_call(n))
207 fprintf(F, " tail call\n");
208 ir_fprintf(F, " calling method of type %+F\n", tp);
209 if (get_unknown_type() != tp) {
211 for (i = 0; i < get_method_n_params(tp); ++i)
212 ir_fprintf(F, " param %d type: %+F\n", i, get_method_param_type(tp, i));
213 for (i = 0; i < get_method_n_ress(tp); ++i)
214 ir_fprintf(F, " result %d type: %+F\n", i, get_method_res_type(tp, i));
216 if (Call_has_callees(n)) {
218 fprintf(F, " possible callees:\n");
219 for (i = 0; i < get_Call_n_callees(n); i++) {
220 ir_fprintf(F, " %zu: %s\n", i, get_ent_dump_name(get_Call_callee(n, i)));
225 ir_fprintf(F, " cast to type: %+F\n", get_Cast_type(n));
228 ir_relation relation = get_Cmp_relation(n);
229 ir_fprintf(F, " relation: %s\n", get_relation_string(relation));
233 ir_type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
234 ir_fprintf(F, " return in method of type %+F\n", tp);
235 for (i = 0; i < get_method_n_ress(tp); ++i) {
236 ir_fprintf(F, " result %d type: %+F\n", i,
237 get_method_res_type(tp, i));
241 switch (get_SymConst_kind(n)) {
242 case symconst_addr_ent:
243 fprintf(F, " kind: addr_ent\n");
244 fprintf(F, " entity: ");
245 dump_entity_to_file(F, get_SymConst_entity(n));
247 case symconst_ofs_ent:
248 fprintf(F, " kind: offset\n");
249 fprintf(F, " entity: ");
250 dump_entity_to_file(F, get_SymConst_entity(n));
252 case symconst_type_tag:
253 fprintf(F, " kind: type_tag\n");
254 fprintf(F, " type: ");
255 dump_type_to_file(F, get_SymConst_type(n));
257 case symconst_type_size:
258 fprintf(F, " kind: size\n");
259 fprintf(F, " type: ");
260 dump_type_to_file(F, get_SymConst_type(n));
262 case symconst_type_align:
263 fprintf(F, " kind: alignment\n");
264 fprintf(F, " type: ");
265 dump_type_to_file(F, get_SymConst_type(n));
267 case symconst_enum_const:
268 fprintf(F, " kind: enumeration\n");
269 fprintf(F, " name: %s\n", get_enumeration_const_name(get_SymConst_enum(n)));
274 fprintf(F, " mode of loaded value: %s\n", get_mode_name_ex(get_Load_mode(n), NULL));
275 fprintf(F, " volatility: %s\n", get_volatility_name(get_Load_volatility(n)));
276 fprintf(F, " align: %s\n", get_align_name(get_Load_unaligned(n)));
279 fprintf(F, " volatility: %s\n", get_volatility_name(get_Store_volatility(n)));
280 fprintf(F, " align: %s\n", get_align_name(get_Store_unaligned(n)));
283 fprintf(F, " compare operation: %s\n", get_relation_string(get_Confirm_relation(n)));
286 const ir_asm_constraint *cons;
290 fprintf(F, " assembler text: %s", get_id_str(get_ASM_text(n)));
291 l = get_ASM_n_input_constraints(n);
294 fprintf(F, "\n inputs: ");
295 cons = get_ASM_input_constraints(n);
296 for (i = 0; i < l; ++i)
297 fprintf(F, "%%%u %s ", cons[i].pos, get_id_str(cons[i].constraint));
299 l = get_ASM_n_output_constraints(n);
302 fprintf(F, "\n outputs: ");
303 cons = get_ASM_output_constraints(n);
304 for (i = 0; i < l; ++i)
305 fprintf(F, "%%%u %s ", cons[i].pos, get_id_str(cons[i].constraint));
307 l = get_ASM_n_clobbers(n);
310 fprintf(F, "\n clobber: ");
311 clobber = get_ASM_clobbers(n);
312 for (i = 0; i < l; ++i)
313 fprintf(F, "%s ", get_id_str(clobber[i]));
315 if (get_irn_pinned(n) != op_pin_state_floats)
316 fprintf(F, "\n volatile");
324 if (get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_consistent ||
325 get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_inconsistent )
326 if (get_irn_typeinfo_type(n) != firm_none_type)
327 ir_fprintf (F, " Analysed type: %s\n", get_irn_typeinfo_type(n));
330 void dump_graph_as_text(FILE *out, ir_graph *irg)
332 fprintf(out, "graph %s\n", get_irg_dump_name(irg));
335 static int need_nl = 1;
337 static bool is_init_string(ir_initializer_t const* const init, ir_type *const type)
339 ir_type *const element_type = get_array_element_type(type);
344 if (!is_Primitive_type(element_type))
347 mode = get_type_mode(element_type);
348 if (!mode_is_int(mode) || get_mode_size_bits(mode) != 8)
351 n = get_initializer_compound_n_entries(init);
352 for (i = 0; i != n; ++i) {
353 ir_initializer_t const* const val = get_initializer_compound_value(init, i);
354 ir_tarval* const tv = get_initializer_tarval_value(val);
357 if (!tarval_is_constant(tv))
360 v = get_tarval_long(tv);
361 if (v != 0 && (v < 0x07 || 0x0D < v) && v != 0x1B && (v < 0x20 || 0x80 <= v) && (v < 0xA0 || 0x100 <= v))
371 static void dump_ir_initializers_to_file(FILE *F, const char *prefix,
372 const ir_initializer_t *initializer,
379 fprintf(F, "\n%s ", prefix);
382 switch (get_initializer_kind(initializer)) {
383 case IR_INITIALIZER_NULL:
384 fprintf(F, "\t = <NOT_SET>");
386 case IR_INITIALIZER_TARVAL:
387 tv = get_initializer_tarval_value(initializer);
388 ir_fprintf(F, "\t = <TV>%F", tv);
390 case IR_INITIALIZER_CONST:
391 value = get_initializer_const_value(initializer);
392 ir_fprintf(F, "\t = %F", value);
394 case IR_INITIALIZER_COMPOUND:
395 if (is_Array_type(type)) {
396 size_t const n = get_initializer_compound_n_entries(initializer);
399 if (is_init_string(initializer, type)) {
400 fprintf(F, "\t[0...%u] = '", (unsigned)n - 1);
401 for (i = 0; i != n; ++i) {
402 ir_initializer_t const* const val = get_initializer_compound_value(initializer, i);
403 ir_tarval* const tv = get_initializer_tarval_value(val);
404 long const v = get_tarval_long(tv);
407 case 0x00: fprintf(F, "\\\\000"); break;
408 case 0x07: fprintf(F, "\\\\a"); break;
409 case 0x08: fprintf(F, "\\\\b"); break;
410 case 0x09: fprintf(F, "\\\\t"); break;
411 case 0x0A: fprintf(F, "\\\\n"); break;
412 case 0x0B: fprintf(F, "\\\\v"); break;
413 case 0x0C: fprintf(F, "\\\\f"); break;
414 case 0x0D: fprintf(F, "\\\\r"); break;
415 case 0x1B: fprintf(F, "\\\\033"); break;
416 case 0x22: fprintf(F, "\\\\\\\""); break;
417 case 0x5C: fprintf(F, "\\\\\\\\"); break;
418 default: fprintf(F, "%c", (unsigned char)v); break;
423 ir_type *const element_type = get_array_element_type(type);
425 for (i = 0; i < n; ++i) {
426 ir_initializer_t *sub_initializer
427 = get_initializer_compound_value(initializer, i);
430 fprintf(F, "\n%s ", prefix);
433 fprintf(F, "[%d]", (int) i);
434 dump_ir_initializers_to_file(F, prefix, sub_initializer, element_type);
439 assert(is_compound_type(type));
440 n = get_compound_n_members(type);
441 for (i = 0; i < n; ++i) {
442 ir_entity *member = get_compound_member(type, i);
443 ir_type *subtype = get_entity_type(member);
444 ir_initializer_t *sub_initializer;
446 assert(i < get_initializer_compound_n_entries(initializer));
448 = get_initializer_compound_value(initializer, i);
451 fprintf(F, "\n%s ", prefix);
454 ir_fprintf(F, ".%F", member);
455 dump_ir_initializers_to_file(F, prefix, sub_initializer, subtype);
460 panic("invalid ir_initializer kind found");
465 static void dump_entity_linkage(FILE *F, const ir_entity *entity)
467 ir_linkage linkage = get_entity_linkage(entity);
469 if (linkage == IR_LINKAGE_DEFAULT) {
470 fprintf(F, " default");
473 if (linkage & IR_LINKAGE_CONSTANT)
474 fprintf(F, " constant");
475 if (linkage & IR_LINKAGE_WEAK)
477 if (linkage & IR_LINKAGE_GARBAGE_COLLECT)
478 fprintf(F, " garbage_collect");
479 if (linkage & IR_LINKAGE_MERGE)
480 fprintf(F, " merge");
481 if (linkage & IR_LINKAGE_HIDDEN_USER)
482 fprintf(F, " hidden_user");
485 static void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, const char *prefix)
487 ir_type *owner, *type;
489 assert(is_entity(ent));
490 owner = get_entity_owner(ent);
491 type = get_entity_type(ent);
492 if (verbosity & dump_verbosity_onlynames) {
493 fprintf(F, "%sentity %s.%s (%ld)\n", prefix, get_compound_name(get_entity_owner(ent)),
494 get_entity_name(ent), get_entity_nr(ent));
498 if (verbosity & dump_verbosity_entattrs) {
499 fprintf(F, "%sentity %s (%ld)\n", prefix, get_entity_name(ent), get_entity_nr(ent));
500 ir_fprintf(F, "%s type: %+F\n", prefix, type);
501 ir_fprintf(F, "%s owner: %+F\n", prefix, owner);
503 if (is_Class_type(get_entity_owner(ent))) {
504 if (get_entity_n_overwrites(ent) > 0) {
506 fprintf(F, "%s overwrites:\n", prefix);
507 for (i = 0; i < get_entity_n_overwrites(ent); ++i) {
508 ir_entity *ov = get_entity_overwrites(ent, i);
509 ir_fprintf(F, "%s %d: %s of class %+F\n", prefix, i,
510 get_entity_name(ov), get_entity_owner(ov));
513 fprintf(F, "%s Does not overwrite other entities.\n", prefix);
515 if (get_entity_n_overwrittenby(ent) > 0) {
517 fprintf(F, "%s overwritten by:\n", prefix);
518 for (i = 0; i < get_entity_n_overwrittenby(ent); ++i) {
519 ir_entity *ov = get_entity_overwrittenby(ent, i);
520 ir_fprintf(F, "%s %d: %s of class %+F\n", prefix, i,
521 get_entity_name(ov), get_entity_owner(ov));
524 fprintf(F, "%s Is not overwritten by other entities.\n",
528 if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
530 fprintf(F, "%s transitive overwrites:\n", prefix);
531 for (ov = get_entity_trans_overwrites_first(ent);
533 ov = get_entity_trans_overwrites_next(ent)) {
534 ir_fprintf(F, "%s : %s of class %+F\n", prefix,
535 get_entity_name(ov), get_entity_owner(ov));
537 fprintf(F, "%s transitive overwritten by:\n", prefix);
538 for (ov = get_entity_trans_overwrittenby_first(ent);
540 ov = get_entity_trans_overwrittenby_next(ent)) {
541 ir_fprintf(F, "%s : %s of class %+F\n", prefix,
542 get_entity_name(ov), get_entity_owner(ov));
547 if (is_Method_type(get_entity_type(ent))) {
548 unsigned mask = get_entity_additional_properties(ent);
549 unsigned cc = get_method_calling_convention(get_entity_type(ent));
550 ir_graph *irg = get_entity_irg(ent);
553 fprintf(F, "%s estimated node count: %u\n", prefix, get_irg_estimated_node_cnt(irg));
554 fprintf(F, "%s maximum node index: %u\n", prefix, get_irg_last_idx(irg));
558 fprintf(F, "%s additional prop: ", prefix);
560 if (mask & mtp_property_const) fputs("const_function, ", F);
561 if (mask & mtp_property_pure) fputs("pure_function, ", F);
562 if (mask & mtp_property_noreturn) fputs("noreturn_function, ", F);
563 if (mask & mtp_property_nothrow) fputs("nothrow_function, ", F);
564 if (mask & mtp_property_naked) fputs("naked_function, ", F);
565 if (mask & mtp_property_malloc) fputs("malloc_function, ", F);
566 if (mask & mtp_property_returns_twice) fputs("weak_function, ", F);
567 if (mask & mtp_property_intrinsic) fputs("intrinsic_function, ", F);
568 if (mask & mtp_property_runtime) fputs("runtime_function, ", F);
569 if (mask & mtp_property_private) fputs("private_function, ", F);
570 if (mask & mtp_property_has_loop) fputs("has_loop_function, ", F);
573 fprintf(F, "%s calling convention: ", prefix);
574 if (cc & cc_reg_param) fputs("regparam, ", F);
575 if (cc & cc_this_call) fputs("thiscall, ", F);
576 if (cc & cc_compound_ret) fputs("compound_ret, ", F);
577 if (cc & cc_frame_on_caller_stk) fputs("frame on caller's stack, ", F);
578 cc &= ~(cc_compound_ret|cc_frame_on_caller_stk);
581 else if (IS_STDCALL(cc))
584 fputs(cc & cc_last_on_top ? "last param on top, " : "first param on top, ", F);
585 fputs(cc & cc_callee_clear_stk ? "callee clear stack" : "caller clear stack", F);
587 fprintf(F, "\n%s vtable number: %u\n", prefix, get_entity_vtable_number(ent));
589 } else { /* no entattrs */
590 ir_fprintf(F, "%s(%3d:%d) %+F: %s", prefix,
591 get_entity_offset(ent), get_entity_offset_bits_remainder(ent),
592 get_entity_type(ent), get_entity_name(ent));
593 if (is_Method_type(get_entity_type(ent))) fputs("(...)", F);
595 if (verbosity & dump_verbosity_accessStats) {
596 dump_entity_linkage(F, ent);
601 if (verbosity & dump_verbosity_entconsts) {
602 if (ent->initializer != NULL) {
603 const ir_initializer_t *initializer = get_entity_initializer(ent);
604 fprintf(F, "\n%s Initializers:", prefix);
606 dump_ir_initializers_to_file(F, prefix, initializer, get_entity_type(ent));
608 } else if (entity_has_compound_ent_values(ent)) {
610 fprintf(F, "%s compound values:", prefix);
611 for (i = 0; i < get_compound_ent_n_values(ent); ++i) {
613 compound_graph_path *path = get_compound_ent_value_path(ent, i);
614 ir_entity *ent0 = get_compound_graph_path_node(path, 0);
615 fprintf(F, "\n%s %3d:%d ", prefix, get_entity_offset(ent0), get_entity_offset_bits_remainder(ent0));
616 if (get_type_state(type) == layout_fixed)
617 fprintf(F, "(%3u:%u) ", get_compound_ent_value_offset_bytes(ent, i), get_compound_ent_value_offset_bit_remainder(ent, i));
618 fprintf(F, "%s", get_entity_name(ent));
619 for (j = 0; j < get_compound_graph_path_length(path); ++j) {
620 ir_entity *node = get_compound_graph_path_node(path, j);
621 fprintf(F, ".%s", get_entity_name(node));
622 if (is_Array_type(get_entity_owner(node)))
623 fprintf(F, "[%ld]", get_compound_graph_path_array_index(path, j));
626 dump_node_opcode(F, get_compound_ent_value(ent, i));
632 if (verbosity & dump_verbosity_entattrs) {
633 fprintf(F, "%s linkage:", prefix);
634 dump_entity_linkage(F, ent);
635 fprintf(F, "\n%s volatility: %s", prefix, get_volatility_name(get_entity_volatility(ent)));
636 fprintf(F, "\n%s aligned: %s", prefix, get_align_name(get_entity_aligned(ent)));
637 fprintf(F, "\n%s alignment: %u", prefix, get_entity_alignment(ent));
638 fprintf(F, "\n%s ld_name: %s", prefix, ent->ld_name ? get_entity_ld_name(ent) : "no yet set");
639 fprintf(F, "\n%s offset: %d bytes, %d rem bits", prefix, get_entity_offset(ent), get_entity_offset_bits_remainder(ent));
640 if (is_Method_type(get_entity_type(ent))) {
641 if (get_entity_irg(ent)) /* can be null */ {
642 fprintf(F, "\n%s irg = %ld", prefix, get_irg_graph_nr(get_entity_irg(ent)));
644 fprintf(F, "\n%s irg = NULL", prefix);
651 void dump_entity_to_file(FILE *out, ir_entity *ent)
653 dump_entity_to_file_prefix(out, ent, "");
657 void dump_type_to_file(FILE *F, ir_type *tp)
661 if ((is_Class_type(tp)) && (verbosity & dump_verbosity_noClassTypes)) return;
662 if ((is_Struct_type(tp)) && (verbosity & dump_verbosity_noStructTypes)) return;
663 if ((is_Union_type(tp)) && (verbosity & dump_verbosity_noUnionTypes)) return;
664 if ((is_Array_type(tp)) && (verbosity & dump_verbosity_noArrayTypes)) return;
665 if ((is_Pointer_type(tp)) && (verbosity & dump_verbosity_noPointerTypes)) return;
666 if ((is_Method_type(tp)) && (verbosity & dump_verbosity_noMethodTypes)) return;
667 if ((is_Primitive_type(tp)) && (verbosity & dump_verbosity_noPrimitiveTypes)) return;
668 if ((is_Enumeration_type(tp)) && (verbosity & dump_verbosity_noEnumerationTypes)) return;
670 ir_fprintf(F, "%+F", tp);
671 if (verbosity & dump_verbosity_onlynames) { fprintf(F, "\n"); return; }
673 switch (get_type_tpop_code(tp)) {
676 if ((verbosity & dump_verbosity_methods) || (verbosity & dump_verbosity_fields)) {
677 fprintf(F, "\n members:\n");
679 for (i = 0; i < get_class_n_members(tp); ++i) {
680 ir_entity *mem = get_class_member(tp, i);
681 if (((verbosity & dump_verbosity_methods) && is_Method_type(get_entity_type(mem))) ||
682 ((verbosity & dump_verbosity_fields) && !is_Method_type(get_entity_type(mem))) ) {
683 if (!(verbosity & dump_verbosity_nostatic)) {
684 dump_entity_to_file_prefix(F, mem, " ");
688 if (verbosity & dump_verbosity_typeattrs) {
689 fprintf(F, " supertypes: ");
690 for (i = 0; i < get_class_n_supertypes(tp); ++i) {
691 ir_type *stp = get_class_supertype(tp, i);
692 ir_fprintf(F, "\n %d %+F", i, stp);
694 fprintf(F, "\n subtypes: ");
695 for (i = 0; i < get_class_n_subtypes(tp); ++i) {
696 ir_type *stp = get_class_subtype(tp, i);
697 ir_fprintf(F, "\n %d %+F", i, stp);
700 if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
702 fprintf(F, "\n transitive supertypes: ");
703 for (stp = get_class_trans_supertype_first(tp);
705 stp = get_class_trans_supertype_next(tp)) {
706 ir_fprintf(F, "\n %+F", stp);
708 fprintf(F, "\n transitive subtypes: ");
709 for (stp = get_class_trans_subtype_first(tp);
711 stp = get_class_trans_subtype_next(tp)) {
712 ir_fprintf(F, "\n %+F", stp);
716 fprintf(F, "\n flags: ");
717 if (is_class_final(tp))
718 fprintf(F, "final, ");
719 if (is_class_interface(tp))
720 fprintf(F, "interface, ");
721 if (is_class_abstract(tp))
722 fprintf(F, "abstract, ");
729 if (verbosity & dump_verbosity_fields) fprintf(F, "\n members: ");
730 for (i = 0; i < get_compound_n_members(tp); ++i) {
731 ir_entity *mem = get_compound_member(tp, i);
732 if (verbosity & dump_verbosity_fields) {
733 dump_entity_to_file_prefix(F, mem, " ");
739 if (verbosity & dump_verbosity_typeattrs) {
741 ir_type *elem_tp = get_array_element_type(tp);
743 fprintf(F, "\n array ");
745 n_dim = get_array_n_dimensions(tp);
746 for (i = 0; i < n_dim; ++i) {
747 ir_node *lower, *upper;
749 lower = get_array_lower_bound(tp, i);
750 upper = get_array_upper_bound(tp, i);
754 if (is_Const(lower)) {
755 fprintf(F, "%ld .. ", get_tarval_long(get_Const_tarval(lower)));
757 dump_node_opcode(F, lower);
758 fprintf(F, " %ld .. ", get_irn_node_nr(lower));
761 if (is_Const(upper)) {
762 fprintf(F, "%ld]", get_tarval_long(get_Const_tarval(lower)));
764 dump_node_opcode(F, upper);
765 fprintf(F, " %ld]", get_irn_node_nr(upper));
768 ir_fprintf(F, " of <%+F>", elem_tp);
770 fprintf(F, "\n order: ");
771 for (i = 0; i < n_dim; ++i)
772 fprintf(F, "<%zu>", get_array_order(tp, i));
776 if (verbosity & dump_verbosity_fields) {
777 dump_entity_to_file_prefix(F, get_array_element_entity(tp),
784 if (verbosity & dump_verbosity_typeattrs) {
785 ir_type *tt = get_pointer_points_to_type(tp);
786 ir_fprintf(F, "\n points to %+F\n", tt);
791 if (verbosity & dump_verbosity_typeattrs) {
792 mtp_additional_properties mtp = get_method_additional_properties(tp);
793 unsigned cconv = get_method_calling_convention(tp);
794 fprintf(F, "\n variadicity: %s", get_variadicity_name(get_method_variadicity(tp)));
795 fprintf(F, "\n return types: %lu",
796 (unsigned long) get_method_n_ress(tp));
797 for (i = 0; i < get_method_n_ress(tp); ++i) {
798 ir_type *rtp = get_method_res_type(tp, i);
799 ir_fprintf(F, "\n %+F", rtp);
802 fprintf(F, "\n parameter types: %lu",
803 (unsigned long) get_method_n_params(tp));
804 for (i = 0; i < get_method_n_params(tp); ++i) {
805 ir_type *ptp = get_method_param_type(tp, i);
806 ir_fprintf(F, "\n %+F", ptp);
808 fprintf(F, "\n properties:");
809 if (mtp & mtp_property_const)
811 if (mtp & mtp_property_pure)
813 if (mtp & mtp_property_noreturn)
814 fputs(" noreturn", F);
815 if (mtp & mtp_property_nothrow)
816 fputs(" nothrow", F);
817 if (mtp & mtp_property_naked)
819 if (mtp & mtp_property_malloc)
821 if (mtp & mtp_property_returns_twice)
822 fputs(" returns_twice", F);
823 if (mtp & mtp_property_intrinsic)
824 fputs(" intrinsic", F);
825 if (mtp & mtp_property_runtime)
826 fputs(" runtime", F);
827 if (mtp & mtp_property_private)
828 fputs(" private", F);
829 if (mtp & mtp_property_has_loop)
830 fputs(" has_Loop", F);
832 fprintf(F, "\n calling convention:");
833 if (cconv & cc_reg_param)
834 fputs(" regparam", F);
835 if (cconv & cc_last_on_top)
836 fputs(" last_on_top", F);
837 if (cconv & cc_callee_clear_stk)
838 fputs(" calle_clear_stk", F);
839 if (cconv & cc_this_call)
840 fputs(" this_call", F);
841 if (cconv & cc_compound_ret)
842 fputs(" compound_ret", F);
843 if (cconv & cc_frame_on_caller_stk)
844 fputs(" frame_on_caller_stk", F);
845 if (cconv & cc_fpreg_param)
846 fputs(" fpreg_param", F);
848 if (get_method_variadicity(tp)) {
849 fprintf(F, "\n ...");
856 if (verbosity & dump_verbosity_typeattrs) {
857 ir_type *base_tp = get_primitive_base_type(tp);
859 ir_fprintf(F, "\n base type: %+F", tp);
870 if (verbosity & dump_verbosity_typeattrs) {
871 fprintf(F, ": details not implemented\n");
875 fprintf(F, " state: %s,\n", get_type_state_name(get_type_state(tp)));
876 fprintf(F, " size: %2u Bytes,\n", get_type_size_bytes(tp));
877 fprintf(F, " alignment: %2u Bytes,\n", get_type_alignment_bytes(tp));
878 if (is_atomic_type(tp) || is_Method_type(tp))
879 fprintf(F, " mode: %s,\n", get_mode_name(get_type_mode(tp)));
884 void dump_types_as_text(FILE *out)
886 size_t i, n_types = get_irp_n_types();
888 for (i = 0; i < n_types; ++i) {
889 ir_type *type = get_irp_type(i);
890 dump_type_to_file(out, type);
894 void dump_globals_as_text(FILE *out)
896 ir_type *global_type = get_glob_type();
897 size_t n_members = get_class_n_members(global_type);
900 for (i = 0; i < n_members; ++i) {
901 ir_entity *entity = get_class_member(global_type, i);
902 dump_entity_to_file(out, entity);