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"
48 static ir_dump_verbosity_t verbosity = dump_verbosity_max;
50 void ir_set_dump_verbosity(ir_dump_verbosity_t new_verbosity)
52 verbosity = new_verbosity;
55 ir_dump_verbosity_t ir_get_dump_verbosity(void)
60 /* Write the irnode and all its attributes to the file passed. */
61 void dump_irnode_to_file(FILE *F, ir_node *n)
67 dump_node_opcode(F, n);
68 fprintf(F, " %ld\n", get_irn_node_nr(n));
70 fprintf(F, " index: %u\n", get_irn_idx(n));
71 if (ir_get_dump_flags() & ir_dump_flag_analysed_types)
72 fprintf (F, " addr: %p\n", (void *)n);
73 fprintf (F, " mode: %s\n", get_mode_name(get_irn_mode(n)));
74 fprintf (F, " visited: %lu\n", get_irn_visited(n));
76 if (irg != get_const_code_irg())
77 fprintf (F, " irg: %s\n", get_ent_dump_name(get_irg_entity(irg)));
79 if (get_irn_pinned(n) == op_pin_state_floats &&
80 get_irg_pinned(get_irn_irg(n)) == op_pin_state_floats) {
81 fprintf(F, " node was pinned in ");
82 dump_node_opcode(F, get_irn_n(n, -1));
83 fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, -1)));
86 fprintf(F, " arity: %d\n", get_irn_arity(n));
87 /* show all predecessor nodes */
88 fprintf(F, " pred nodes:\n");
91 dump_node_opcode(F, get_irn_n(n, -1));
92 fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, -1)));
97 for (i = 0; i < get_irn_arity(n); ++i) {
98 fprintf(F, " %d: %s ", i, is_backedge(n, i) ? "be" : " ");
99 dump_node_opcode(F, get_irn_n(n, i));
100 fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, i)));
104 fprintf(F, " Private Attributes:\n");
107 fprintf(F, " proj nr: %ld\n", get_Proj_proj(n));
109 if (is_fragile_op(n)) {
110 fprintf(F, " pinned state: %s\n", get_op_pin_state_name(get_irn_pinned(n)));
111 /* not dumped: frag array */
114 /* This is not nice, output it as a marker in the predecessor list. */
115 if (is_Block(n) || get_irn_op(n) == op_Phi) {
117 fprintf(F, " backedges:");
119 for (i = 0; i < get_irn_arity(n); i++)
120 if (is_backedge(n, i)) { fprintf(F, "%c %d", comma, i); comma = ','; }
124 /* Loop node. Someone else please tell me what's wrong ... */
125 if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO)) {
126 ir_loop *loop = get_irn_loop(n);
128 fprintf(F, " in loop %ld with depth %u\n",
129 get_loop_loop_nr(loop), get_loop_depth(loop));
134 switch (get_irn_opcode(n)) {
136 if (has_Block_entity(n))
137 fprintf(F, " Label: %lu\n", get_entity_label(get_Block_entity(n)));
138 fprintf(F, " block visited: %lu\n", get_Block_block_visited(n));
139 fprintf(F, " block marked: %u\n", get_Block_mark(n));
140 if (is_irg_state(get_irn_irg(n), IR_GRAPH_STATE_CONSISTENT_DOMINANCE)) {
141 fprintf(F, " dom depth %d\n", get_Block_dom_depth(n));
142 fprintf(F, " domtree pre num %u\n", get_Block_dom_tree_pre_num(n));
143 fprintf(F, " max subtree pre num %u\n", get_Block_dom_max_subtree_pre_num(n));
145 if (is_irg_state(get_irn_irg(n), IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE)) {
146 fprintf(F, " pdom depth %d\n", get_Block_postdom_depth(n));
147 fprintf(F, " pdomtree pre num %u\n", get_Block_pdom_tree_pre_num(n));
148 fprintf(F, " max pdomsubtree pre num %u\n", get_Block_pdom_max_subtree_pre_num(n));
151 /* not dumped: graph_arr */
152 /* not dumped: mature */
156 ir_type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
157 ir_fprintf(F, " start of method of type %+F\n", tp);
158 for (i = 0; i < get_method_n_params(tp); ++i)
159 ir_fprintf(F, " param %d type: %+F\n", i, get_method_param_type(tp, i));
162 fprintf(F, " default ProjNr: %ld\n", get_Cond_default_proj(n));
163 if (get_Cond_jmp_pred(n) != COND_JMP_PRED_NONE) {
164 fprintf(F, " jump prediction: %s\n",
165 get_cond_jmp_predicate_name(get_Cond_jmp_pred(n)));
169 ir_fprintf(F, " allocating entity of type: %+F\n", get_Alloc_type(n));
170 fprintf(F, " allocating on: the %s\n", (get_Alloc_where(n) == stack_alloc) ? "stack" : "heap");
173 ir_fprintf(F, " freeing entity of type %+F\n", get_Free_type(n));
174 fprintf(F, " allocated on: the %s\n", (get_Free_where(n) == stack_alloc) ? "stack" : "heap");
177 ir_entity *ent = get_Sel_entity(n);
179 fprintf(F, " Selecting entity %s (%ld)\n", get_entity_name(ent), get_entity_nr(ent));
180 ir_fprintf(F, " of type %+F\n", get_entity_type(ent));
181 ir_fprintf(F, " with owner %+F.\n", get_entity_owner(ent));
183 fprintf(F, " <NULL entity>\n");
187 ir_type *tp = get_Call_type(n);
188 if (get_Call_tail_call(n))
189 fprintf(F, " tail call\n");
190 ir_fprintf(F, " calling method of type %+F\n", tp);
191 if (get_unknown_type() != tp) {
193 for (i = 0; i < get_method_n_params(tp); ++i)
194 ir_fprintf(F, " param %d type: %+F\n", i, get_method_param_type(tp, i));
195 for (i = 0; i < get_method_n_ress(tp); ++i)
196 ir_fprintf(F, " result %d type: %+F\n", i, get_method_res_type(tp, i));
198 if (Call_has_callees(n)) {
200 fprintf(F, " possible callees:\n");
201 for (i = 0; i < get_Call_n_callees(n); i++) {
202 ir_fprintf(F, " %zu: %s\n", i, get_ent_dump_name(get_Call_callee(n, i)));
207 ir_fprintf(F, " cast to type: %+F\n", get_Cast_type(n));
210 ir_relation relation = get_Cmp_relation(n);
211 ir_fprintf(F, " relation: %s\n", get_relation_string(relation));
215 ir_type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
216 ir_fprintf(F, " return in method of type %+F\n", tp);
217 for (i = 0; i < get_method_n_ress(tp); ++i) {
218 ir_fprintf(F, " result %d type: %+F\n", i,
219 get_method_res_type(tp, i));
223 switch (get_SymConst_kind(n)) {
224 case symconst_addr_ent:
225 fprintf(F, " kind: addr_ent\n");
226 fprintf(F, " entity: ");
227 dump_entity_to_file(F, get_SymConst_entity(n));
229 case symconst_ofs_ent:
230 fprintf(F, " kind: offset\n");
231 fprintf(F, " entity: ");
232 dump_entity_to_file(F, get_SymConst_entity(n));
234 case symconst_type_tag:
235 fprintf(F, " kind: type_tag\n");
236 fprintf(F, " type: ");
237 dump_type_to_file(F, get_SymConst_type(n));
239 case symconst_type_size:
240 fprintf(F, " kind: size\n");
241 fprintf(F, " type: ");
242 dump_type_to_file(F, get_SymConst_type(n));
244 case symconst_type_align:
245 fprintf(F, " kind: alignment\n");
246 fprintf(F, " type: ");
247 dump_type_to_file(F, get_SymConst_type(n));
249 case symconst_enum_const:
250 fprintf(F, " kind: enumeration\n");
251 fprintf(F, " name: %s\n", get_enumeration_const_name(get_SymConst_enum(n)));
256 fprintf(F, " mode of loaded value: %s\n", get_mode_name_ex(get_Load_mode(n), NULL));
257 fprintf(F, " volatility: %s\n", get_volatility_name(get_Load_volatility(n)));
258 fprintf(F, " align: %s\n", get_align_name(get_Load_unaligned(n)));
261 fprintf(F, " volatility: %s\n", get_volatility_name(get_Store_volatility(n)));
262 fprintf(F, " align: %s\n", get_align_name(get_Store_unaligned(n)));
265 fprintf(F, " compare operation: %s\n", get_relation_string(get_Confirm_relation(n)));
268 const ir_asm_constraint *cons;
272 fprintf(F, " assembler text: %s", get_id_str(get_ASM_text(n)));
273 l = get_ASM_n_input_constraints(n);
276 fprintf(F, "\n inputs: ");
277 cons = get_ASM_input_constraints(n);
278 for (i = 0; i < l; ++i)
279 fprintf(F, "%%%u %s ", cons[i].pos, get_id_str(cons[i].constraint));
281 l = get_ASM_n_output_constraints(n);
284 fprintf(F, "\n outputs: ");
285 cons = get_ASM_output_constraints(n);
286 for (i = 0; i < l; ++i)
287 fprintf(F, "%%%u %s ", cons[i].pos, get_id_str(cons[i].constraint));
289 l = get_ASM_n_clobbers(n);
292 fprintf(F, "\n clobber: ");
293 clobber = get_ASM_clobbers(n);
294 for (i = 0; i < l; ++i)
295 fprintf(F, "%s ", get_id_str(clobber[i]));
297 if (get_irn_pinned(n) != op_pin_state_floats)
298 fprintf(F, "\n volatile");
306 vrp_info = vrp_get_info(n);
311 if (get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_consistent ||
312 get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_inconsistent )
313 if (get_irn_typeinfo_type(n) != firm_none_type)
314 ir_fprintf (F, " Analysed type: %s\n", get_irn_typeinfo_type(n));
317 void dump_graph_as_text(FILE *out, ir_graph *irg)
319 fprintf(out, "graph %s\n", get_irg_dump_name(irg));
322 static int need_nl = 1;
327 static void dump_ir_initializers_to_file(FILE *F, const char *prefix,
328 const ir_initializer_t *initializer,
335 fprintf(F, "\n%s ", prefix);
338 switch (get_initializer_kind(initializer)) {
339 case IR_INITIALIZER_NULL:
340 fprintf(F, "\t = <NOT_SET>");
342 case IR_INITIALIZER_TARVAL:
343 tv = get_initializer_tarval_value(initializer);
344 ir_fprintf(F, "\t = <TV>%F", tv);
346 case IR_INITIALIZER_CONST:
347 value = get_initializer_const_value(initializer);
348 ir_fprintf(F, "\t = %F", value);
350 case IR_INITIALIZER_COMPOUND:
351 if (is_Array_type(type)) {
352 size_t i, n = get_initializer_compound_n_entries(initializer);
353 ir_type *element_type = get_array_element_type(type);
354 for (i = 0; i < n; ++i) {
355 ir_initializer_t *sub_initializer
356 = get_initializer_compound_value(initializer, i);
359 fprintf(F, "\n%s ", prefix);
362 fprintf(F, "[%d]", (int) i);
363 dump_ir_initializers_to_file(F, prefix, sub_initializer, element_type);
367 assert(is_compound_type(type));
368 n = get_compound_n_members(type);
369 for (i = 0; i < n; ++i) {
370 ir_entity *member = get_compound_member(type, i);
371 ir_type *subtype = get_entity_type(member);
372 ir_initializer_t *sub_initializer;
374 assert(i < get_initializer_compound_n_entries(initializer));
376 = get_initializer_compound_value(initializer, i);
379 fprintf(F, "\n%s ", prefix);
382 ir_fprintf(F, ".%F", member);
383 dump_ir_initializers_to_file(F, prefix, sub_initializer, subtype);
388 panic("invalid ir_initializer kind found");
393 static void dump_entity_linkage(FILE *F, const ir_entity *entity)
395 ir_linkage linkage = get_entity_linkage(entity);
397 if (linkage == IR_LINKAGE_DEFAULT) {
398 fprintf(F, " default");
401 if (linkage & IR_LINKAGE_CONSTANT)
402 fprintf(F, " constant");
403 if (linkage & IR_LINKAGE_WEAK)
405 if (linkage & IR_LINKAGE_GARBAGE_COLLECT)
406 fprintf(F, " garbage_collect");
407 if (linkage & IR_LINKAGE_MERGE)
408 fprintf(F, " merge");
409 if (linkage & IR_LINKAGE_HIDDEN_USER)
410 fprintf(F, " hidden_user");
413 static void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, const char *prefix)
415 ir_type *owner, *type;
417 assert(is_entity(ent));
418 owner = get_entity_owner(ent);
419 type = get_entity_type(ent);
420 if (verbosity & dump_verbosity_onlynames) {
421 fprintf(F, "%sentity %s.%s (%ld)\n", prefix, get_compound_name(get_entity_owner(ent)),
422 get_entity_name(ent), get_entity_nr(ent));
426 if (verbosity & dump_verbosity_entattrs) {
427 fprintf(F, "%sentity %s (%ld)\n", prefix, get_entity_name(ent), get_entity_nr(ent));
428 ir_fprintf(F, "%s type: %+F\n", prefix, type);
429 ir_fprintf(F, "%s owner: %+F\n", prefix, owner);
431 if (is_Class_type(get_entity_owner(ent))) {
432 if (get_entity_n_overwrites(ent) > 0) {
434 fprintf(F, "%s overwrites:\n", prefix);
435 for (i = 0; i < get_entity_n_overwrites(ent); ++i) {
436 ir_entity *ov = get_entity_overwrites(ent, i);
437 ir_fprintf(F, "%s %d: %s of class %+F\n", prefix, i,
438 get_entity_name(ov), get_entity_owner(ov));
441 fprintf(F, "%s Does not overwrite other entities.\n", prefix);
443 if (get_entity_n_overwrittenby(ent) > 0) {
445 fprintf(F, "%s overwritten by:\n", prefix);
446 for (i = 0; i < get_entity_n_overwrittenby(ent); ++i) {
447 ir_entity *ov = get_entity_overwrittenby(ent, i);
448 ir_fprintf(F, "%s %d: %s of class %+F\n", prefix, i,
449 get_entity_name(ov), get_entity_owner(ov));
452 fprintf(F, "%s Is not overwritten by other entities.\n",
456 if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
458 fprintf(F, "%s transitive overwrites:\n", prefix);
459 for (ov = get_entity_trans_overwrites_first(ent);
461 ov = get_entity_trans_overwrites_next(ent)) {
462 ir_fprintf(F, "%s : %s of class %+F\n", prefix,
463 get_entity_name(ov), get_entity_owner(ov));
465 fprintf(F, "%s transitive overwritten by:\n", prefix);
466 for (ov = get_entity_trans_overwrittenby_first(ent);
468 ov = get_entity_trans_overwrittenby_next(ent)) {
469 ir_fprintf(F, "%s : %s of class %+F\n", prefix,
470 get_entity_name(ov), get_entity_owner(ov));
475 if (is_Method_type(get_entity_type(ent))) {
476 unsigned mask = get_entity_additional_properties(ent);
477 unsigned cc = get_method_calling_convention(get_entity_type(ent));
478 ir_graph *irg = get_entity_irg(ent);
481 fprintf(F, "%s estimated node count: %u\n", prefix, get_irg_estimated_node_cnt(irg));
482 fprintf(F, "%s maximum node index: %u\n", prefix, get_irg_last_idx(irg));
486 fprintf(F, "%s additional prop: ", prefix);
488 if (mask & mtp_property_const) fputs("const_function, ", F);
489 if (mask & mtp_property_pure) fputs("pure_function, ", F);
490 if (mask & mtp_property_noreturn) fputs("noreturn_function, ", F);
491 if (mask & mtp_property_nothrow) fputs("nothrow_function, ", F);
492 if (mask & mtp_property_naked) fputs("naked_function, ", F);
493 if (mask & mtp_property_malloc) fputs("malloc_function, ", F);
494 if (mask & mtp_property_returns_twice) fputs("weak_function, ", F);
495 if (mask & mtp_property_intrinsic) fputs("intrinsic_function, ", F);
496 if (mask & mtp_property_runtime) fputs("runtime_function, ", F);
497 if (mask & mtp_property_private) fputs("private_function, ", F);
498 if (mask & mtp_property_has_loop) fputs("has_loop_function, ", F);
501 fprintf(F, "%s calling convention: ", prefix);
502 if (cc & cc_reg_param) fputs("regparam, ", F);
503 if (cc & cc_this_call) fputs("thiscall, ", F);
504 if (cc & cc_compound_ret) fputs("compound_ret, ", F);
505 if (cc & cc_frame_on_caller_stk) fputs("frame on caller's stack, ", F);
506 cc &= ~(cc_compound_ret|cc_frame_on_caller_stk);
509 else if (IS_STDCALL(cc))
512 fputs(cc & cc_last_on_top ? "last param on top, " : "first param on top, ", F);
513 fputs(cc & cc_callee_clear_stk ? "callee clear stack" : "caller clear stack", F);
515 fprintf(F, "\n%s vtable number: %u\n", prefix, get_entity_vtable_number(ent));
517 } else { /* no entattrs */
518 ir_fprintf(F, "%s(%3d:%d) %+F: %s", prefix,
519 get_entity_offset(ent), get_entity_offset_bits_remainder(ent),
520 get_entity_type(ent), get_entity_name(ent));
521 if (is_Method_type(get_entity_type(ent))) fputs("(...)", F);
523 if (verbosity & dump_verbosity_accessStats) {
524 dump_entity_linkage(F, ent);
529 if (verbosity & dump_verbosity_entconsts) {
530 if (ent->initializer != NULL) {
531 const ir_initializer_t *initializer = get_entity_initializer(ent);
532 fprintf(F, "\n%s Initializers:", prefix);
534 dump_ir_initializers_to_file(F, prefix, initializer, get_entity_type(ent));
536 } else if (entity_has_compound_ent_values(ent)) {
538 fprintf(F, "%s compound values:", prefix);
539 for (i = 0; i < get_compound_ent_n_values(ent); ++i) {
541 compound_graph_path *path = get_compound_ent_value_path(ent, i);
542 ir_entity *ent0 = get_compound_graph_path_node(path, 0);
543 fprintf(F, "\n%s %3d:%d ", prefix, get_entity_offset(ent0), get_entity_offset_bits_remainder(ent0));
544 if (get_type_state(type) == layout_fixed)
545 fprintf(F, "(%3u:%u) ", get_compound_ent_value_offset_bytes(ent, i), get_compound_ent_value_offset_bit_remainder(ent, i));
546 fprintf(F, "%s", get_entity_name(ent));
547 for (j = 0; j < get_compound_graph_path_length(path); ++j) {
548 ir_entity *node = get_compound_graph_path_node(path, j);
549 fprintf(F, ".%s", get_entity_name(node));
550 if (is_Array_type(get_entity_owner(node)))
551 fprintf(F, "[%ld]", get_compound_graph_path_array_index(path, j));
554 dump_node_opcode(F, get_compound_ent_value(ent, i));
560 if (verbosity & dump_verbosity_entattrs) {
561 fprintf(F, "%s linkage:", prefix);
562 dump_entity_linkage(F, ent);
563 fprintf(F, "\n%s volatility: %s", prefix, get_volatility_name(get_entity_volatility(ent)));
564 fprintf(F, "\n%s aligned: %s", prefix, get_align_name(get_entity_aligned(ent)));
565 fprintf(F, "\n%s alignment: %u", prefix, get_entity_alignment(ent));
566 fprintf(F, "\n%s ld_name: %s", prefix, ent->ld_name ? get_entity_ld_name(ent) : "no yet set");
567 fprintf(F, "\n%s offset: %d bytes, %d rem bits", prefix, get_entity_offset(ent), get_entity_offset_bits_remainder(ent));
568 if (is_Method_type(get_entity_type(ent))) {
569 if (get_entity_irg(ent)) /* can be null */ {
570 fprintf(F, "\n%s irg = %ld", prefix, get_irg_graph_nr(get_entity_irg(ent)));
572 fprintf(F, "\n%s irg = NULL", prefix);
579 void dump_entity_to_file(FILE *out, ir_entity *ent)
581 dump_entity_to_file_prefix(out, ent, "");
585 void dump_type_to_file(FILE *F, ir_type *tp)
589 if ((is_Class_type(tp)) && (verbosity & dump_verbosity_noClassTypes)) return;
590 if ((is_Struct_type(tp)) && (verbosity & dump_verbosity_noStructTypes)) return;
591 if ((is_Union_type(tp)) && (verbosity & dump_verbosity_noUnionTypes)) return;
592 if ((is_Array_type(tp)) && (verbosity & dump_verbosity_noArrayTypes)) return;
593 if ((is_Pointer_type(tp)) && (verbosity & dump_verbosity_noPointerTypes)) return;
594 if ((is_Method_type(tp)) && (verbosity & dump_verbosity_noMethodTypes)) return;
595 if ((is_Primitive_type(tp)) && (verbosity & dump_verbosity_noPrimitiveTypes)) return;
596 if ((is_Enumeration_type(tp)) && (verbosity & dump_verbosity_noEnumerationTypes)) return;
598 ir_fprintf(F, "%+F", tp);
599 if (verbosity & dump_verbosity_onlynames) { fprintf(F, "\n"); return; }
601 switch (get_type_tpop_code(tp)) {
604 if ((verbosity & dump_verbosity_methods) || (verbosity & dump_verbosity_fields)) {
605 fprintf(F, "\n members:\n");
607 for (i = 0; i < get_class_n_members(tp); ++i) {
608 ir_entity *mem = get_class_member(tp, i);
609 if (((verbosity & dump_verbosity_methods) && is_Method_type(get_entity_type(mem))) ||
610 ((verbosity & dump_verbosity_fields) && !is_Method_type(get_entity_type(mem))) ) {
611 if (!(verbosity & dump_verbosity_nostatic)) {
612 dump_entity_to_file_prefix(F, mem, " ");
616 if (verbosity & dump_verbosity_typeattrs) {
617 fprintf(F, " supertypes: ");
618 for (i = 0; i < get_class_n_supertypes(tp); ++i) {
619 ir_type *stp = get_class_supertype(tp, i);
620 ir_fprintf(F, "\n %d %+F", i, stp);
622 fprintf(F, "\n subtypes: ");
623 for (i = 0; i < get_class_n_subtypes(tp); ++i) {
624 ir_type *stp = get_class_subtype(tp, i);
625 ir_fprintf(F, "\n %d %+F", i, stp);
628 if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
630 fprintf(F, "\n transitive supertypes: ");
631 for (stp = get_class_trans_supertype_first(tp);
633 stp = get_class_trans_supertype_next(tp)) {
634 ir_fprintf(F, "\n %+F", stp);
636 fprintf(F, "\n transitive subtypes: ");
637 for (stp = get_class_trans_subtype_first(tp);
639 stp = get_class_trans_subtype_next(tp)) {
640 ir_fprintf(F, "\n %+F", stp);
644 fprintf(F, "\n flags: ");
645 if (is_class_final(tp))
646 fprintf(F, "final, ");
647 if (is_class_interface(tp))
648 fprintf(F, "interface, ");
649 if (is_class_abstract(tp))
650 fprintf(F, "abstract, ");
657 if (verbosity & dump_verbosity_fields) fprintf(F, "\n members: ");
658 for (i = 0; i < get_compound_n_members(tp); ++i) {
659 ir_entity *mem = get_compound_member(tp, i);
660 if (verbosity & dump_verbosity_fields) {
661 dump_entity_to_file_prefix(F, mem, " ");
667 if (verbosity & dump_verbosity_typeattrs) {
669 ir_type *elem_tp = get_array_element_type(tp);
671 fprintf(F, "\n array ");
673 n_dim = get_array_n_dimensions(tp);
674 for (i = 0; i < n_dim; ++i) {
675 ir_node *lower, *upper;
677 lower = get_array_lower_bound(tp, i);
678 upper = get_array_upper_bound(tp, i);
682 if (is_Const(lower)) {
683 fprintf(F, "%ld .. ", get_tarval_long(get_Const_tarval(lower)));
685 dump_node_opcode(F, lower);
686 fprintf(F, " %ld .. ", get_irn_node_nr(lower));
689 if (is_Const(upper)) {
690 fprintf(F, "%ld]", get_tarval_long(get_Const_tarval(lower)));
692 dump_node_opcode(F, upper);
693 fprintf(F, " %ld]", get_irn_node_nr(upper));
696 ir_fprintf(F, " of <%+F>", elem_tp);
698 fprintf(F, "\n order: ");
699 for (i = 0; i < n_dim; ++i)
700 fprintf(F, "<%zu>", get_array_order(tp, i));
704 if (verbosity & dump_verbosity_fields) {
705 dump_entity_to_file_prefix(F, get_array_element_entity(tp),
712 if (verbosity & dump_verbosity_typeattrs) {
713 ir_type *tt = get_pointer_points_to_type(tp);
714 ir_fprintf(F, "\n points to %+F\n", tt);
719 if (verbosity & dump_verbosity_typeattrs) {
720 mtp_additional_properties mtp = get_method_additional_properties(tp);
721 unsigned cconv = get_method_calling_convention(tp);
722 fprintf(F, "\n variadicity: %s", get_variadicity_name(get_method_variadicity(tp)));
723 fprintf(F, "\n return types: %lu",
724 (unsigned long) get_method_n_ress(tp));
725 for (i = 0; i < get_method_n_ress(tp); ++i) {
726 ir_type *rtp = get_method_res_type(tp, i);
727 ir_fprintf(F, "\n %+F", rtp);
730 fprintf(F, "\n parameter types: %lu",
731 (unsigned long) get_method_n_params(tp));
732 for (i = 0; i < get_method_n_params(tp); ++i) {
733 ir_type *ptp = get_method_param_type(tp, i);
734 ir_fprintf(F, "\n %+F", ptp);
736 fprintf(F, "\n properties:");
737 if (mtp & mtp_property_const)
739 if (mtp & mtp_property_pure)
741 if (mtp & mtp_property_noreturn)
742 fputs(" noreturn", F);
743 if (mtp & mtp_property_nothrow)
744 fputs(" nothrow", F);
745 if (mtp & mtp_property_naked)
747 if (mtp & mtp_property_malloc)
749 if (mtp & mtp_property_returns_twice)
750 fputs(" returns_twice", F);
751 if (mtp & mtp_property_intrinsic)
752 fputs(" intrinsic", F);
753 if (mtp & mtp_property_runtime)
754 fputs(" runtime", F);
755 if (mtp & mtp_property_private)
756 fputs(" private", F);
757 if (mtp & mtp_property_has_loop)
758 fputs(" has_Loop", F);
760 fprintf(F, "\n calling convention:");
761 if (cconv & cc_reg_param)
762 fputs(" regparam", F);
763 if (cconv & cc_last_on_top)
764 fputs(" last_on_top", F);
765 if (cconv & cc_callee_clear_stk)
766 fputs(" calle_clear_stk", F);
767 if (cconv & cc_this_call)
768 fputs(" this_call", F);
769 if (cconv & cc_compound_ret)
770 fputs(" compound_ret", F);
771 if (cconv & cc_frame_on_caller_stk)
772 fputs(" frame_on_caller_stk", F);
773 if (cconv & cc_fpreg_param)
774 fputs(" fpreg_param", F);
776 if (get_method_variadicity(tp)) {
777 fprintf(F, "\n ...");
784 if (verbosity & dump_verbosity_typeattrs) {
785 ir_type *base_tp = get_primitive_base_type(tp);
787 ir_fprintf(F, "\n base type: %+F", tp);
798 if (verbosity & dump_verbosity_typeattrs) {
799 fprintf(F, ": details not implemented\n");
803 fprintf(F, " state: %s,\n", get_type_state_name(get_type_state(tp)));
804 fprintf(F, " size: %2u Bytes,\n", get_type_size_bytes(tp));
805 fprintf(F, " alignment: %2u Bytes,\n", get_type_alignment_bytes(tp));
806 if (is_atomic_type(tp) || is_Method_type(tp))
807 fprintf(F, " mode: %s,\n", get_mode_name(get_type_mode(tp)));
812 void dump_types_as_text(FILE *out)
814 size_t i, n_types = get_irp_n_types();
816 for (i = 0; i < n_types; ++i) {
817 ir_type *type = get_irp_type(i);
818 dump_type_to_file(out, type);
822 void dump_globals_as_text(FILE *out)
824 ir_type *global_type = get_glob_type();
825 size_t n_members = get_class_n_members(global_type);
828 for (i = 0; i < n_members; ++i) {
829 ir_entity *entity = get_class_member(global_type, i);
830 dump_entity_to_file(out, entity);