+/**
+ * recursive build the graph form the instructions.
+ *
+ * @param env the environment
+ * @param inst the instruction
+ */
+static ir_node *build_graph(mul_env *env, instruction *inst)
+{
+ ir_node *l, *r, *c;
+
+ if (inst->irn)
+ return inst->irn;
+
+ switch (inst->kind) {
+ case LEA:
+ l = build_graph(env, inst->in[0]);
+ r = build_graph(env, inst->in[1]);
+ c = new_Const_long(env->shf_mode, inst->shift_count);
+ r = new_rd_Shl(env->dbg, env->blk, r, c, env->mode);
+ return inst->irn = new_rd_Add(env->dbg, env->blk, l, r, env->mode);
+ case SHIFT:
+ l = build_graph(env, inst->in[0]);
+ c = new_Const_long(env->shf_mode, inst->shift_count);
+ return inst->irn = new_rd_Shl(env->dbg, env->blk, l, c, env->mode);
+ case SUB:
+ l = build_graph(env, inst->in[0]);
+ r = build_graph(env, inst->in[1]);
+ return inst->irn = new_rd_Sub(env->dbg, env->blk, l, r, env->mode);
+ case ADD:
+ l = build_graph(env, inst->in[0]);
+ r = build_graph(env, inst->in[1]);
+ return inst->irn = new_rd_Add(env->dbg, env->blk, l, r, env->mode);
+ case ZERO:
+ return inst->irn = new_Const(get_mode_null(env->mode));
+ default:
+ panic("Unsupported instruction kind");
+ return NULL;
+ }
+}