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 #include "field_temperature.h"
49 static ir_dump_verbosity_t verbosity = dump_verbosity_max;
51 void ir_set_dump_verbosity(ir_dump_verbosity_t new_verbosity)
53 verbosity = new_verbosity;
56 ir_dump_verbosity_t ir_get_dump_verbosity(void)
61 /* Write the irnode and all its attributes to the file passed. */
62 void dump_irnode_to_file(FILE *F, ir_node *n)
68 dump_node_opcode(F, n);
69 fprintf(F, " %ld\n", get_irn_node_nr(n));
71 fprintf(F, " index: %u\n", get_irn_idx(n));
72 if (ir_get_dump_flags() & ir_dump_flag_analysed_types)
73 fprintf (F, " addr: %p\n", (void *)n);
74 fprintf (F, " mode: %s\n", get_mode_name(get_irn_mode(n)));
75 fprintf (F, " visited: %lu\n", get_irn_visited(n));
77 if (irg != get_const_code_irg())
78 fprintf (F, " irg: %s\n", get_ent_dump_name(get_irg_entity(irg)));
80 if (get_irn_pinned(n) == op_pin_state_floats &&
81 get_irg_pinned(get_irn_irg(n)) == op_pin_state_floats) {
82 fprintf(F, " node was pinned in ");
83 dump_node_opcode(F, get_irn_n(n, -1));
84 fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, -1)));
87 fprintf(F, " arity: %d\n", get_irn_arity(n));
88 /* show all predecessor nodes */
89 fprintf(F, " pred nodes:\n");
92 dump_node_opcode(F, get_irn_n(n, -1));
93 fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, -1)));
98 for (i = 0; i < get_irn_arity(n); ++i) {
99 fprintf(F, " %d: %s ", i, is_backedge(n, i) ? "be" : " ");
100 dump_node_opcode(F, get_irn_n(n, i));
101 fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, i)));
105 fprintf(F, " Private Attributes:\n");
108 fprintf(F, " proj nr: %ld\n", get_Proj_proj(n));
110 if (is_fragile_op(n)) {
111 fprintf(F, " pinned state: %s\n", get_op_pin_state_name(get_irn_pinned(n)));
112 /* not dumped: frag array */
115 /* This is not nice, output it as a marker in the predecessor list. */
116 if (is_Block(n) || get_irn_op(n) == op_Phi) {
118 fprintf(F, " backedges:");
120 for (i = 0; i < get_irn_arity(n); i++)
121 if (is_backedge(n, i)) { fprintf(F, "%c %d", comma, i); comma = ','; }
125 /* Loop node. Someone else please tell me what's wrong ... */
126 if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO)) {
127 ir_loop *loop = get_irn_loop(n);
129 fprintf(F, " in loop %ld with depth %u\n",
130 get_loop_loop_nr(loop), get_loop_depth(loop));
135 switch (get_irn_opcode(n)) {
137 if (has_Block_entity(n))
138 fprintf(F, " Label: %lu\n", get_entity_label(get_Block_entity(n)));
139 fprintf(F, " block visited: %lu\n", get_Block_block_visited(n));
140 fprintf(F, " block marked: %u\n", get_Block_mark(n));
141 if (is_irg_state(get_irn_irg(n), IR_GRAPH_STATE_CONSISTENT_DOMINANCE)) {
142 fprintf(F, " dom depth %d\n", get_Block_dom_depth(n));
143 fprintf(F, " domtree pre num %u\n", get_Block_dom_tree_pre_num(n));
144 fprintf(F, " max subtree pre num %u\n", get_Block_dom_max_subtree_pre_num(n));
146 if (is_irg_state(get_irn_irg(n), IR_GRAPH_STATE_CONSISTENT_POSTDOMINANCE)) {
147 fprintf(F, " pdom depth %d\n", get_Block_postdom_depth(n));
148 fprintf(F, " pdomtree pre num %u\n", get_Block_pdom_tree_pre_num(n));
149 fprintf(F, " max pdomsubtree pre num %u\n", get_Block_pdom_max_subtree_pre_num(n));
152 fprintf(F, " Execution frequency statistics:\n");
153 if (get_irg_exec_freq_state(get_irn_irg(n)) != exec_freq_none)
154 fprintf(F, " procedure local evaluation: %8.2lf\n", get_irn_exec_freq(n));
156 /* not dumped: graph_arr */
157 /* not dumped: mature */
161 ir_type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
162 ir_fprintf(F, " start of method of type %+F\n", tp);
163 for (i = 0; i < get_method_n_params(tp); ++i)
164 ir_fprintf(F, " param %d type: %+F\n", i, get_method_param_type(tp, i));
167 fprintf(F, " default ProjNr: %ld\n", get_Cond_default_proj(n));
168 if (get_Cond_jmp_pred(n) != COND_JMP_PRED_NONE) {
169 fprintf(F, " jump prediction: %s\n",
170 get_cond_jmp_predicate_name(get_Cond_jmp_pred(n)));
174 ir_fprintf(F, " allocating entity of type: %+F\n", get_Alloc_type(n));
175 fprintf(F, " allocating on: the %s\n", (get_Alloc_where(n) == stack_alloc) ? "stack" : "heap");
178 ir_fprintf(F, " freeing entity of type %+F\n", get_Free_type(n));
179 fprintf(F, " allocated on: the %s\n", (get_Free_where(n) == stack_alloc) ? "stack" : "heap");
182 ir_entity *ent = get_Sel_entity(n);
184 fprintf(F, " Selecting entity %s (%ld)\n", get_entity_name(ent), get_entity_nr(ent));
185 ir_fprintf(F, " of type %+F\n", get_entity_type(ent));
186 ir_fprintf(F, " with owner %+F.\n", get_entity_owner(ent));
188 fprintf(F, " <NULL entity>\n");
192 ir_type *tp = get_Call_type(n);
193 if (get_Call_tail_call(n))
194 fprintf(F, " tail call\n");
195 ir_fprintf(F, " calling method of type %+F\n", tp);
196 if (get_unknown_type() != tp) {
198 for (i = 0; i < get_method_n_params(tp); ++i)
199 ir_fprintf(F, " param %d type: %+F\n", i, get_method_param_type(tp, i));
200 for (i = 0; i < get_method_n_ress(tp); ++i)
201 ir_fprintf(F, " result %d type: %+F\n", i, get_method_res_type(tp, i));
203 if (Call_has_callees(n)) {
205 fprintf(F, " possible callees:\n");
206 for (i = 0; i < get_Call_n_callees(n); i++) {
207 ir_fprintf(F, " %zu: %s\n", i, get_ent_dump_name(get_Call_callee(n, i)));
212 ir_fprintf(F, " cast to type: %+F\n", get_Cast_type(n));
215 ir_relation relation = get_Cmp_relation(n);
216 ir_fprintf(F, " relation: %s\n", get_relation_string(relation));
220 ir_type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
221 ir_fprintf(F, " return in method of type %+F\n", tp);
222 for (i = 0; i < get_method_n_ress(tp); ++i) {
223 ir_fprintf(F, " result %d type: %+F\n", i,
224 get_method_res_type(tp, i));
228 switch (get_SymConst_kind(n)) {
229 case symconst_addr_ent:
230 fprintf(F, " kind: addr_ent\n");
231 fprintf(F, " entity: ");
232 dump_entity_to_file(F, get_SymConst_entity(n));
234 case symconst_ofs_ent:
235 fprintf(F, " kind: offset\n");
236 fprintf(F, " entity: ");
237 dump_entity_to_file(F, get_SymConst_entity(n));
239 case symconst_type_tag:
240 fprintf(F, " kind: type_tag\n");
241 fprintf(F, " type: ");
242 dump_type_to_file(F, get_SymConst_type(n));
244 case symconst_type_size:
245 fprintf(F, " kind: size\n");
246 fprintf(F, " type: ");
247 dump_type_to_file(F, get_SymConst_type(n));
249 case symconst_type_align:
250 fprintf(F, " kind: alignment\n");
251 fprintf(F, " type: ");
252 dump_type_to_file(F, get_SymConst_type(n));
254 case symconst_enum_const:
255 fprintf(F, " kind: enumeration\n");
256 fprintf(F, " name: %s\n", get_enumeration_const_name(get_SymConst_enum(n)));
261 fprintf(F, " mode of loaded value: %s\n", get_mode_name_ex(get_Load_mode(n), NULL));
262 fprintf(F, " volatility: %s\n", get_volatility_name(get_Load_volatility(n)));
263 fprintf(F, " align: %s\n", get_align_name(get_Load_unaligned(n)));
266 fprintf(F, " volatility: %s\n", get_volatility_name(get_Store_volatility(n)));
267 fprintf(F, " align: %s\n", get_align_name(get_Store_unaligned(n)));
270 fprintf(F, " compare operation: %s\n", get_relation_string(get_Confirm_relation(n)));
273 const ir_asm_constraint *cons;
277 fprintf(F, " assembler text: %s", get_id_str(get_ASM_text(n)));
278 l = get_ASM_n_input_constraints(n);
281 fprintf(F, "\n inputs: ");
282 cons = get_ASM_input_constraints(n);
283 for (i = 0; i < l; ++i)
284 fprintf(F, "%%%u %s ", cons[i].pos, get_id_str(cons[i].constraint));
286 l = get_ASM_n_output_constraints(n);
289 fprintf(F, "\n outputs: ");
290 cons = get_ASM_output_constraints(n);
291 for (i = 0; i < l; ++i)
292 fprintf(F, "%%%u %s ", cons[i].pos, get_id_str(cons[i].constraint));
294 l = get_ASM_n_clobbers(n);
297 fprintf(F, "\n clobber: ");
298 clobber = get_ASM_clobbers(n);
299 for (i = 0; i < l; ++i)
300 fprintf(F, "%s ", get_id_str(clobber[i]));
302 if (get_irn_pinned(n) != op_pin_state_floats)
303 fprintf(F, "\n volatile");
311 vrp_info = vrp_get_info(n);
316 if (get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_consistent ||
317 get_irg_typeinfo_state(get_irn_irg(n)) == ir_typeinfo_inconsistent )
318 if (get_irn_typeinfo_type(n) != firm_none_type)
319 ir_fprintf (F, " Analysed type: %s\n", get_irn_typeinfo_type(n));
322 void dump_graph_as_text(FILE *out, ir_graph *irg)
324 fprintf(out, "graph %s\n", get_irg_dump_name(irg));
327 static int need_nl = 1;
332 static void dump_ir_initializers_to_file(FILE *F, const char *prefix,
333 const ir_initializer_t *initializer,
340 fprintf(F, "\n%s ", prefix);
343 switch (get_initializer_kind(initializer)) {
344 case IR_INITIALIZER_NULL:
345 fprintf(F, "\t = <NOT_SET>");
347 case IR_INITIALIZER_TARVAL:
348 tv = get_initializer_tarval_value(initializer);
349 ir_fprintf(F, "\t = <TV>%F", tv);
351 case IR_INITIALIZER_CONST:
352 value = get_initializer_const_value(initializer);
353 ir_fprintf(F, "\t = %F", value);
355 case IR_INITIALIZER_COMPOUND:
356 if (is_Array_type(type)) {
357 size_t i, n = get_initializer_compound_n_entries(initializer);
358 ir_type *element_type = get_array_element_type(type);
359 for (i = 0; i < n; ++i) {
360 ir_initializer_t *sub_initializer
361 = get_initializer_compound_value(initializer, i);
364 fprintf(F, "\n%s ", prefix);
367 fprintf(F, "[%d]", (int) i);
368 dump_ir_initializers_to_file(F, prefix, sub_initializer, element_type);
372 assert(is_compound_type(type));
373 n = get_compound_n_members(type);
374 for (i = 0; i < n; ++i) {
375 ir_entity *member = get_compound_member(type, i);
376 ir_type *subtype = get_entity_type(member);
377 ir_initializer_t *sub_initializer;
379 assert(i < get_initializer_compound_n_entries(initializer));
381 = get_initializer_compound_value(initializer, i);
384 fprintf(F, "\n%s ", prefix);
387 ir_fprintf(F, ".%F", member);
388 dump_ir_initializers_to_file(F, prefix, sub_initializer, subtype);
393 panic("invalid ir_initializer kind found");
398 static void dump_entity_linkage(FILE *F, const ir_entity *entity)
400 ir_linkage linkage = get_entity_linkage(entity);
402 if (linkage == IR_LINKAGE_DEFAULT) {
403 fprintf(F, " default");
406 if (linkage & IR_LINKAGE_CONSTANT)
407 fprintf(F, " constant");
408 if (linkage & IR_LINKAGE_WEAK)
410 if (linkage & IR_LINKAGE_GARBAGE_COLLECT)
411 fprintf(F, " garbage_collect");
412 if (linkage & IR_LINKAGE_MERGE)
413 fprintf(F, " merge");
414 if (linkage & IR_LINKAGE_HIDDEN_USER)
415 fprintf(F, " hidden_user");
418 static void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, const char *prefix)
420 ir_type *owner, *type;
422 assert(is_entity(ent));
423 owner = get_entity_owner(ent);
424 type = get_entity_type(ent);
425 if (verbosity & dump_verbosity_onlynames) {
426 fprintf(F, "%sentity %s.%s (%ld)\n", prefix, get_compound_name(get_entity_owner(ent)),
427 get_entity_name(ent), get_entity_nr(ent));
431 if (verbosity & dump_verbosity_entattrs) {
432 fprintf(F, "%sentity %s (%ld)\n", prefix, get_entity_name(ent), get_entity_nr(ent));
433 ir_fprintf(F, "%s type: %+F\n", prefix, type);
434 ir_fprintf(F, "%s owner: %+F\n", prefix, owner);
436 if (is_Class_type(get_entity_owner(ent))) {
437 if (get_entity_n_overwrites(ent) > 0) {
439 fprintf(F, "%s overwrites:\n", prefix);
440 for (i = 0; i < get_entity_n_overwrites(ent); ++i) {
441 ir_entity *ov = get_entity_overwrites(ent, i);
442 ir_fprintf(F, "%s %d: %s of class %+F\n", prefix, i,
443 get_entity_name(ov), get_entity_owner(ov));
446 fprintf(F, "%s Does not overwrite other entities.\n", prefix);
448 if (get_entity_n_overwrittenby(ent) > 0) {
450 fprintf(F, "%s overwritten by:\n", prefix);
451 for (i = 0; i < get_entity_n_overwrittenby(ent); ++i) {
452 ir_entity *ov = get_entity_overwrittenby(ent, i);
453 ir_fprintf(F, "%s %d: %s of class %+F\n", prefix, i,
454 get_entity_name(ov), get_entity_owner(ov));
457 fprintf(F, "%s Is not overwritten by other entities.\n",
461 if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
463 fprintf(F, "%s transitive overwrites:\n", prefix);
464 for (ov = get_entity_trans_overwrites_first(ent);
466 ov = get_entity_trans_overwrites_next(ent)) {
467 ir_fprintf(F, "%s : %s of class %+F\n", prefix,
468 get_entity_name(ov), get_entity_owner(ov));
470 fprintf(F, "%s transitive overwritten by:\n", prefix);
471 for (ov = get_entity_trans_overwrittenby_first(ent);
473 ov = get_entity_trans_overwrittenby_next(ent)) {
474 ir_fprintf(F, "%s : %s of class %+F\n", prefix,
475 get_entity_name(ov), get_entity_owner(ov));
480 if (is_Method_type(get_entity_type(ent))) {
481 unsigned mask = get_entity_additional_properties(ent);
482 unsigned cc = get_method_calling_convention(get_entity_type(ent));
483 ir_graph *irg = get_entity_irg(ent);
486 fprintf(F, "%s estimated node count: %u\n", prefix, get_irg_estimated_node_cnt(irg));
487 fprintf(F, "%s maximum node index: %u\n", prefix, get_irg_last_idx(irg));
491 fprintf(F, "%s additional prop: ", prefix);
493 if (mask & mtp_property_const) fputs("const_function, ", F);
494 if (mask & mtp_property_pure) fputs("pure_function, ", F);
495 if (mask & mtp_property_noreturn) fputs("noreturn_function, ", F);
496 if (mask & mtp_property_nothrow) fputs("nothrow_function, ", F);
497 if (mask & mtp_property_naked) fputs("naked_function, ", F);
498 if (mask & mtp_property_malloc) fputs("malloc_function, ", F);
499 if (mask & mtp_property_returns_twice) fputs("weak_function, ", F);
500 if (mask & mtp_property_intrinsic) fputs("intrinsic_function, ", F);
501 if (mask & mtp_property_runtime) fputs("runtime_function, ", F);
502 if (mask & mtp_property_private) fputs("private_function, ", F);
503 if (mask & mtp_property_has_loop) fputs("has_loop_function, ", F);
506 fprintf(F, "%s calling convention: ", prefix);
507 if (cc & cc_reg_param) fputs("regparam, ", F);
508 if (cc & cc_this_call) fputs("thiscall, ", F);
509 if (cc & cc_compound_ret) fputs("compound_ret, ", F);
510 if (cc & cc_frame_on_caller_stk) fputs("frame on caller's stack, ", F);
511 cc &= ~(cc_compound_ret|cc_frame_on_caller_stk);
514 else if (IS_STDCALL(cc))
517 fputs(cc & cc_last_on_top ? "last param on top, " : "first param on top, ", F);
518 fputs(cc & cc_callee_clear_stk ? "callee clear stack" : "caller clear stack", F);
520 fprintf(F, "\n%s vtable number: %u\n", prefix, get_entity_vtable_number(ent));
522 } else { /* no entattrs */
523 ir_fprintf(F, "%s(%3d:%d) %+F: %s", prefix,
524 get_entity_offset(ent), get_entity_offset_bits_remainder(ent),
525 get_entity_type(ent), get_entity_name(ent));
526 if (is_Method_type(get_entity_type(ent))) fputs("(...)", F);
528 if (verbosity & dump_verbosity_accessStats) {
529 dump_entity_linkage(F, ent);
534 if (verbosity & dump_verbosity_entconsts) {
535 if (ent->initializer != NULL) {
536 const ir_initializer_t *initializer = get_entity_initializer(ent);
537 fprintf(F, "\n%s Initializers:", prefix);
539 dump_ir_initializers_to_file(F, prefix, initializer, get_entity_type(ent));
541 } else if (entity_has_compound_ent_values(ent)) {
543 fprintf(F, "%s compound values:", prefix);
544 for (i = 0; i < get_compound_ent_n_values(ent); ++i) {
546 compound_graph_path *path = get_compound_ent_value_path(ent, i);
547 ir_entity *ent0 = get_compound_graph_path_node(path, 0);
548 fprintf(F, "\n%s %3d:%d ", prefix, get_entity_offset(ent0), get_entity_offset_bits_remainder(ent0));
549 if (get_type_state(type) == layout_fixed)
550 fprintf(F, "(%3u:%u) ", get_compound_ent_value_offset_bytes(ent, i), get_compound_ent_value_offset_bit_remainder(ent, i));
551 fprintf(F, "%s", get_entity_name(ent));
552 for (j = 0; j < get_compound_graph_path_length(path); ++j) {
553 ir_entity *node = get_compound_graph_path_node(path, j);
554 fprintf(F, ".%s", get_entity_name(node));
555 if (is_Array_type(get_entity_owner(node)))
556 fprintf(F, "[%ld]", get_compound_graph_path_array_index(path, j));
559 dump_node_opcode(F, get_compound_ent_value(ent, i));
565 if (verbosity & dump_verbosity_entattrs) {
566 fprintf(F, "%s linkage:", prefix);
567 dump_entity_linkage(F, ent);
568 fprintf(F, "\n%s volatility: %s", prefix, get_volatility_name(get_entity_volatility(ent)));
569 fprintf(F, "\n%s aligned: %s", prefix, get_align_name(get_entity_aligned(ent)));
570 fprintf(F, "\n%s alignment: %u", prefix, get_entity_alignment(ent));
571 fprintf(F, "\n%s ld_name: %s", prefix, ent->ld_name ? get_entity_ld_name(ent) : "no yet set");
572 fprintf(F, "\n%s offset: %d bytes, %d rem bits", prefix, get_entity_offset(ent), get_entity_offset_bits_remainder(ent));
573 if (is_Method_type(get_entity_type(ent))) {
574 if (get_entity_irg(ent)) /* can be null */ {
575 fprintf(F, "\n%s irg = %ld", prefix, get_irg_graph_nr(get_entity_irg(ent)));
577 fprintf(F, "\n%s irg = NULL", prefix);
584 void dump_entity_to_file(FILE *out, ir_entity *ent)
586 dump_entity_to_file_prefix(out, ent, "");
590 void dump_type_to_file(FILE *F, ir_type *tp)
594 if ((is_Class_type(tp)) && (verbosity & dump_verbosity_noClassTypes)) return;
595 if ((is_Struct_type(tp)) && (verbosity & dump_verbosity_noStructTypes)) return;
596 if ((is_Union_type(tp)) && (verbosity & dump_verbosity_noUnionTypes)) return;
597 if ((is_Array_type(tp)) && (verbosity & dump_verbosity_noArrayTypes)) return;
598 if ((is_Pointer_type(tp)) && (verbosity & dump_verbosity_noPointerTypes)) return;
599 if ((is_Method_type(tp)) && (verbosity & dump_verbosity_noMethodTypes)) return;
600 if ((is_Primitive_type(tp)) && (verbosity & dump_verbosity_noPrimitiveTypes)) return;
601 if ((is_Enumeration_type(tp)) && (verbosity & dump_verbosity_noEnumerationTypes)) return;
603 ir_fprintf(F, "%+F", tp);
604 if (verbosity & dump_verbosity_onlynames) { fprintf(F, "\n"); return; }
606 switch (get_type_tpop_code(tp)) {
609 if ((verbosity & dump_verbosity_methods) || (verbosity & dump_verbosity_fields)) {
610 fprintf(F, "\n members:\n");
612 for (i = 0; i < get_class_n_members(tp); ++i) {
613 ir_entity *mem = get_class_member(tp, i);
614 if (((verbosity & dump_verbosity_methods) && is_Method_type(get_entity_type(mem))) ||
615 ((verbosity & dump_verbosity_fields) && !is_Method_type(get_entity_type(mem))) ) {
616 if (!(verbosity & dump_verbosity_nostatic)) {
617 dump_entity_to_file_prefix(F, mem, " ");
621 if (verbosity & dump_verbosity_typeattrs) {
622 fprintf(F, " supertypes: ");
623 for (i = 0; i < get_class_n_supertypes(tp); ++i) {
624 ir_type *stp = get_class_supertype(tp, i);
625 ir_fprintf(F, "\n %d %+F", i, stp);
627 fprintf(F, "\n subtypes: ");
628 for (i = 0; i < get_class_n_subtypes(tp); ++i) {
629 ir_type *stp = get_class_subtype(tp, i);
630 ir_fprintf(F, "\n %d %+F", i, stp);
633 if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
635 fprintf(F, "\n transitive supertypes: ");
636 for (stp = get_class_trans_supertype_first(tp);
638 stp = get_class_trans_supertype_next(tp)) {
639 ir_fprintf(F, "\n %+F", stp);
641 fprintf(F, "\n transitive subtypes: ");
642 for (stp = get_class_trans_subtype_first(tp);
644 stp = get_class_trans_subtype_next(tp)) {
645 ir_fprintf(F, "\n %+F", stp);
649 fprintf(F, "\n flags: ");
650 if (is_class_final(tp))
651 fprintf(F, "final, ");
652 if (is_class_interface(tp))
653 fprintf(F, "interface, ");
654 if (is_class_abstract(tp))
655 fprintf(F, "abstract, ");
662 if (verbosity & dump_verbosity_fields) fprintf(F, "\n members: ");
663 for (i = 0; i < get_compound_n_members(tp); ++i) {
664 ir_entity *mem = get_compound_member(tp, i);
665 if (verbosity & dump_verbosity_fields) {
666 dump_entity_to_file_prefix(F, mem, " ");
672 if (verbosity & dump_verbosity_typeattrs) {
674 ir_type *elem_tp = get_array_element_type(tp);
676 fprintf(F, "\n array ");
678 n_dim = get_array_n_dimensions(tp);
679 for (i = 0; i < n_dim; ++i) {
680 ir_node *lower, *upper;
682 lower = get_array_lower_bound(tp, i);
683 upper = get_array_upper_bound(tp, i);
687 if (is_Const(lower)) {
688 fprintf(F, "%ld .. ", get_tarval_long(get_Const_tarval(lower)));
690 dump_node_opcode(F, lower);
691 fprintf(F, " %ld .. ", get_irn_node_nr(lower));
694 if (is_Const(upper)) {
695 fprintf(F, "%ld]", get_tarval_long(get_Const_tarval(lower)));
697 dump_node_opcode(F, upper);
698 fprintf(F, " %ld]", get_irn_node_nr(upper));
701 ir_fprintf(F, " of <%+F>", elem_tp);
703 fprintf(F, "\n order: ");
704 for (i = 0; i < n_dim; ++i)
705 fprintf(F, "<%zu>", get_array_order(tp, i));
709 if (verbosity & dump_verbosity_fields) {
710 dump_entity_to_file_prefix(F, get_array_element_entity(tp),
717 if (verbosity & dump_verbosity_typeattrs) {
718 ir_type *tt = get_pointer_points_to_type(tp);
719 ir_fprintf(F, "\n points to %+F\n", tt);
724 if (verbosity & dump_verbosity_typeattrs) {
725 mtp_additional_properties mtp = get_method_additional_properties(tp);
726 unsigned cconv = get_method_calling_convention(tp);
727 fprintf(F, "\n variadicity: %s", get_variadicity_name(get_method_variadicity(tp)));
728 fprintf(F, "\n return types: %lu",
729 (unsigned long) get_method_n_ress(tp));
730 for (i = 0; i < get_method_n_ress(tp); ++i) {
731 ir_type *rtp = get_method_res_type(tp, i);
732 ir_fprintf(F, "\n %+F", rtp);
735 fprintf(F, "\n parameter types: %lu",
736 (unsigned long) get_method_n_params(tp));
737 for (i = 0; i < get_method_n_params(tp); ++i) {
738 ir_type *ptp = get_method_param_type(tp, i);
739 ir_fprintf(F, "\n %+F", ptp);
741 fprintf(F, "\n properties:");
742 if (mtp & mtp_property_const)
744 if (mtp & mtp_property_pure)
746 if (mtp & mtp_property_noreturn)
747 fputs(" noreturn", F);
748 if (mtp & mtp_property_nothrow)
749 fputs(" nothrow", F);
750 if (mtp & mtp_property_naked)
752 if (mtp & mtp_property_malloc)
754 if (mtp & mtp_property_returns_twice)
755 fputs(" returns_twice", F);
756 if (mtp & mtp_property_intrinsic)
757 fputs(" intrinsic", F);
758 if (mtp & mtp_property_runtime)
759 fputs(" runtime", F);
760 if (mtp & mtp_property_private)
761 fputs(" private", F);
762 if (mtp & mtp_property_has_loop)
763 fputs(" has_Loop", F);
765 fprintf(F, "\n calling convention:");
766 if (cconv & cc_reg_param)
767 fputs(" regparam", F);
768 if (cconv & cc_last_on_top)
769 fputs(" last_on_top", F);
770 if (cconv & cc_callee_clear_stk)
771 fputs(" calle_clear_stk", F);
772 if (cconv & cc_this_call)
773 fputs(" this_call", F);
774 if (cconv & cc_compound_ret)
775 fputs(" compound_ret", F);
776 if (cconv & cc_frame_on_caller_stk)
777 fputs(" frame_on_caller_stk", F);
778 if (cconv & cc_fpreg_param)
779 fputs(" fpreg_param", F);
781 if (get_method_variadicity(tp)) {
782 fprintf(F, "\n ...");
789 if (verbosity & dump_verbosity_typeattrs) {
790 ir_type *base_tp = get_primitive_base_type(tp);
792 ir_fprintf(F, "\n base type: %+F", tp);
803 if (verbosity & dump_verbosity_typeattrs) {
804 fprintf(F, ": details not implemented\n");
808 fprintf(F, " state: %s,\n", get_type_state_name(get_type_state(tp)));
809 fprintf(F, " size: %2u Bytes,\n", get_type_size_bytes(tp));
810 fprintf(F, " alignment: %2u Bytes,\n", get_type_alignment_bytes(tp));
811 if (is_atomic_type(tp) || is_Method_type(tp))
812 fprintf(F, " mode: %s,\n", get_mode_name(get_type_mode(tp)));
817 void dump_types_as_text(FILE *out)
819 size_t i, n_types = get_irp_n_types();
821 for (i = 0; i < n_types; ++i) {
822 ir_type *type = get_irp_type(i);
823 dump_type_to_file(out, type);
827 void dump_globals_as_text(FILE *out)
829 ir_type *global_type = get_glob_type();
830 size_t n_members = get_class_n_members(global_type);
833 for (i = 0; i < n_members; ++i) {
834 ir_entity *entity = get_class_member(global_type, i);
835 dump_entity_to_file(out, entity);