int primIntType = Type.newTypePrimitive(primIntTypeName, Irmode.getModeIs());
/* The type of the method */
int primIntType = Type.newTypePrimitive(primIntTypeName, Irmode.getModeIs());
/* The type of the method */
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 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 ent = Entity.newEntity (owner, name, procMain);
/** Build code for the procedure. **/
int ent = Entity.newEntity (owner, name, procMain);
/** Build code for the procedure. **/
int c2 = Ircons.newConst(Irmode.getModeIs(),
Tv.newTarvalFromLong (2, Irmode.getModeIs()));
int cmpGt = Ircons.newProj(Ircons.newCmp(Ircons.getValue(0, Irmode.getModeIs()), c2),
int c2 = Ircons.newConst(Irmode.getModeIs(),
Tv.newTarvalFromLong (2, Irmode.getModeIs()));
int cmpGt = Ircons.newProj(Ircons.newCmp(Ircons.getValue(0, Irmode.getModeIs()), c2),
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 */
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 */
int x_then = Ircons.newJmp ();
/* generate and fill the else block */
b = Ircons.newImmBlock ();
int x_then = Ircons.newJmp ();
/* generate and fill the else block */
b = Ircons.newImmBlock ();
Ircons.setValue (1, Ircons.newConst (Irmode.getModeIs(),
Tv.newTarvalFromLong (2, Irmode.getModeIs())));
Ircons.setValue (1, Ircons.newConst (Irmode.getModeIs(),
Tv.newTarvalFromLong (2, Irmode.getModeIs())));
int x_else = Ircons.newJmp ();
/* generate the join block and add all cfg edges */
b = Ircons.newImmBlock ();
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());
int[] in = new int[2]; /* this is the array containing the return parameters */
in[0] = Ircons.getValue(0, Irmode.getModeIs());
/* Now generate all instructions for this block and all its predecessor
blocks so we can mature it. */
/* Now generate all instructions for this block and all its predecessor
blocks so we can mature it. */
/* 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. */
/* 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. */
System.out.println("Done building the graph. Optimizing it.");
Irgopt.localOptimizeGraph(irg);
Irgopt.deadNodeElimination(irg);
System.out.println("Done building the graph. Optimizing it.");
Irgopt.localOptimizeGraph(irg);
Irgopt.deadNodeElimination(irg);
System.out.println("use xvcg to view this graph:");
System.out.println("/ben/goetz/bin/xvcg GRAPHNAME\n");
System.out.println("use xvcg to view this graph:");
System.out.println("/ben/goetz/bin/xvcg GRAPHNAME\n");