Nuke temp reference counting.

The whole reason for this crazy developement branch :)
This commit is contained in:
Bill Currie 2011-01-21 23:42:50 +09:00
parent 3b462e16cf
commit d5f669af7a
3 changed files with 0 additions and 72 deletions

View file

@ -88,7 +88,6 @@ typedef struct {
struct operand_s *op; ///< The operand for the temporary variable, if struct operand_s *op; ///< The operand for the temporary variable, if
///< allocated ///< allocated
struct type_s *type; ///< The type of the temporary variable. struct type_s *type; ///< The type of the temporary variable.
int users; ///< Reference count. Source of much hair loss.
} ex_temp_t; } ex_temp_t;
/** Pointer constant expression. /** Pointer constant expression.
@ -287,9 +286,6 @@ expr_t *new_block_expr (void);
/** Create a new binary expression node node. /** Create a new binary expression node node.
If \a e1 or \a e2 represent temporary variables, their ex_temp_t::users
field will be incremented.
If either \a e1 or \a e2 are error expressions, then that expression will If either \a e1 or \a e2 are error expressions, then that expression will
be returned instead of a new binary expression. be returned instead of a new binary expression.
@ -304,9 +300,6 @@ expr_t *new_binary_expr (int op, expr_t *e1, expr_t *e2);
/** Create a new unary expression node node. /** Create a new unary expression node node.
If \a e1 represents a temporary variable, its ex_temp_t::users field
will be incremented.
If \a e1 is an error expression, then it will be returned instead of a If \a e1 is an error expression, then it will be returned instead of a
new binary expression. new binary expression.
@ -514,30 +507,6 @@ expr_t *new_param_expr (struct type_s *type, int num);
*/ */
expr_t *new_move_expr (expr_t *e1, expr_t *e2, struct type_s *type); expr_t *new_move_expr (expr_t *e1, expr_t *e2, struct type_s *type);
/** Temporary variable reference counting.
Increment the users of the referenced temporary. Has no effect on
other expressions.
\param e The expression referencing the temporary variable. If
a block expression, the result of the block will be
incremented.
\return \a e
*/
expr_t *inc_users (expr_t *e);
/** Temporary variable reference counting.
Decrement the users of the referenced temporary. Has no effect on
other expressions.
\param e The expression referencing the temporary variable. If
a block expression, the result of the block will be
decremented.
\return \a e
*/
expr_t *dec_users (expr_t *e);
expr_t *append_expr (expr_t *block, expr_t *e); expr_t *append_expr (expr_t *block, expr_t *e);
void print_expr (expr_t *e); void print_expr (expr_t *e);

View file

@ -55,12 +55,6 @@ static expr_t *
cf_cast_expr (type_t *type, expr_t *e) cf_cast_expr (type_t *type, expr_t *e)
{ {
e = cast_expr (type, e); e = cast_expr (type, e);
// The expression of which this is a sub-expression has already
// incremented users, so we don't need cast_expr to do so again,
// however, since cast_expr does so unconditionally, we must undo
// the increment.
if (e && e->type == ex_uexpr && e->e.expr.op == 'C')
dec_users (e->e.expr.e1);
return e; return e;
} }

View file

@ -190,26 +190,6 @@ test_error (expr_t *e, type_t *t)
return e; return e;
} }
expr_t *
inc_users (expr_t *e)
{
if (e && e->type == ex_temp)
e->e.temp.users++;
else if (e && e->type == ex_block)
inc_users (e->e.block.result);
return e;
}
expr_t *
dec_users (expr_t *e)
{
if (e && e->type == ex_temp)
e->e.temp.users--;
else if (e && e->type == ex_block)
dec_users (e->e.block.result);
return e;
}
expr_t * expr_t *
new_expr (void) new_expr (void)
{ {
@ -301,7 +281,6 @@ copy_expr (expr_t *e)
n = new_expr (); n = new_expr ();
*n = *e; *n = *e;
n->e.temp.expr = copy_expr (e->e.temp.expr); n->e.temp.expr = copy_expr (e->e.temp.expr);
e->e.temp.users = 0; //FIXME?
return n; return n;
} }
error (e, "internal: invalid expression"); error (e, "internal: invalid expression");
@ -387,9 +366,6 @@ new_binary_expr (int op, expr_t *e1, expr_t *e2)
if (e2 && e2->type == ex_error) if (e2 && e2->type == ex_error)
return e2; return e2;
inc_users (e1);
inc_users (e2);
e->type = ex_expr; e->type = ex_expr;
e->e.expr.op = op; e->e.expr.op = op;
e->e.expr.e1 = e1; e->e.expr.e1 = e1;
@ -405,8 +381,6 @@ new_unary_expr (int op, expr_t *e1)
if (e1 && e1->type == ex_error) if (e1 && e1->type == ex_error)
return e1; return e1;
inc_users (e1);
e->type = ex_uexpr; e->type = ex_uexpr;
e->e.expr.op = op; e->e.expr.op = op;
e->e.expr.e1 = e1; e->e.expr.e1 = e1;
@ -1214,7 +1188,6 @@ binary_expr (int op, expr_t *e1, expr_t *e2)
if (e1->type == ex_block && e1->e.block.is_call if (e1->type == ex_block && e1->e.block.is_call
&& has_function_call (e2) && e1->e.block.result) { && has_function_call (e2) && e1->e.block.result) {
e = new_temp_def_expr (get_type (e1->e.block.result)); e = new_temp_def_expr (get_type (e1->e.block.result));
inc_users (e); // for the block itself
e1 = assign_expr (e, e1); e1 = assign_expr (e, e1);
} }
@ -1617,12 +1590,6 @@ build_function_call (expr_t *fexpr, type_t *ftype, expr_t *params)
} else { } else {
*a = cast_expr (arg_types[i], e); *a = cast_expr (arg_types[i], e);
} }
// new_binary_expr calls inc_users for both args, but inc_users doesn't
// walk expression chains so only the first arg expression in the chain
// (the last arg in the call) gets its user count incremented, thus
// ensure all other arg expressions get their user counts incremented.
if (a != &args)
inc_users (*a);
a = &(*a)->next; a = &(*a)->next;
} }
for (i = 0; i < arg_expr_count - 1; i++) { for (i = 0; i < arg_expr_count - 1; i++) {
@ -1631,8 +1598,6 @@ build_function_call (expr_t *fexpr, type_t *ftype, expr_t *params)
if (arg_expr_count) { if (arg_expr_count) {
e = assign_expr (arg_exprs[arg_expr_count - 1][1], e = assign_expr (arg_exprs[arg_expr_count - 1][1],
arg_exprs[arg_expr_count - 1][0]); arg_exprs[arg_expr_count - 1][0]);
inc_users (arg_exprs[arg_expr_count - 1][0]);
inc_users (arg_exprs[arg_expr_count - 1][1]);
append_expr (call, e); append_expr (call, e);
} }
e = new_binary_expr ('c', fexpr, args); e = new_binary_expr ('c', fexpr, args);