X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=firmjni%2Ftestprograms%2FIfElseExample.java;h=33781365fe77dbe5365df9f9329e7c48bed7224d;hb=b863ba4c0942c387ea18167a6b970a67b26c7ec1;hp=0f9f43828f0dae1218a99793d64a905302df5d94;hpb=f34c10e30b6812a53efbb2634c04c3511c75344b;p=libfirm diff --git a/firmjni/testprograms/IfElseExample.java b/firmjni/testprograms/IfElseExample.java index 0f9f43828..33781365f 100644 --- a/firmjni/testprograms/IfElseExample.java +++ b/firmjni/testprograms/IfElseExample.java @@ -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. **/ @@ -76,32 +76,33 @@ class IfElseExample { int c2 = Ircons.newConst(Irmode.getModeIs(), Tv.newTarvalFromLong (2, Irmode.getModeIs())); int cmpGt = Ircons.newProj(Ircons.newCmp(Ircons.getValue(0, Irmode.getModeIs()), c2), - Irmode.getModeb(), Irnode.Gt); + Irmode.getModeb(), Irnode.pn_Cmp_Gt); + int x = Ircons.newCond (cmpGt); 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,24 +111,24 @@ 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); + Irvrfy.irgVerify(irg, Irvrfy.VRFY_NORMAL); + Irgraph.setIrgPhaseState (irg, Irgraph.phase_high); System.out.println("Done building the graph. Optimizing it."); 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");