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 void dump_irnode_to_file(FILE *F, const ir_node *n)
64 dump_node_opcode(F, n);
65 fprintf(F, " %ld\n", get_irn_node_nr(n));
67 fprintf(F, " index: %u\n", get_irn_idx(n));
68 if (ir_get_dump_flags() & ir_dump_flag_analysed_types)
69 fprintf (F, " addr: %p\n", (void *)n);
70 fprintf (F, " mode: %s\n", get_mode_name(get_irn_mode(n)));
71 fprintf (F, " visited: %lu\n", get_irn_visited(n));
73 if (irg != get_const_code_irg())
74 fprintf (F, " irg: %s\n", get_ent_dump_name(get_irg_entity(irg)));
76 if (get_irn_pinned(n) == op_pin_state_floats &&
77 get_irg_pinned(get_irn_irg(n)) == op_pin_state_floats) {
78 fprintf(F, " node was pinned in ");
79 dump_node_opcode(F, get_irn_n(n, -1));
80 fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, -1)));
83 fprintf(F, " arity: %d\n", get_irn_arity(n));
84 /* show all predecessor nodes */
85 fprintf(F, " pred nodes:\n");
88 dump_node_opcode(F, get_irn_n(n, -1));
89 fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, -1)));
94 for (i = 0; i < get_irn_arity(n); ++i) {
95 fprintf(F, " %d: %s ", i, is_backedge(n, i) ? "be" : " ");
96 dump_node_opcode(F, get_irn_n(n, i));
97 fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, i)));
101 fprintf(F, " Private Attributes:\n");
104 ir_node *pred = get_Proj_pred(n);
105 long pn = get_Proj_proj(n);
106 fprintf(F, " proj nr: %ld\n", pn);
107 if (is_Switch(pred)) {
108 const ir_switch_table *table = get_Switch_table(pred);
109 size_t n_entries = ir_switch_table_get_n_entries(table);
111 for (i = 0; i < n_entries; ++i) {
112 const ir_switch_table_entry *entry
113 = ir_switch_table_get_entry_const(table, i);
114 if (entry->pn == pn && entry->min != NULL && entry->max != NULL) {
115 ir_tarval *min = entry->min;
116 ir_tarval *max = entry->max;
118 ir_fprintf(F, " switch case %+F .. %+F\n", min, max);
120 ir_fprintf(F, " switch case %+F\n", min);
127 if (is_fragile_op(n)) {
128 fprintf(F, " pinned state: %s\n", get_op_pin_state_name(get_irn_pinned(n)));
129 /* not dumped: frag array */
132 /* This is not nice, output it as a marker in the predecessor list. */
133 if (is_Block(n) || get_irn_op(n) == op_Phi) {
135 fprintf(F, " backedges:");
137 for (i = 0; i < get_irn_arity(n); i++)
138 if (is_backedge(n, i)) { fprintf(F, "%c %d", comma, i); comma = ','; }
142 /* Loop node. Someone else please tell me what's wrong ... */
143 if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO)) {
144 ir_loop *loop = get_irn_loop(n);
146 fprintf(F, " in loop %ld with depth %u\n",
147 get_loop_loop_nr(loop), get_loop_depth(loop));
152 switch (get_irn_opcode(n)) {
154 ir_entity *const entity = get_Block_entity(n);
156 fprintf(F, " Label: %lu\n", get_entity_label(entity));
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 (irg_has_properties(get_irn_irg(n), IR_GRAPH_PROPERTY_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 (irg_has_properties(get_irn_irg(n), IR_GRAPH_PROPERTY_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 ir_fprintf(F, " calling method of type %+F\n", tp);
207 if (get_unknown_type() != tp) {
209 for (i = 0; i < get_method_n_params(tp); ++i)
210 ir_fprintf(F, " param %d type: %+F\n", i, get_method_param_type(tp, i));
211 for (i = 0; i < get_method_n_ress(tp); ++i)
212 ir_fprintf(F, " result %d type: %+F\n", i, get_method_res_type(tp, i));
214 if (Call_has_callees(n)) {
216 fprintf(F, " possible callees:\n");
217 for (i = 0; i < get_Call_n_callees(n); i++) {
218 ir_fprintf(F, " %zu: %s\n", i, get_ent_dump_name(get_Call_callee(n, i)));
223 ir_fprintf(F, " cast to type: %+F\n", get_Cast_type(n));
226 ir_relation relation = get_Cmp_relation(n);
227 ir_fprintf(F, " relation: %s\n", get_relation_string(relation));
231 ir_type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
232 ir_fprintf(F, " return in method of type %+F\n", tp);
233 for (i = 0; i < get_method_n_ress(tp); ++i) {
234 ir_fprintf(F, " result %d type: %+F\n", i,
235 get_method_res_type(tp, i));
239 switch (get_SymConst_kind(n)) {
240 case symconst_addr_ent:
241 fprintf(F, " kind: addr_ent\n");
242 fprintf(F, " entity: ");
243 dump_entity_to_file(F, get_SymConst_entity(n));
245 case symconst_ofs_ent:
246 fprintf(F, " kind: offset\n");
247 fprintf(F, " entity: ");
248 dump_entity_to_file(F, get_SymConst_entity(n));
250 case symconst_type_size:
251 fprintf(F, " kind: size\n");
252 fprintf(F, " type: ");
253 dump_type_to_file(F, get_SymConst_type(n));
255 case symconst_type_align:
256 fprintf(F, " kind: alignment\n");
257 fprintf(F, " type: ");
258 dump_type_to_file(F, get_SymConst_type(n));
260 case symconst_enum_const:
261 fprintf(F, " kind: enumeration\n");
262 fprintf(F, " name: %s\n", get_enumeration_const_name(get_SymConst_enum(n)));
267 fprintf(F, " mode of loaded value: %s\n", get_mode_name_ex(get_Load_mode(n), NULL));
268 fprintf(F, " volatility: %s\n", get_volatility_name(get_Load_volatility(n)));
269 fprintf(F, " align: %s\n", get_align_name(get_Load_unaligned(n)));
272 fprintf(F, " volatility: %s\n", get_volatility_name(get_Store_volatility(n)));
273 fprintf(F, " align: %s\n", get_align_name(get_Store_unaligned(n)));
276 fprintf(F, " compare operation: %s\n", get_relation_string(get_Confirm_relation(n)));
279 const ir_asm_constraint *cons;
283 fprintf(F, " assembler text: %s", get_id_str(get_ASM_text(n)));
284 l = get_ASM_n_input_constraints(n);
287 fprintf(F, "\n inputs: ");
288 cons = get_ASM_input_constraints(n);
289 for (i = 0; i < l; ++i)
290 fprintf(F, "%%%u %s ", cons[i].pos, get_id_str(cons[i].constraint));
292 l = get_ASM_n_output_constraints(n);
295 fprintf(F, "\n outputs: ");
296 cons = get_ASM_output_constraints(n);
297 for (i = 0; i < l; ++i)
298 fprintf(F, "%%%u %s ", cons[i].pos, get_id_str(cons[i].constraint));
300 l = get_ASM_n_clobbers(n);
303 fprintf(F, "\n clobber: ");
304 clobber = get_ASM_clobbers(n);
305 for (i = 0; i < l; ++i)
306 fprintf(F, "%s ", get_id_str(clobber[i]));
308 if (get_irn_pinned(n) != op_pin_state_floats)
309 fprintf(F, "\n volatile");
317 if (get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_consistent ||
318 get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_inconsistent )
319 if (get_irn_typeinfo_type(n) != get_none_type())
320 ir_fprintf (F, " Analysed type: %s\n", get_irn_typeinfo_type(n));
323 void dump_graph_as_text(FILE *out, ir_graph *irg)
325 fprintf(out, "graph %s\n", get_irg_dump_name(irg));
328 static int need_nl = 1;
330 static bool is_init_string(ir_initializer_t const* const init, ir_type *const type)
332 ir_type *const element_type = get_array_element_type(type);
337 if (!is_Primitive_type(element_type))
340 mode = get_type_mode(element_type);
341 if (!mode_is_int(mode) || get_mode_size_bits(mode) != 8)
344 n = get_initializer_compound_n_entries(init);
345 for (i = 0; i != n; ++i) {
346 ir_initializer_t const* const val = get_initializer_compound_value(init, i);
350 if (get_initializer_kind(val) != IR_INITIALIZER_TARVAL)
352 tv = get_initializer_tarval_value(val);
354 if (!tarval_is_constant(tv))
357 v = get_tarval_long(tv);
358 if (v != 0 && (v < 0x07 || 0x0D < v) && v != 0x1B && (v < 0x20 || 0x80 <= v) && (v < 0xA0 || 0x100 <= v))
368 static void dump_ir_initializers_to_file(FILE *F, const char *prefix,
369 const ir_initializer_t *initializer,
376 fprintf(F, "\n%s ", prefix);
379 switch (get_initializer_kind(initializer)) {
380 case IR_INITIALIZER_NULL:
381 fprintf(F, "\t = <NOT_SET>");
383 case IR_INITIALIZER_TARVAL:
384 tv = get_initializer_tarval_value(initializer);
385 ir_fprintf(F, "\t = <TV>%F", tv);
387 case IR_INITIALIZER_CONST:
388 value = get_initializer_const_value(initializer);
389 ir_fprintf(F, "\t = %F", value);
391 case IR_INITIALIZER_COMPOUND:
392 if (is_Array_type(type)) {
393 size_t const n = get_initializer_compound_n_entries(initializer);
396 if (is_init_string(initializer, type)) {
397 fprintf(F, "\t[0...%u] = '", (unsigned)n - 1);
398 for (i = 0; i != n; ++i) {
399 ir_initializer_t const* const val = get_initializer_compound_value(initializer, i);
400 ir_tarval* const tv = get_initializer_tarval_value(val);
401 long const v = get_tarval_long(tv);
404 case 0x00: fprintf(F, "\\\\000"); break;
405 case 0x07: fprintf(F, "\\\\a"); break;
406 case 0x08: fprintf(F, "\\\\b"); break;
407 case 0x09: fprintf(F, "\\\\t"); break;
408 case 0x0A: fprintf(F, "\\\\n"); break;
409 case 0x0B: fprintf(F, "\\\\v"); break;
410 case 0x0C: fprintf(F, "\\\\f"); break;
411 case 0x0D: fprintf(F, "\\\\r"); break;
412 case 0x1B: fprintf(F, "\\\\033"); break;
413 case 0x22: fprintf(F, "\\\\\\\""); break;
414 case 0x5C: fprintf(F, "\\\\\\\\"); break;
415 default: fprintf(F, "%c", (unsigned char)v); break;
420 ir_type *const element_type = get_array_element_type(type);
422 for (i = 0; i < n; ++i) {
423 ir_initializer_t *sub_initializer
424 = get_initializer_compound_value(initializer, i);
427 fprintf(F, "\n%s ", prefix);
430 fprintf(F, "[%d]", (int) i);
431 dump_ir_initializers_to_file(F, prefix, sub_initializer, element_type);
436 assert(is_compound_type(type));
437 n = get_compound_n_members(type);
438 for (i = 0; i < n; ++i) {
439 ir_entity *member = get_compound_member(type, i);
440 ir_type *subtype = get_entity_type(member);
441 ir_initializer_t *sub_initializer;
443 assert(i < get_initializer_compound_n_entries(initializer));
445 = get_initializer_compound_value(initializer, i);
448 fprintf(F, "\n%s ", prefix);
451 ir_fprintf(F, ".%F", member);
452 dump_ir_initializers_to_file(F, prefix, sub_initializer, subtype);
457 panic("invalid ir_initializer kind found");
462 static void dump_entity_linkage(FILE *F, const ir_entity *entity)
464 ir_linkage linkage = get_entity_linkage(entity);
466 if (linkage == IR_LINKAGE_DEFAULT) {
467 fprintf(F, " default");
470 if (linkage & IR_LINKAGE_CONSTANT)
471 fprintf(F, " constant");
472 if (linkage & IR_LINKAGE_WEAK)
474 if (linkage & IR_LINKAGE_GARBAGE_COLLECT)
475 fprintf(F, " garbage_collect");
476 if (linkage & IR_LINKAGE_MERGE)
477 fprintf(F, " merge");
478 if (linkage & IR_LINKAGE_HIDDEN_USER)
479 fprintf(F, " hidden_user");
482 static void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, const char *prefix)
484 ir_type *owner, *type;
486 assert(is_entity(ent));
487 owner = get_entity_owner(ent);
488 type = get_entity_type(ent);
489 if (verbosity & dump_verbosity_onlynames) {
490 fprintf(F, "%sentity %s.%s (%ld)\n", prefix, get_compound_name(get_entity_owner(ent)),
491 get_entity_name(ent), get_entity_nr(ent));
495 if (verbosity & dump_verbosity_entattrs) {
496 fprintf(F, "%sentity %s (%ld)\n", prefix, get_entity_name(ent), get_entity_nr(ent));
497 ir_fprintf(F, "%s type: %+F\n", prefix, type);
498 ir_fprintf(F, "%s owner: %+F\n", prefix, owner);
500 if (is_Class_type(get_entity_owner(ent))) {
501 if (get_entity_n_overwrites(ent) > 0) {
503 fprintf(F, "%s overwrites:\n", prefix);
504 for (i = 0; i < get_entity_n_overwrites(ent); ++i) {
505 ir_entity *ov = get_entity_overwrites(ent, i);
506 ir_fprintf(F, "%s %d: %s of class %+F\n", prefix, i,
507 get_entity_name(ov), get_entity_owner(ov));
510 fprintf(F, "%s Does not overwrite other entities.\n", prefix);
512 if (get_entity_n_overwrittenby(ent) > 0) {
514 fprintf(F, "%s overwritten by:\n", prefix);
515 for (i = 0; i < get_entity_n_overwrittenby(ent); ++i) {
516 ir_entity *ov = get_entity_overwrittenby(ent, i);
517 ir_fprintf(F, "%s %d: %s of class %+F\n", prefix, i,
518 get_entity_name(ov), get_entity_owner(ov));
521 fprintf(F, "%s Is not overwritten by other entities.\n",
525 if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
527 fprintf(F, "%s transitive overwrites:\n", prefix);
528 for (ov = get_entity_trans_overwrites_first(ent);
530 ov = get_entity_trans_overwrites_next(ent)) {
531 ir_fprintf(F, "%s : %s of class %+F\n", prefix,
532 get_entity_name(ov), get_entity_owner(ov));
534 fprintf(F, "%s transitive overwritten by:\n", prefix);
535 for (ov = get_entity_trans_overwrittenby_first(ent);
537 ov = get_entity_trans_overwrittenby_next(ent)) {
538 ir_fprintf(F, "%s : %s of class %+F\n", prefix,
539 get_entity_name(ov), get_entity_owner(ov));
544 if (is_Method_type(get_entity_type(ent))) {
545 unsigned mask = get_entity_additional_properties(ent);
546 unsigned cc = get_method_calling_convention(get_entity_type(ent));
547 ir_graph *irg = get_entity_irg(ent);
550 fprintf(F, "%s estimated node count: %u\n", prefix, get_irg_estimated_node_cnt(irg));
551 fprintf(F, "%s maximum node index: %u\n", prefix, get_irg_last_idx(irg));
555 fprintf(F, "%s additional prop: ", prefix);
557 if (mask & mtp_property_const) fputs("const_function, ", F);
558 if (mask & mtp_property_pure) fputs("pure_function, ", F);
559 if (mask & mtp_property_noreturn) fputs("noreturn_function, ", F);
560 if (mask & mtp_property_nothrow) fputs("nothrow_function, ", F);
561 if (mask & mtp_property_naked) fputs("naked_function, ", F);
562 if (mask & mtp_property_malloc) fputs("malloc_function, ", F);
563 if (mask & mtp_property_returns_twice) fputs("weak_function, ", F);
564 if (mask & mtp_property_intrinsic) fputs("intrinsic_function, ", F);
565 if (mask & mtp_property_runtime) fputs("runtime_function, ", F);
566 if (mask & mtp_property_private) fputs("private_function, ", F);
567 if (mask & mtp_property_has_loop) fputs("has_loop_function, ", F);
570 fprintf(F, "%s calling convention: ", prefix);
571 if (cc & cc_reg_param) fputs("regparam, ", F);
572 if (cc & cc_this_call) fputs("thiscall, ", F);
573 if (cc & cc_compound_ret) fputs("compound_ret, ", F);
574 if (cc & cc_frame_on_caller_stk) fputs("frame on caller's stack, ", F);
575 cc &= ~(cc_compound_ret|cc_frame_on_caller_stk);
578 else if (IS_STDCALL(cc))
581 fputs(cc & cc_last_on_top ? "last param on top, " : "first param on top, ", F);
582 fputs(cc & cc_callee_clear_stk ? "callee clear stack" : "caller clear stack", F);
584 fprintf(F, "\n%s vtable number: %u\n", prefix, get_entity_vtable_number(ent));
586 } else { /* no entattrs */
587 ir_fprintf(F, "%s(%3d:%d) %+F: %s", prefix,
588 get_entity_offset(ent), get_entity_offset_bits_remainder(ent),
589 get_entity_type(ent), get_entity_name(ent));
590 if (is_Method_type(get_entity_type(ent))) fputs("(...)", F);
592 if (verbosity & dump_verbosity_accessStats) {
593 dump_entity_linkage(F, ent);
598 if (verbosity & dump_verbosity_entconsts) {
599 if (ent->initializer != NULL) {
600 const ir_initializer_t *initializer = get_entity_initializer(ent);
601 fprintf(F, "\n%s Initializers:", prefix);
603 dump_ir_initializers_to_file(F, prefix, initializer, get_entity_type(ent));
608 if (verbosity & dump_verbosity_entattrs) {
609 fprintf(F, "%s linkage:", prefix);
610 dump_entity_linkage(F, ent);
611 fprintf(F, "\n%s volatility: %s", prefix, get_volatility_name(get_entity_volatility(ent)));
612 fprintf(F, "\n%s aligned: %s", prefix, get_align_name(get_entity_aligned(ent)));
613 fprintf(F, "\n%s alignment: %u", prefix, get_entity_alignment(ent));
614 fprintf(F, "\n%s ld_name: %s", prefix, ent->ld_name ? get_entity_ld_name(ent) : "no yet set");
615 fprintf(F, "\n%s offset: %d bytes, %d rem bits", prefix, get_entity_offset(ent), get_entity_offset_bits_remainder(ent));
616 if (is_Method_type(get_entity_type(ent))) {
617 if (get_entity_irg(ent)) /* can be null */ {
618 fprintf(F, "\n%s irg = %ld", prefix, get_irg_graph_nr(get_entity_irg(ent)));
620 fprintf(F, "\n%s irg = NULL", prefix);
627 void dump_entity_to_file(FILE *out, ir_entity *ent)
629 dump_entity_to_file_prefix(out, ent, "");
633 void dump_type_to_file(FILE *F, ir_type *tp)
637 if ((is_Class_type(tp)) && (verbosity & dump_verbosity_noClassTypes)) return;
638 if ((is_Struct_type(tp)) && (verbosity & dump_verbosity_noStructTypes)) return;
639 if ((is_Union_type(tp)) && (verbosity & dump_verbosity_noUnionTypes)) return;
640 if ((is_Array_type(tp)) && (verbosity & dump_verbosity_noArrayTypes)) return;
641 if ((is_Pointer_type(tp)) && (verbosity & dump_verbosity_noPointerTypes)) return;
642 if ((is_Method_type(tp)) && (verbosity & dump_verbosity_noMethodTypes)) return;
643 if ((is_Primitive_type(tp)) && (verbosity & dump_verbosity_noPrimitiveTypes)) return;
644 if ((is_Enumeration_type(tp)) && (verbosity & dump_verbosity_noEnumerationTypes)) return;
646 ir_fprintf(F, "%+F", tp);
647 if (verbosity & dump_verbosity_onlynames) { fprintf(F, "\n"); return; }
649 switch (get_type_tpop_code(tp)) {
652 if ((verbosity & dump_verbosity_methods) || (verbosity & dump_verbosity_fields)) {
653 fprintf(F, "\n members:\n");
655 for (i = 0; i < get_class_n_members(tp); ++i) {
656 ir_entity *mem = get_class_member(tp, i);
657 if (((verbosity & dump_verbosity_methods) && is_Method_type(get_entity_type(mem))) ||
658 ((verbosity & dump_verbosity_fields) && !is_Method_type(get_entity_type(mem))) ) {
659 if (!(verbosity & dump_verbosity_nostatic)) {
660 dump_entity_to_file_prefix(F, mem, " ");
664 if (verbosity & dump_verbosity_typeattrs) {
665 fprintf(F, " supertypes: ");
666 for (i = 0; i < get_class_n_supertypes(tp); ++i) {
667 ir_type *stp = get_class_supertype(tp, i);
668 ir_fprintf(F, "\n %d %+F", i, stp);
670 fprintf(F, "\n subtypes: ");
671 for (i = 0; i < get_class_n_subtypes(tp); ++i) {
672 ir_type *stp = get_class_subtype(tp, i);
673 ir_fprintf(F, "\n %d %+F", i, stp);
676 if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
678 fprintf(F, "\n transitive supertypes: ");
679 for (stp = get_class_trans_supertype_first(tp);
681 stp = get_class_trans_supertype_next(tp)) {
682 ir_fprintf(F, "\n %+F", stp);
684 fprintf(F, "\n transitive subtypes: ");
685 for (stp = get_class_trans_subtype_first(tp);
687 stp = get_class_trans_subtype_next(tp)) {
688 ir_fprintf(F, "\n %+F", stp);
692 fprintf(F, "\n flags: ");
693 if (is_class_final(tp))
694 fprintf(F, "final, ");
695 if (is_class_interface(tp))
696 fprintf(F, "interface, ");
697 if (is_class_abstract(tp))
698 fprintf(F, "abstract, ");
705 if (verbosity & dump_verbosity_fields) fprintf(F, "\n members: ");
706 for (i = 0; i < get_compound_n_members(tp); ++i) {
707 ir_entity *mem = get_compound_member(tp, i);
708 if (verbosity & dump_verbosity_fields) {
709 dump_entity_to_file_prefix(F, mem, " ");
715 if (verbosity & dump_verbosity_typeattrs) {
717 ir_type *elem_tp = get_array_element_type(tp);
719 fprintf(F, "\n array ");
721 n_dim = get_array_n_dimensions(tp);
722 for (i = 0; i < n_dim; ++i) {
723 ir_node *lower, *upper;
725 lower = get_array_lower_bound(tp, i);
726 upper = get_array_upper_bound(tp, i);
730 if (is_Const(lower)) {
731 fprintf(F, "%ld .. ", get_tarval_long(get_Const_tarval(lower)));
733 dump_node_opcode(F, lower);
734 fprintf(F, " %ld .. ", get_irn_node_nr(lower));
737 if (is_Const(upper)) {
738 fprintf(F, "%ld]", get_tarval_long(get_Const_tarval(lower)));
740 dump_node_opcode(F, upper);
741 fprintf(F, " %ld]", get_irn_node_nr(upper));
744 ir_fprintf(F, " of <%+F>", elem_tp);
746 fprintf(F, "\n order: ");
747 for (i = 0; i < n_dim; ++i)
748 fprintf(F, "<%zu>", get_array_order(tp, i));
752 if (verbosity & dump_verbosity_fields) {
753 dump_entity_to_file_prefix(F, get_array_element_entity(tp),
760 if (verbosity & dump_verbosity_typeattrs) {
761 ir_type *tt = get_pointer_points_to_type(tp);
762 ir_fprintf(F, "\n points to %+F\n", tt);
767 if (verbosity & dump_verbosity_typeattrs) {
768 mtp_additional_properties mtp = get_method_additional_properties(tp);
769 unsigned cconv = get_method_calling_convention(tp);
770 fprintf(F, "\n variadicity: %s", get_variadicity_name(get_method_variadicity(tp)));
771 fprintf(F, "\n return types: %lu",
772 (unsigned long) get_method_n_ress(tp));
773 for (i = 0; i < get_method_n_ress(tp); ++i) {
774 ir_type *rtp = get_method_res_type(tp, i);
775 ir_fprintf(F, "\n %+F", rtp);
778 fprintf(F, "\n parameter types: %lu",
779 (unsigned long) get_method_n_params(tp));
780 for (i = 0; i < get_method_n_params(tp); ++i) {
781 ir_type *ptp = get_method_param_type(tp, i);
782 ir_fprintf(F, "\n %+F", ptp);
784 fprintf(F, "\n properties:");
785 if (mtp & mtp_property_const)
787 if (mtp & mtp_property_pure)
789 if (mtp & mtp_property_noreturn)
790 fputs(" noreturn", F);
791 if (mtp & mtp_property_nothrow)
792 fputs(" nothrow", F);
793 if (mtp & mtp_property_naked)
795 if (mtp & mtp_property_malloc)
797 if (mtp & mtp_property_returns_twice)
798 fputs(" returns_twice", F);
799 if (mtp & mtp_property_intrinsic)
800 fputs(" intrinsic", F);
801 if (mtp & mtp_property_runtime)
802 fputs(" runtime", F);
803 if (mtp & mtp_property_private)
804 fputs(" private", F);
805 if (mtp & mtp_property_has_loop)
806 fputs(" has_Loop", F);
808 fprintf(F, "\n calling convention:");
809 if (cconv & cc_reg_param)
810 fputs(" regparam", F);
811 if (cconv & cc_last_on_top)
812 fputs(" last_on_top", F);
813 if (cconv & cc_callee_clear_stk)
814 fputs(" calle_clear_stk", F);
815 if (cconv & cc_this_call)
816 fputs(" this_call", F);
817 if (cconv & cc_compound_ret)
818 fputs(" compound_ret", F);
819 if (cconv & cc_frame_on_caller_stk)
820 fputs(" frame_on_caller_stk", F);
821 if (cconv & cc_fpreg_param)
822 fputs(" fpreg_param", F);
824 if (get_method_variadicity(tp)) {
825 fprintf(F, "\n ...");
832 if (verbosity & dump_verbosity_typeattrs) {
833 ir_type *base_tp = get_primitive_base_type(tp);
835 ir_fprintf(F, "\n base type: %+F", tp);
846 if (verbosity & dump_verbosity_typeattrs) {
847 fprintf(F, ": details not implemented\n");
851 fprintf(F, " state: %s,\n", get_type_state_name(get_type_state(tp)));
852 fprintf(F, " size: %2u Bytes,\n", get_type_size_bytes(tp));
853 fprintf(F, " alignment: %2u Bytes,\n", get_type_alignment_bytes(tp));
854 if (is_atomic_type(tp) || is_Method_type(tp))
855 fprintf(F, " mode: %s,\n", get_mode_name(get_type_mode(tp)));
860 void dump_types_as_text(FILE *out)
862 size_t i, n_types = get_irp_n_types();
864 for (i = 0; i < n_types; ++i) {
865 ir_type *type = get_irp_type(i);
866 dump_type_to_file(out, type);
870 void dump_globals_as_text(FILE *out)
872 ir_type *global_type = get_glob_type();
873 size_t n_members = get_class_n_members(global_type);
876 for (i = 0; i < n_members; ++i) {
877 ir_entity *entity = get_class_member(global_type, i);
878 dump_entity_to_file(out, entity);