+/* Add values of the actual arguments to the formal arguments */
+static int add_graph_args (ir_graph *graph, ir_node *call, pto_env_t *env)
+{
+ int change = FALSE;
+ ir_type *meth = get_entity_type (get_irg_entity (graph));
+ ir_node **args = get_irg_proj_args (graph);
+ int i, n_args;
+
+ assert(op_Call == get_irn_op(call));
+
+ n_args = get_Call_n_params (call);
+
+ DBGPRINT (1, (stdout, "%s: args of %s[%li] -> 0x%08x\n",
+ __FUNCTION__,
+ OPNAME (call), OPNUM (call), (int) graph));
+
+ for (i = 0; i < n_args; i ++) {
+ if (NULL != args [i]) {
+ if (mode_P == get_type_mode (get_method_param_type (meth, i))) {
+ ir_node *call_arg = get_Call_param (call, i);
+ pto_t *arg_pto = get_pto (call_arg, env);
+ pto_t *frm_pto = get_node_pto (args [i]);
+
+ assert (arg_pto);
+ assert (frm_pto);
+
+ change |= qset_insert_all (frm_pto->values, arg_pto->values);
+
+ DBGPRINT (2, (stdout, "%s: arg [%i]: -> %s[%li] (%i) -> %s[%li] (%i)\n",
+ __FUNCTION__,
+ i,
+ OPNAME (call_arg), OPNUM (call_arg),
+ arg_pto->values->id,
+ OPNAME (args [i]), OPNUM (args [i]),
+ frm_pto->values->id));
+ }
+ }
+ }
+
+ return (change);
+}
+
+/* Transfer the actual arguments to the formal arguments */
+static void set_graph_args (ir_graph *graph, ir_node *call, pto_env_t *env)
+{
+ ir_type *meth = get_entity_type (get_irg_entity (graph));
+ ir_node **args = get_irg_proj_args (graph);
+ int i, n_args;
+
+ assert (op_Call == get_irn_op(call));
+
+ n_args = get_Call_n_params (call);
+
+ for (i = 0; i < n_args; i ++) {
+ if (NULL != args [i]) {
+ if (mode_P == get_type_mode (get_method_param_type (meth, i))) {
+ ir_node *call_arg = get_Call_param (call, i);
+ pto_t *pto = get_pto (call_arg, env);
+ assert (pto);
+ set_node_pto (args [i], pto);
+
+ DBGPRINT (1, (stdout, "%s: arg [%i]: %s[%li] -> %s[%li] (%i)\n",
+ __FUNCTION__,
+ i,
+ OPNAME (call_arg), OPNUM (call_arg),
+ OPNAME (args [i]), OPNUM (args [i]),
+ pto->values->id));
+ }
+ }
+ }
+}
+
+/* Transfer the graph's result to the call */
+static int set_graph_result (ir_graph *graph, ir_node *call)
+{
+ ir_type *tp = get_entity_type (get_irg_entity (graph));
+ ir_node *end_block;
+ pto_t *ret_pto, *call_pto;
+ int change;
+
+ if (0 == get_method_n_ress (tp)) {
+ return (FALSE);
+ }
+
+ tp = get_method_res_type (tp, 0);
+
+ if (mode_P != get_type_mode (tp)) {
+ set_node_pto (call, NULL);
+
+ return (FALSE);
+ }
+
+ end_block = get_irg_end_block (graph);
+ ret_pto = get_node_pto (end_block);
+
+ call_pto = get_node_pto (call);
+
+ assert (call_pto);
+
+ DBGPRINT (1, (stdout, "%s: before change args\n", __FUNCTION__));
+ DBGEXE (1, pto_print_pto (end_block));
+ DBGEXE (1, pto_print_pto (call));
+
+ change = qset_insert_all (call_pto->values, ret_pto->values);
+
+ if (change) {
+ DBGPRINT (1, (stdout, "%s: after change args\n", __FUNCTION__));
+ DBGEXE (1, pto_print_pto (end_block));
+ DBGEXE (1, pto_print_pto (call));
+ /* assert (0); */
+ }
+
+ return (change);
+}