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,
35 #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 fprintf(F, " proj nr: %ld\n", get_Proj_proj(n));
107 if (is_fragile_op(n)) {
108 fprintf(F, " pinned state: %s\n", get_op_pin_state_name(get_irn_pinned(n)));
109 /* not dumped: frag array */
112 /* This is not nice, output it as a marker in the predecessor list. */
113 if (is_Block(n) || get_irn_op(n) == op_Phi) {
115 fprintf(F, " backedges:");
117 for (i = 0; i < get_irn_arity(n); i++)
118 if (is_backedge(n, i)) { fprintf(F, "%c %d", comma, i); comma = ','; }
122 /* Loop node. Someone else please tell me what's wrong ... */
123 if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO)) {
124 ir_loop *loop = get_irn_loop(n);
126 fprintf(F, " in loop %ld with depth %u\n",
127 get_loop_loop_nr(loop), get_loop_depth(loop));
132 switch (get_irn_opcode(n)) {
134 if (has_Block_entity(n))
135 fprintf(F, " Label: %lu\n", get_entity_label(get_Block_entity(n)));
136 fprintf(F, " block visited: %lu\n", get_Block_block_visited(n));
137 fprintf(F, " block marked: %u\n", get_Block_mark(n));
138 if (is_irg_state(get_irn_irg(n), IR_GRAPH_STATE_CONSISTENT_DOMINANCE)) {
139 fprintf(F, " dom depth %d\n", get_Block_dom_depth(n));
140 fprintf(F, " domtree pre num %u\n", get_Block_dom_tree_pre_num(n));
141 fprintf(F, " max subtree pre num %u\n", get_Block_dom_max_subtree_pre_num(n));
143 if (is_irg_state(get_irn_irg(n), IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE)) {
144 fprintf(F, " pdom depth %d\n", get_Block_postdom_depth(n));
145 fprintf(F, " pdomtree pre num %u\n", get_Block_pdom_tree_pre_num(n));
146 fprintf(F, " max pdomsubtree pre num %u\n", get_Block_pdom_max_subtree_pre_num(n));
149 /* not dumped: graph_arr */
150 /* not dumped: mature */
154 ir_type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
155 ir_fprintf(F, " start of method of type %+F\n", tp);
156 for (i = 0; i < get_method_n_params(tp); ++i)
157 ir_fprintf(F, " param %d type: %+F\n", i, get_method_param_type(tp, i));
160 fprintf(F, " default ProjNr: %ld\n", get_Cond_default_proj(n));
161 if (get_Cond_jmp_pred(n) != COND_JMP_PRED_NONE) {
162 fprintf(F, " jump prediction: %s\n",
163 get_cond_jmp_predicate_name(get_Cond_jmp_pred(n)));
167 ir_fprintf(F, " allocating entity of type: %+F\n", get_Alloc_type(n));
168 fprintf(F, " allocating on: the %s\n", (get_Alloc_where(n) == stack_alloc) ? "stack" : "heap");
171 ir_fprintf(F, " freeing entity of type %+F\n", get_Free_type(n));
172 fprintf(F, " allocated on: the %s\n", (get_Free_where(n) == stack_alloc) ? "stack" : "heap");
175 ir_entity *ent = get_Sel_entity(n);
177 fprintf(F, " Selecting entity %s (%ld)\n", get_entity_name(ent), get_entity_nr(ent));
178 ir_fprintf(F, " of type %+F\n", get_entity_type(ent));
179 ir_fprintf(F, " with owner %+F.\n", get_entity_owner(ent));
181 fprintf(F, " <NULL entity>\n");
185 ir_type *tp = get_Call_type(n);
186 if (get_Call_tail_call(n))
187 fprintf(F, " tail call\n");
188 ir_fprintf(F, " calling method of type %+F\n", tp);
189 if (get_unknown_type() != tp) {
191 for (i = 0; i < get_method_n_params(tp); ++i)
192 ir_fprintf(F, " param %d type: %+F\n", i, get_method_param_type(tp, i));
193 for (i = 0; i < get_method_n_ress(tp); ++i)
194 ir_fprintf(F, " result %d type: %+F\n", i, get_method_res_type(tp, i));
196 if (Call_has_callees(n)) {
198 fprintf(F, " possible callees:\n");
199 for (i = 0; i < get_Call_n_callees(n); i++) {
200 ir_fprintf(F, " %zu: %s\n", i, get_ent_dump_name(get_Call_callee(n, i)));
205 ir_fprintf(F, " cast to type: %+F\n", get_Cast_type(n));
208 ir_relation relation = get_Cmp_relation(n);
209 ir_fprintf(F, " relation: %s\n", get_relation_string(relation));
213 ir_type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
214 ir_fprintf(F, " return in method of type %+F\n", tp);
215 for (i = 0; i < get_method_n_ress(tp); ++i) {
216 ir_fprintf(F, " result %d type: %+F\n", i,
217 get_method_res_type(tp, i));
221 switch (get_SymConst_kind(n)) {
222 case symconst_addr_ent:
223 fprintf(F, " kind: addr_ent\n");
224 fprintf(F, " entity: ");
225 dump_entity_to_file(F, get_SymConst_entity(n));
227 case symconst_ofs_ent:
228 fprintf(F, " kind: offset\n");
229 fprintf(F, " entity: ");
230 dump_entity_to_file(F, get_SymConst_entity(n));
232 case symconst_type_tag:
233 fprintf(F, " kind: type_tag\n");
234 fprintf(F, " type: ");
235 dump_type_to_file(F, get_SymConst_type(n));
237 case symconst_type_size:
238 fprintf(F, " kind: size\n");
239 fprintf(F, " type: ");
240 dump_type_to_file(F, get_SymConst_type(n));
242 case symconst_type_align:
243 fprintf(F, " kind: alignment\n");
244 fprintf(F, " type: ");
245 dump_type_to_file(F, get_SymConst_type(n));
247 case symconst_enum_const:
248 fprintf(F, " kind: enumeration\n");
249 fprintf(F, " name: %s\n", get_enumeration_const_name(get_SymConst_enum(n)));
254 fprintf(F, " mode of loaded value: %s\n", get_mode_name_ex(get_Load_mode(n), NULL));
255 fprintf(F, " volatility: %s\n", get_volatility_name(get_Load_volatility(n)));
256 fprintf(F, " align: %s\n", get_align_name(get_Load_unaligned(n)));
259 fprintf(F, " volatility: %s\n", get_volatility_name(get_Store_volatility(n)));
260 fprintf(F, " align: %s\n", get_align_name(get_Store_unaligned(n)));
263 fprintf(F, " compare operation: %s\n", get_relation_string(get_Confirm_relation(n)));
266 const ir_asm_constraint *cons;
270 fprintf(F, " assembler text: %s", get_id_str(get_ASM_text(n)));
271 l = get_ASM_n_input_constraints(n);
274 fprintf(F, "\n inputs: ");
275 cons = get_ASM_input_constraints(n);
276 for (i = 0; i < l; ++i)
277 fprintf(F, "%%%u %s ", cons[i].pos, get_id_str(cons[i].constraint));
279 l = get_ASM_n_output_constraints(n);
282 fprintf(F, "\n outputs: ");
283 cons = get_ASM_output_constraints(n);
284 for (i = 0; i < l; ++i)
285 fprintf(F, "%%%u %s ", cons[i].pos, get_id_str(cons[i].constraint));
287 l = get_ASM_n_clobbers(n);
290 fprintf(F, "\n clobber: ");
291 clobber = get_ASM_clobbers(n);
292 for (i = 0; i < l; ++i)
293 fprintf(F, "%s ", get_id_str(clobber[i]));
295 if (get_irn_pinned(n) != op_pin_state_floats)
296 fprintf(F, "\n volatile");
304 if (get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_consistent ||
305 get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_inconsistent )
306 if (get_irn_typeinfo_type(n) != firm_none_type)
307 ir_fprintf (F, " Analysed type: %s\n", get_irn_typeinfo_type(n));
310 void dump_graph_as_text(FILE *out, ir_graph *irg)
312 fprintf(out, "graph %s\n", get_irg_dump_name(irg));
315 static int need_nl = 1;
317 static bool is_init_string(ir_initializer_t const* const init, ir_type *const type)
319 ir_type *const element_type = get_array_element_type(type);
324 if (!is_Primitive_type(element_type))
327 mode = get_type_mode(element_type);
328 if (!mode_is_int(mode) || get_mode_size_bits(mode) != 8)
331 n = get_initializer_compound_n_entries(init);
332 for (i = 0; i != n; ++i) {
333 ir_initializer_t const* const val = get_initializer_compound_value(init, i);
334 ir_tarval* const tv = get_initializer_tarval_value(val);
337 if (!tarval_is_constant(tv))
340 v = get_tarval_long(tv);
341 if (v != 0 && (v < 0x07 || 0x0D < v) && v != 0x1B && (v < 0x20 || 0x80 <= v) && (v < 0xA0 || 0x100 <= v))
351 static void dump_ir_initializers_to_file(FILE *F, const char *prefix,
352 const ir_initializer_t *initializer,
359 fprintf(F, "\n%s ", prefix);
362 switch (get_initializer_kind(initializer)) {
363 case IR_INITIALIZER_NULL:
364 fprintf(F, "\t = <NOT_SET>");
366 case IR_INITIALIZER_TARVAL:
367 tv = get_initializer_tarval_value(initializer);
368 ir_fprintf(F, "\t = <TV>%F", tv);
370 case IR_INITIALIZER_CONST:
371 value = get_initializer_const_value(initializer);
372 ir_fprintf(F, "\t = %F", value);
374 case IR_INITIALIZER_COMPOUND:
375 if (is_Array_type(type)) {
376 size_t const n = get_initializer_compound_n_entries(initializer);
379 if (is_init_string(initializer, type)) {
380 fprintf(F, "\t[0...%u] = '", (unsigned)n - 1);
381 for (i = 0; i != n; ++i) {
382 ir_initializer_t const* const val = get_initializer_compound_value(initializer, i);
383 ir_tarval* const tv = get_initializer_tarval_value(val);
384 long const v = get_tarval_long(tv);
387 case 0x00: fprintf(F, "\\\\000"); break;
388 case 0x07: fprintf(F, "\\\\a"); break;
389 case 0x08: fprintf(F, "\\\\b"); break;
390 case 0x09: fprintf(F, "\\\\t"); break;
391 case 0x0A: fprintf(F, "\\\\n"); break;
392 case 0x0B: fprintf(F, "\\\\v"); break;
393 case 0x0C: fprintf(F, "\\\\f"); break;
394 case 0x0D: fprintf(F, "\\\\r"); break;
395 case 0x1B: fprintf(F, "\\\\033"); break;
396 case 0x22: fprintf(F, "\\\\\\\""); break;
397 case 0x5C: fprintf(F, "\\\\\\\\"); break;
398 default: fprintf(F, "%c", (unsigned char)v); break;
403 ir_type *const element_type = get_array_element_type(type);
405 for (i = 0; i < n; ++i) {
406 ir_initializer_t *sub_initializer
407 = get_initializer_compound_value(initializer, i);
410 fprintf(F, "\n%s ", prefix);
413 fprintf(F, "[%d]", (int) i);
414 dump_ir_initializers_to_file(F, prefix, sub_initializer, element_type);
419 assert(is_compound_type(type));
420 n = get_compound_n_members(type);
421 for (i = 0; i < n; ++i) {
422 ir_entity *member = get_compound_member(type, i);
423 ir_type *subtype = get_entity_type(member);
424 ir_initializer_t *sub_initializer;
426 assert(i < get_initializer_compound_n_entries(initializer));
428 = get_initializer_compound_value(initializer, i);
431 fprintf(F, "\n%s ", prefix);
434 ir_fprintf(F, ".%F", member);
435 dump_ir_initializers_to_file(F, prefix, sub_initializer, subtype);
440 panic("invalid ir_initializer kind found");
445 static void dump_entity_linkage(FILE *F, const ir_entity *entity)
447 ir_linkage linkage = get_entity_linkage(entity);
449 if (linkage == IR_LINKAGE_DEFAULT) {
450 fprintf(F, " default");
453 if (linkage & IR_LINKAGE_CONSTANT)
454 fprintf(F, " constant");
455 if (linkage & IR_LINKAGE_WEAK)
457 if (linkage & IR_LINKAGE_GARBAGE_COLLECT)
458 fprintf(F, " garbage_collect");
459 if (linkage & IR_LINKAGE_MERGE)
460 fprintf(F, " merge");
461 if (linkage & IR_LINKAGE_HIDDEN_USER)
462 fprintf(F, " hidden_user");
465 static void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, const char *prefix)
467 ir_type *owner, *type;
469 assert(is_entity(ent));
470 owner = get_entity_owner(ent);
471 type = get_entity_type(ent);
472 if (verbosity & dump_verbosity_onlynames) {
473 fprintf(F, "%sentity %s.%s (%ld)\n", prefix, get_compound_name(get_entity_owner(ent)),
474 get_entity_name(ent), get_entity_nr(ent));
478 if (verbosity & dump_verbosity_entattrs) {
479 fprintf(F, "%sentity %s (%ld)\n", prefix, get_entity_name(ent), get_entity_nr(ent));
480 ir_fprintf(F, "%s type: %+F\n", prefix, type);
481 ir_fprintf(F, "%s owner: %+F\n", prefix, owner);
483 if (is_Class_type(get_entity_owner(ent))) {
484 if (get_entity_n_overwrites(ent) > 0) {
486 fprintf(F, "%s overwrites:\n", prefix);
487 for (i = 0; i < get_entity_n_overwrites(ent); ++i) {
488 ir_entity *ov = get_entity_overwrites(ent, i);
489 ir_fprintf(F, "%s %d: %s of class %+F\n", prefix, i,
490 get_entity_name(ov), get_entity_owner(ov));
493 fprintf(F, "%s Does not overwrite other entities.\n", prefix);
495 if (get_entity_n_overwrittenby(ent) > 0) {
497 fprintf(F, "%s overwritten by:\n", prefix);
498 for (i = 0; i < get_entity_n_overwrittenby(ent); ++i) {
499 ir_entity *ov = get_entity_overwrittenby(ent, i);
500 ir_fprintf(F, "%s %d: %s of class %+F\n", prefix, i,
501 get_entity_name(ov), get_entity_owner(ov));
504 fprintf(F, "%s Is not overwritten by other entities.\n",
508 if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
510 fprintf(F, "%s transitive overwrites:\n", prefix);
511 for (ov = get_entity_trans_overwrites_first(ent);
513 ov = get_entity_trans_overwrites_next(ent)) {
514 ir_fprintf(F, "%s : %s of class %+F\n", prefix,
515 get_entity_name(ov), get_entity_owner(ov));
517 fprintf(F, "%s transitive overwritten by:\n", prefix);
518 for (ov = get_entity_trans_overwrittenby_first(ent);
520 ov = get_entity_trans_overwrittenby_next(ent)) {
521 ir_fprintf(F, "%s : %s of class %+F\n", prefix,
522 get_entity_name(ov), get_entity_owner(ov));
527 if (is_Method_type(get_entity_type(ent))) {
528 unsigned mask = get_entity_additional_properties(ent);
529 unsigned cc = get_method_calling_convention(get_entity_type(ent));
530 ir_graph *irg = get_entity_irg(ent);
533 fprintf(F, "%s estimated node count: %u\n", prefix, get_irg_estimated_node_cnt(irg));
534 fprintf(F, "%s maximum node index: %u\n", prefix, get_irg_last_idx(irg));
538 fprintf(F, "%s additional prop: ", prefix);
540 if (mask & mtp_property_const) fputs("const_function, ", F);
541 if (mask & mtp_property_pure) fputs("pure_function, ", F);
542 if (mask & mtp_property_noreturn) fputs("noreturn_function, ", F);
543 if (mask & mtp_property_nothrow) fputs("nothrow_function, ", F);
544 if (mask & mtp_property_naked) fputs("naked_function, ", F);
545 if (mask & mtp_property_malloc) fputs("malloc_function, ", F);
546 if (mask & mtp_property_returns_twice) fputs("weak_function, ", F);
547 if (mask & mtp_property_intrinsic) fputs("intrinsic_function, ", F);
548 if (mask & mtp_property_runtime) fputs("runtime_function, ", F);
549 if (mask & mtp_property_private) fputs("private_function, ", F);
550 if (mask & mtp_property_has_loop) fputs("has_loop_function, ", F);
553 fprintf(F, "%s calling convention: ", prefix);
554 if (cc & cc_reg_param) fputs("regparam, ", F);
555 if (cc & cc_this_call) fputs("thiscall, ", F);
556 if (cc & cc_compound_ret) fputs("compound_ret, ", F);
557 if (cc & cc_frame_on_caller_stk) fputs("frame on caller's stack, ", F);
558 cc &= ~(cc_compound_ret|cc_frame_on_caller_stk);
561 else if (IS_STDCALL(cc))
564 fputs(cc & cc_last_on_top ? "last param on top, " : "first param on top, ", F);
565 fputs(cc & cc_callee_clear_stk ? "callee clear stack" : "caller clear stack", F);
567 fprintf(F, "\n%s vtable number: %u\n", prefix, get_entity_vtable_number(ent));
569 } else { /* no entattrs */
570 ir_fprintf(F, "%s(%3d:%d) %+F: %s", prefix,
571 get_entity_offset(ent), get_entity_offset_bits_remainder(ent),
572 get_entity_type(ent), get_entity_name(ent));
573 if (is_Method_type(get_entity_type(ent))) fputs("(...)", F);
575 if (verbosity & dump_verbosity_accessStats) {
576 dump_entity_linkage(F, ent);
581 if (verbosity & dump_verbosity_entconsts) {
582 if (ent->initializer != NULL) {
583 const ir_initializer_t *initializer = get_entity_initializer(ent);
584 fprintf(F, "\n%s Initializers:", prefix);
586 dump_ir_initializers_to_file(F, prefix, initializer, get_entity_type(ent));
588 } else if (entity_has_compound_ent_values(ent)) {
590 fprintf(F, "%s compound values:", prefix);
591 for (i = 0; i < get_compound_ent_n_values(ent); ++i) {
593 compound_graph_path *path = get_compound_ent_value_path(ent, i);
594 ir_entity *ent0 = get_compound_graph_path_node(path, 0);
595 fprintf(F, "\n%s %3d:%d ", prefix, get_entity_offset(ent0), get_entity_offset_bits_remainder(ent0));
596 if (get_type_state(type) == layout_fixed)
597 fprintf(F, "(%3u:%u) ", get_compound_ent_value_offset_bytes(ent, i), get_compound_ent_value_offset_bit_remainder(ent, i));
598 fprintf(F, "%s", get_entity_name(ent));
599 for (j = 0; j < get_compound_graph_path_length(path); ++j) {
600 ir_entity *node = get_compound_graph_path_node(path, j);
601 fprintf(F, ".%s", get_entity_name(node));
602 if (is_Array_type(get_entity_owner(node)))
603 fprintf(F, "[%ld]", get_compound_graph_path_array_index(path, j));
606 dump_node_opcode(F, get_compound_ent_value(ent, i));
612 if (verbosity & dump_verbosity_entattrs) {
613 fprintf(F, "%s linkage:", prefix);
614 dump_entity_linkage(F, ent);
615 fprintf(F, "\n%s volatility: %s", prefix, get_volatility_name(get_entity_volatility(ent)));
616 fprintf(F, "\n%s aligned: %s", prefix, get_align_name(get_entity_aligned(ent)));
617 fprintf(F, "\n%s alignment: %u", prefix, get_entity_alignment(ent));
618 fprintf(F, "\n%s ld_name: %s", prefix, ent->ld_name ? get_entity_ld_name(ent) : "no yet set");
619 fprintf(F, "\n%s offset: %d bytes, %d rem bits", prefix, get_entity_offset(ent), get_entity_offset_bits_remainder(ent));
620 if (is_Method_type(get_entity_type(ent))) {
621 if (get_entity_irg(ent)) /* can be null */ {
622 fprintf(F, "\n%s irg = %ld", prefix, get_irg_graph_nr(get_entity_irg(ent)));
624 fprintf(F, "\n%s irg = NULL", prefix);
631 void dump_entity_to_file(FILE *out, ir_entity *ent)
633 dump_entity_to_file_prefix(out, ent, "");
637 void dump_type_to_file(FILE *F, ir_type *tp)
641 if ((is_Class_type(tp)) && (verbosity & dump_verbosity_noClassTypes)) return;
642 if ((is_Struct_type(tp)) && (verbosity & dump_verbosity_noStructTypes)) return;
643 if ((is_Union_type(tp)) && (verbosity & dump_verbosity_noUnionTypes)) return;
644 if ((is_Array_type(tp)) && (verbosity & dump_verbosity_noArrayTypes)) return;
645 if ((is_Pointer_type(tp)) && (verbosity & dump_verbosity_noPointerTypes)) return;
646 if ((is_Method_type(tp)) && (verbosity & dump_verbosity_noMethodTypes)) return;
647 if ((is_Primitive_type(tp)) && (verbosity & dump_verbosity_noPrimitiveTypes)) return;
648 if ((is_Enumeration_type(tp)) && (verbosity & dump_verbosity_noEnumerationTypes)) return;
650 ir_fprintf(F, "%+F", tp);
651 if (verbosity & dump_verbosity_onlynames) { fprintf(F, "\n"); return; }
653 switch (get_type_tpop_code(tp)) {
656 if ((verbosity & dump_verbosity_methods) || (verbosity & dump_verbosity_fields)) {
657 fprintf(F, "\n members:\n");
659 for (i = 0; i < get_class_n_members(tp); ++i) {
660 ir_entity *mem = get_class_member(tp, i);
661 if (((verbosity & dump_verbosity_methods) && is_Method_type(get_entity_type(mem))) ||
662 ((verbosity & dump_verbosity_fields) && !is_Method_type(get_entity_type(mem))) ) {
663 if (!(verbosity & dump_verbosity_nostatic)) {
664 dump_entity_to_file_prefix(F, mem, " ");
668 if (verbosity & dump_verbosity_typeattrs) {
669 fprintf(F, " supertypes: ");
670 for (i = 0; i < get_class_n_supertypes(tp); ++i) {
671 ir_type *stp = get_class_supertype(tp, i);
672 ir_fprintf(F, "\n %d %+F", i, stp);
674 fprintf(F, "\n subtypes: ");
675 for (i = 0; i < get_class_n_subtypes(tp); ++i) {
676 ir_type *stp = get_class_subtype(tp, i);
677 ir_fprintf(F, "\n %d %+F", i, stp);
680 if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
682 fprintf(F, "\n transitive supertypes: ");
683 for (stp = get_class_trans_supertype_first(tp);
685 stp = get_class_trans_supertype_next(tp)) {
686 ir_fprintf(F, "\n %+F", stp);
688 fprintf(F, "\n transitive subtypes: ");
689 for (stp = get_class_trans_subtype_first(tp);
691 stp = get_class_trans_subtype_next(tp)) {
692 ir_fprintf(F, "\n %+F", stp);
696 fprintf(F, "\n flags: ");
697 if (is_class_final(tp))
698 fprintf(F, "final, ");
699 if (is_class_interface(tp))
700 fprintf(F, "interface, ");
701 if (is_class_abstract(tp))
702 fprintf(F, "abstract, ");
709 if (verbosity & dump_verbosity_fields) fprintf(F, "\n members: ");
710 for (i = 0; i < get_compound_n_members(tp); ++i) {
711 ir_entity *mem = get_compound_member(tp, i);
712 if (verbosity & dump_verbosity_fields) {
713 dump_entity_to_file_prefix(F, mem, " ");
719 if (verbosity & dump_verbosity_typeattrs) {
721 ir_type *elem_tp = get_array_element_type(tp);
723 fprintf(F, "\n array ");
725 n_dim = get_array_n_dimensions(tp);
726 for (i = 0; i < n_dim; ++i) {
727 ir_node *lower, *upper;
729 lower = get_array_lower_bound(tp, i);
730 upper = get_array_upper_bound(tp, i);
734 if (is_Const(lower)) {
735 fprintf(F, "%ld .. ", get_tarval_long(get_Const_tarval(lower)));
737 dump_node_opcode(F, lower);
738 fprintf(F, " %ld .. ", get_irn_node_nr(lower));
741 if (is_Const(upper)) {
742 fprintf(F, "%ld]", get_tarval_long(get_Const_tarval(lower)));
744 dump_node_opcode(F, upper);
745 fprintf(F, " %ld]", get_irn_node_nr(upper));
748 ir_fprintf(F, " of <%+F>", elem_tp);
750 fprintf(F, "\n order: ");
751 for (i = 0; i < n_dim; ++i)
752 fprintf(F, "<%zu>", get_array_order(tp, i));
756 if (verbosity & dump_verbosity_fields) {
757 dump_entity_to_file_prefix(F, get_array_element_entity(tp),
764 if (verbosity & dump_verbosity_typeattrs) {
765 ir_type *tt = get_pointer_points_to_type(tp);
766 ir_fprintf(F, "\n points to %+F\n", tt);
771 if (verbosity & dump_verbosity_typeattrs) {
772 mtp_additional_properties mtp = get_method_additional_properties(tp);
773 unsigned cconv = get_method_calling_convention(tp);
774 fprintf(F, "\n variadicity: %s", get_variadicity_name(get_method_variadicity(tp)));
775 fprintf(F, "\n return types: %lu",
776 (unsigned long) get_method_n_ress(tp));
777 for (i = 0; i < get_method_n_ress(tp); ++i) {
778 ir_type *rtp = get_method_res_type(tp, i);
779 ir_fprintf(F, "\n %+F", rtp);
782 fprintf(F, "\n parameter types: %lu",
783 (unsigned long) get_method_n_params(tp));
784 for (i = 0; i < get_method_n_params(tp); ++i) {
785 ir_type *ptp = get_method_param_type(tp, i);
786 ir_fprintf(F, "\n %+F", ptp);
788 fprintf(F, "\n properties:");
789 if (mtp & mtp_property_const)
791 if (mtp & mtp_property_pure)
793 if (mtp & mtp_property_noreturn)
794 fputs(" noreturn", F);
795 if (mtp & mtp_property_nothrow)
796 fputs(" nothrow", F);
797 if (mtp & mtp_property_naked)
799 if (mtp & mtp_property_malloc)
801 if (mtp & mtp_property_returns_twice)
802 fputs(" returns_twice", F);
803 if (mtp & mtp_property_intrinsic)
804 fputs(" intrinsic", F);
805 if (mtp & mtp_property_runtime)
806 fputs(" runtime", F);
807 if (mtp & mtp_property_private)
808 fputs(" private", F);
809 if (mtp & mtp_property_has_loop)
810 fputs(" has_Loop", F);
812 fprintf(F, "\n calling convention:");
813 if (cconv & cc_reg_param)
814 fputs(" regparam", F);
815 if (cconv & cc_last_on_top)
816 fputs(" last_on_top", F);
817 if (cconv & cc_callee_clear_stk)
818 fputs(" calle_clear_stk", F);
819 if (cconv & cc_this_call)
820 fputs(" this_call", F);
821 if (cconv & cc_compound_ret)
822 fputs(" compound_ret", F);
823 if (cconv & cc_frame_on_caller_stk)
824 fputs(" frame_on_caller_stk", F);
825 if (cconv & cc_fpreg_param)
826 fputs(" fpreg_param", F);
828 if (get_method_variadicity(tp)) {
829 fprintf(F, "\n ...");
836 if (verbosity & dump_verbosity_typeattrs) {
837 ir_type *base_tp = get_primitive_base_type(tp);
839 ir_fprintf(F, "\n base type: %+F", tp);
850 if (verbosity & dump_verbosity_typeattrs) {
851 fprintf(F, ": details not implemented\n");
855 fprintf(F, " state: %s,\n", get_type_state_name(get_type_state(tp)));
856 fprintf(F, " size: %2u Bytes,\n", get_type_size_bytes(tp));
857 fprintf(F, " alignment: %2u Bytes,\n", get_type_alignment_bytes(tp));
858 if (is_atomic_type(tp) || is_Method_type(tp))
859 fprintf(F, " mode: %s,\n", get_mode_name(get_type_mode(tp)));
864 void dump_types_as_text(FILE *out)
866 size_t i, n_types = get_irp_n_types();
868 for (i = 0; i < n_types; ++i) {
869 ir_type *type = get_irp_type(i);
870 dump_type_to_file(out, type);
874 void dump_globals_as_text(FILE *out)
876 ir_type *global_type = get_glob_type();
877 size_t n_members = get_class_n_members(global_type);
880 for (i = 0; i < n_members; ++i) {
881 ir_entity *entity = get_class_member(global_type, i);
882 dump_entity_to_file(out, entity);