create new_bind_expr and more tweeks to temp def ref counting

This commit is contained in:
Bill Currie 2001-11-13 18:49:27 +00:00
parent f2f8e096f3
commit 4291f9c711
4 changed files with 28 additions and 11 deletions

View file

@ -84,6 +84,7 @@ expr_t *new_block_expr (void);
expr_t *new_binary_expr (int op, expr_t *e1, expr_t *e2);
expr_t *new_unary_expr (int op, expr_t *e1);
expr_t *new_temp_def_expr (type_t *type);
expr_t *new_bind_expr (expr_t *e1, expr_t *e2);
void inc_users (expr_t *e);

View file

@ -364,6 +364,24 @@ new_temp_def_expr (type_t *type)
return e;
}
expr_t *
new_bind_expr (expr_t *e1, expr_t *e2)
{
expr_t *e;
if (!e2 || e2->type != ex_temp) {
error (e1, "internal error");
abort ();
}
//e = new_binary_expr ('b', e1, e2);
e = new_expr ();
e->type = ex_expr;
e->e.expr.op = 'b';
e->e.expr.e1 = e1;
e->e.expr.e2 = e2;
return e;
}
expr_t *
append_expr (expr_t *block, expr_t *e)
{
@ -867,11 +885,6 @@ binary_expr (int op, expr_t *e1, expr_t *e2)
check_initialized (e1);
check_initialized (e2);
if (e1->type != ex_block)
inc_users (e1);
if (e2->type != ex_block)
inc_users (e2);
if (op == '=' && e1->type == ex_def)
PR_DefInitialized (e1->e.def);
@ -879,6 +892,7 @@ binary_expr (int op, expr_t *e1, expr_t *e2)
&& e2->type == ex_block && e2->e.block.is_call
&& e1->e.block.result) {
e = new_temp_def_expr (e1->e.block.result->e.def->type);
inc_users (e);
e1 = binary_expr ('=', e, e1);
}
@ -1271,8 +1285,10 @@ function_expr (expr_t *e1, expr_t *e2)
arg_exprs[i][0]));
}
if (arg_expr_count) {
e = new_binary_expr ('b', arg_exprs[arg_expr_count - 1][0],
arg_exprs[arg_expr_count - 1][1]);
e = new_bind_expr (arg_exprs[arg_expr_count - 1][0],
arg_exprs[arg_expr_count - 1][1]);
inc_users (arg_exprs[arg_expr_count - 1][0]);
inc_users (arg_exprs[arg_expr_count - 1][1]);
append_expr (call, e);
}
e = new_binary_expr ('c', e1, args);

View file

@ -277,7 +277,7 @@ PR_FreeTempDefs (void)
*def = d->next;
if (d->users < 0)
printf ("%s:%d: warning: %3d %3d\n", strings + d->file, d->line, d->ofs, d->users);
printf ("%s:%d: warning: %s %3d %3d\n", strings + d->file, d->line, type_name[d->type->type], d->ofs, d->users);
size = pr_type_size[d->type->type];
if (d->expr)
d->expr->e.temp.def = 0;
@ -304,7 +304,7 @@ PR_ResetTempDefs (void)
}
for (d = temp_scope.next; d; d = d->next)
printf ("%s:%d: warning: %3d %3d\n", strings + d->file, d->line, d->ofs, d->users);
printf ("%s:%d: warning: %s %3d %3d\n", strings + d->file, d->line, type_name[d->type->type], d->ofs, d->users);
temp_scope.next = 0;
}

View file

@ -298,7 +298,7 @@ build_switch (expr_t *sw, case_node_t *tree, int op, expr_t *sw_val,
branch->file = sw_val->file;
append_expr (sw, branch);
}
append_expr (sw, new_binary_expr ('b', temp, utemp));
append_expr (sw, new_bind_expr (temp, utemp));
test = binary_expr (GT, utemp, range);
test->line = sw_val->line;
test->file = sw_val->file;
@ -357,7 +357,7 @@ switch_expr (switch_block_t *switch_block, expr_t *break_label,
default_expr->line = sw_val->line;
default_expr->file = sw_val->file;
append_expr (sw, binary_expr ('b', switch_block->test, sw_val));
append_expr (sw, new_bind_expr (switch_block->test, sw_val));
for (l = labels; *l; l++)
num_labels++;