adapted to new semantics
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Sat, 14 Aug 2004 10:09:55 +0000 (10:09 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Sat, 14 Aug 2004 10:09:55 +0000 (10:09 +0000)
[r3711]

firmjni/auxilliary/Heapanal.c
firmjni/testprograms/Empty.java
firmjni/testprograms/IfElseExample.java
firmjni/testprograms/run-results.txt

index 2a9b6bf..1bb328c 100644 (file)
@@ -2,14 +2,14 @@
 
 # include "Heapanal.h"
 
-# include "libfirm/firm.h"
+# include "firm.h"
 # include "irsimpletype.h"
 # include "heapanal/heapanal.h"
 
 /*  boilerplate stuff: */
-#include "libfirm/irvrfy.h"
-#include "libfirm/trvrfy.h"
-#include "libfirm/irdump.h"
+#include "irvrfy.h"
+#include "trvrfy.h"
+#include "irdump.h"
 
 
 /*  I/O: */
@@ -70,12 +70,12 @@ void Java_firmjni_Heapanal_analHeap__ (JNIEnv *env, jclass clazz)
     /*  opt_load_const_static(); */
 
     /* dump graphs as they come out of the front end */
-    dump_file_suffix = "-fe";
-    dump_all_types ();
-    dump_class_hierarchy (true);
-    dump_all_ir_graphs(dump_ir_block_graph);
-    dump_all_ir_graphs(dump_ir_block_graph_w_types);
-    dump_all_ir_graphs(dump_cfg);
+    char *suffix = "-fe";
+    dump_all_types (suffix);
+    dump_class_hierarchy (true, suffix);
+    dump_all_ir_graphs(dump_ir_block_graph, suffix);
+    dump_all_ir_graphs(dump_ir_block_graph_w_types, suffix);
+    dump_all_ir_graphs(dump_cfg, suffix);
 
     /* verify constructed graphs */
     for (i = 0; i < get_irp_n_irgs(); i++)
@@ -93,8 +93,7 @@ void Java_firmjni_Heapanal_analHeap__ (JNIEnv *env, jclass clazz)
 
       if (1) {
         dump_loop_information();
-        dump_file_suffix = "-1.2-intra-loop";
-        dump_ir_block_graph(get_irp_irg(i));
+        dump_ir_block_graph(get_irp_irg(i), "-1.2-intra-loop");
         dont_dump_loop_information();
         dump_loop_tree(get_irp_irg(i), "-1.2-intra");
       }
@@ -102,14 +101,14 @@ void Java_firmjni_Heapanal_analHeap__ (JNIEnv *env, jclass clazz)
 
     DDMG (get_irp_main_irg ());
     assert(get_irp_main_irg());
-    assert(get_irg_ent(get_irp_main_irg()));
+    assert(get_irg_entity(get_irp_main_irg()));
 
 
     /** Do interprocedural optimizations **/
     /* Analysis that builds the call graph and finds the free methods,
        i.e. methods that are dereferenced.
        Optimizes polymorphic calls.*/
-    cgana(&arr_len, &free_methods);
+    cgana(&arr_len, &free_methods, 0);
     /* Remove methods that are never called. */
     /*  gc_irgs(arr_len, free_methods); */
     /* Build the interprocedural dataflow representation */
@@ -119,8 +118,7 @@ void Java_firmjni_Heapanal_analHeap__ (JNIEnv *env, jclass clazz)
     /*  construct_ip_backedges(); */
 
     dump_loop_information();
-    dump_file_suffix = "-1.2-inter-loop";
-    dump_all_cg_block_graph();
+    dump_all_cg_block_graph("-1.2-inter-loop");
     dont_dump_loop_information();
     dump_loop_tree(get_irp_main_irg(), "-1.2-inter");
 
@@ -130,7 +128,7 @@ void Java_firmjni_Heapanal_analHeap__ (JNIEnv *env, jclass clazz)
 
     set_max_chi_height(8);  /* change ad lib */
     set_initial_context_depth(4);   /* change as needed */
-    ha_analyse_heap(get_irg_ent(get_irp_main_irg()), 1);
+    ha_analyse_heap(get_irg_entity(get_irp_main_irg()), 1);
 
     /* Remove the interprocedural dataflow representation */
     free(free_methods);
@@ -156,6 +154,9 @@ void Java_firmjni_Heapanal_analHeap__ (JNIEnv *env, jclass clazz)
 
 /*
  * $Log$
+ * Revision 1.4  2004/08/14 10:09:52  goetz
+ * adapted to new semantics
+ *
  * Revision 1.3  2004/04/30 09:00:01  goetz
  * added configure support for heap analyses
  *
index 9c54e6b..895b53d 100644 (file)
@@ -40,7 +40,7 @@ class Empty {
        int owner = Irprog.getGlobType();
 
        /* The type of the method */
-       int name = Ident.idFromStr("EMPTY_main", 10);
+       int name = Ident.newIdFromStr("EMPTY_main");
        int proc_main = Type.newTypeMethod(name, 0, 0);
        /* An entity representing the method.  Owner of the entity is the global
           class type mentioned above. */
@@ -65,21 +65,21 @@ class Empty {
 
        /* Now we generated all instructions for this block and all its predecessor
         * blocks so we can mature it.  (There are not too much.) */
-       Ircons.matureBlock (Irgraph.getIrgCurrentBlock(irg));
+       Ircons.matureImmBlock (Irgraph.getIrgCurrentBlock(irg));
 
        /* This adds the in edge of the end block which originates at the return statement.
         * The return node passes controlflow to the end block.  */
-       Ircons.addInEdge (Irgraph.getIrgEndBlock(irg), x);
+       Ircons.addImmBlockPred (Irgraph.getIrgEndBlock(irg), x);
        /* Now we can mature the end block as all it's predecessors are known. */
-       Ircons.matureBlock (Irgraph.getIrgEndBlock(irg));
+       Ircons.matureImmBlock (Irgraph.getIrgEndBlock(irg));
 
        /* Verify the graph.  Finds some very bad errors in the graph. */
        Irvrfy.irgVrfy(irg);
        Ircons.finalizeCons (irg);
 
        System.out.println("Done building the graph.  Dumping it.");
-       Irdump.dumpIrBlockGraph (irg);
-       Irdump.dumpAllTypes();
+       Irdump.dumpIrBlockGraph (irg, "");
+       Irdump.dumpAllTypes("");
 
 
        System.out.println("use xvcg to view this graph:");
index 0f9f438..b0e4dfb 100644 (file)
@@ -46,18 +46,18 @@ class IfElseExample {
        int owner = Irprog.getGlobType();
 
        /* Basic type information for primitive type int. */
-       int primIntTypeName = Ident.idFromStr("int", 3);
+       int primIntTypeName = Ident.newIdFromStr("int");
        int primIntType = Type.newTypePrimitive(primIntTypeName, Irmode.getModeIs());
 
        /* The type of the method */
-       int tpName = Ident.idFromStr("IF_ELSE_EXAMPLE_main_p", 23);
+       int tpName = Ident.newIdFromStr("IF_ELSE_EXAMPLE_main_p");
        int procMain = Type.newTypeMethod(tpName, 0, 2);
        Type.setMethodResType(procMain, 0, primIntType);
        Type.setMethodResType(procMain, 1, primIntType);
 
        /* An entity representing the method.  Owner of the entity is the global
            class type mentioned above. */
-       int name = Ident.idFromStr("IF_ELSE_EXAMPLE_main", 20);
+       int name = Ident.newIdFromStr("IF_ELSE_EXAMPLE_main");
        int ent = Entity.newEntity (owner, name, procMain);
 
        /** Build code for the procedure. **/
@@ -81,27 +81,27 @@ class IfElseExample {
        int f = Ircons.newProj (x, Irmode.getModeX(), 0); /* if condition is false */
        int t = Ircons.newProj (x, Irmode.getModeX(), 1); /* if condition is true */
 
-       Ircons.matureBlock (Irgraph.getIrgCurrentBlock(irg));
+       Ircons.matureImmBlock (Irgraph.getIrgCurrentBlock(irg));
 
        /* generate and fill the then block */
        int b = Ircons.newImmBlock ();
-       Ircons.addInEdge (b, t);
+       Ircons.addImmBlockPred (b, t);
        Ircons.setValue (0, Ircons.getValue(1, Irmode.getModeIs()));
-       Ircons.matureBlock (b);
+       Ircons.matureImmBlock (b);
        int x_then = Ircons.newJmp ();
 
        /* generate and fill the else block */
        b = Ircons.newImmBlock ();
-       Ircons.addInEdge (b, f);
+       Ircons.addImmBlockPred (b, f);
        Ircons.setValue (1, Ircons.newConst (Irmode.getModeIs(),
                                             Tv.newTarvalFromLong (2, Irmode.getModeIs())));
-       Ircons.matureBlock (b);
+       Ircons.matureImmBlock (b);
        int x_else = Ircons.newJmp ();
 
        /* generate the join block and add all cfg edges */
        b = Ircons.newImmBlock ();
-       Ircons.addInEdge (b, x_then);
-       Ircons.addInEdge (b, x_else);
+       Ircons.addImmBlockPred (b, x_then);
+       Ircons.addImmBlockPred (b, x_else);
 
        int[] in = new int[2]; /* this is the array containing the return parameters */
        in[0] = Ircons.getValue(0, Irmode.getModeIs());
@@ -110,14 +110,14 @@ class IfElseExample {
 
        /* Now generate all instructions for this block and all its predecessor
           blocks so we can mature it. */
-       Ircons.matureBlock (Irgraph.getIrgCurrentBlock(irg));
+       Ircons.matureImmBlock (Irgraph.getIrgCurrentBlock(irg));
 
        /* This adds the in edge of the end block which originates at the
           return statement.  The return node passes control flow to the
           end block.  */
-       Ircons.addInEdge (Irgraph.getIrgEndBlock(irg), x);
+       Ircons.addImmBlockPred (Irgraph.getIrgEndBlock(irg), x);
        /* Now we can mature the end block as all it's predecessors are known. */
-       Ircons.matureBlock (Irgraph.getIrgEndBlock(irg));
+       Ircons.matureImmBlock (Irgraph.getIrgEndBlock(irg));
 
        Irvrfy.irgVrfy(irg);
        Ircons.finalizeCons (irg);
@@ -126,8 +126,8 @@ class IfElseExample {
        Irgopt.localOptimizeGraph(irg);
        Irgopt.deadNodeElimination(irg);
 
-       Irdump.dumpIrBlockGraph (irg);
-       Irdump.dumpAllTypes();
+       Irdump.dumpIrBlockGraph (irg, "");
+       Irdump.dumpAllTypes("");
 
        System.out.println("use xvcg to view this graph:");
        System.out.println("/ben/goetz/bin/xvcg GRAPHNAME\n");
index 346ee03..ab33c2a 100644 (file)
@@ -7,20 +7,20 @@ use xvcg to view this graph:
 
 Creating an IR graph: IfElseExample...
 Optimization: 3
-new Node 33
-old Node 32
+new Node 32
+old Node 31
 Optimization: 2
-new Nodes: 35,
-old Nodes: 36, 34, 35,
+new Nodes: 34,
+old Nodes: 35, 33, 34,
 Optimization: 2
-new Nodes: 20,
-old Nodes: 37, 34, 20,
+new Nodes: 19,
+old Nodes: 36, 33, 19,
 Optimization: 4
-new Nodes: 27,
-old Nodes: 42, 35,
+new Nodes: 26,
+old Nodes: 41, 34,
 Done building the graph.  Optimizing it.
 Optimization: 4
-new Nodes: 27,
-old Nodes: 42, 35,
+new Nodes: 26,
+old Nodes: 41, 34,
 use xvcg to view this graph:
 /ben/goetz/bin/xvcg GRAPHNAME