removed phi_out from ast_ternary since we have a place in ast_expression_common for this kind of value

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-11-21 20:13:31 +01:00
parent 268ad7db53
commit a7fb45f102
2 changed files with 4 additions and 8 deletions

9
ast.c
View file

@ -651,7 +651,6 @@ ast_ternary* ast_ternary_new(lex_ctx ctx, ast_expression *cond, ast_expression *
self->cond = cond;
self->on_true = ontrue;
self->on_false = onfalse;
self->phi_out = NULL;
return self;
}
@ -2012,8 +2011,8 @@ bool ast_ternary_codegen(ast_ternary *self, ast_function *func, bool lvalue, ir_
* may still happen, thus we remember a created ir_value and simply return one
* if it already exists.
*/
if (self->phi_out) {
*out = self->phi_out;
if (self->expression.outr) {
*out = self->expression.outr;
return true;
}
@ -2087,8 +2086,8 @@ bool ast_ternary_codegen(ast_ternary *self, ast_function *func, bool lvalue, ir_
ir_phi_add(phi, ontrue, trueval);
ir_phi_add(phi, onfalse, falseval);
self->phi_out = ir_phi_value(phi);
*out = self->phi_out;
self->expression.outr = ir_phi_value(phi);
*out = self->expression.outr;
return true;
}

3
ast.h
View file

@ -398,9 +398,6 @@ struct ast_ternary_s
/* It's all just 'expressions', since an ast_block is one too. */
ast_expression *on_true;
ast_expression *on_false;
/* After a ternary expression we find ourselves in a new IR block
* and start with a PHI node */
ir_value *phi_out;
};
ast_ternary* ast_ternary_new(lex_ctx ctx, ast_expression *cond, ast_expression *ontrue, ast_expression *onfalse);
void ast_ternary_delete(ast_ternary*);