5 # include "libfirm/firm.h"
6 # include "irsimpletype.h"
7 # include "heapanal/heapanal.h"
9 /* boilerplate stuff: */
10 #include "libfirm/irvrfy.h"
11 #include "libfirm/trvrfy.h"
12 #include "libfirm/irdump.h"
19 * Class: firmjni_Heapanal
23 void Java_firmjni_Heapanal_initAnal (JNIEnv *env, jclass clazz)
25 /* from interprete.c: */
30 * Class: firmjni_Heapanal
34 void Java_firmjni_Heapanal_deInitAnal (JNIEnv *env, jclass clazz)
40 * Class: firmjni_Heapanal
44 void Java_firmjni_Heapanal_analHeap__I (JNIEnv *env, jclass clazz, jint fMethod)
46 ha_analyse_heap((entity *) fMethod, 0);
50 * Class: firmjni_Heapanal
54 void Java_firmjni_Heapanal_analHeap__ (JNIEnv *env, jclass clazz)
59 fprintf (stdout, "Hello, Heap!\n");
61 fprintf (stdout, "Ajacs Boilerplate:\n");
63 entity **free_methods = 0;
66 /* replace static constant fields by constants
67 @@@ This corrects some code that is invalid Firm!!!
68 Execute before irg_vrfy(). */
70 /* opt_load_const_static(); */
72 /* dump graphs as they come out of the front end */
73 dump_file_suffix = "-fe";
75 dump_class_hierarchy (true);
76 dump_all_ir_graphs(dump_ir_block_graph);
77 dump_all_ir_graphs(dump_ir_block_graph_w_types);
78 dump_all_ir_graphs(dump_cfg);
80 /* verify constructed graphs */
81 for (i = 0; i < get_irp_n_irgs(); i++)
82 irg_vrfy(get_irp_irg(i));
84 /* verify something */
89 * test loop construction intraprocedural
91 for (i = 0; i < get_irp_n_irgs(); i++) {
92 construct_backedges(get_irp_irg(i));
95 dump_loop_information();
96 dump_file_suffix = "-1.2-intra-loop";
97 dump_ir_block_graph(get_irp_irg(i));
98 dont_dump_loop_information();
99 dump_loop_tree(get_irp_irg(i), "-1.2-intra");
103 DDMG (get_irp_main_irg ());
104 assert(get_irp_main_irg());
105 assert(get_irg_ent(get_irp_main_irg()));
108 /** Do interprocedural optimizations **/
109 /* Analysis that builds the call graph and finds the free methods,
110 i.e. methods that are dereferenced.
111 Optimizes polymorphic calls.*/
112 cgana(&arr_len, &free_methods);
113 /* Remove methods that are never called. */
114 /* gc_irgs(arr_len, free_methods); */
115 /* Build the interprocedural dataflow representation */
116 cg_construct(arr_len, free_methods);
118 /* Test construction of interprocedural loop information */
119 /* construct_ip_backedges(); */
121 dump_loop_information();
122 dump_file_suffix = "-1.2-inter-loop";
123 dump_all_cg_block_graph();
124 dont_dump_loop_information();
125 dump_loop_tree(get_irp_main_irg(), "-1.2-inter");
128 fprintf (stdout, "HA:\n");
129 DDMG (get_irp_main_irg ());
131 set_max_chi_height(8); /* change ad lib */
132 set_initial_context_depth(4); /* change as needed */
133 ha_analyse_heap(get_irg_ent(get_irp_main_irg()), 1);
135 /* Remove the interprocedural dataflow representation */
139 /* verify optimized graphs */
140 for (i = 0; i < get_irp_n_irgs(); i++) {
141 irg_vrfy(get_irp_irg(i));
148 set_opt_dump_abstvals (1);
152 fprintf (stdout, "Bye, Heap!\n");
159 * Revision 1.3 2004/04/30 09:00:01 goetz
160 * added configure support for heap analyses
162 * Revision 1.2 2004/04/29 13:59:11 liekweg
163 * Removed C++-Style comments --flo
165 * Revision 1.1 2004/04/29 12:11:36 liekweg
166 * Moved ... to aux --flo
168 * Revision 1.1 2004/04/27 12:41:31 liekweg
169 * Fixed ir/ana/irouts.c ir/ir/ircons.h ir/ir/irdump.c --flo
170 * Added aux/Heapanal.c aux/Heapanal.java --flo