return value;
}
-static void set_value_for_expression(const expression_t *expression,
- ir_node *value)
-{
- set_value_for_expression_addr(expression, value, NULL);
-}
-
static ir_node *get_value_from_lvalue(const expression_t *expression,
ir_node *addr)
{
? new_d_Add(dbgi, value, offset, mode)
: new_d_Sub(dbgi, value, offset, mode);
- set_value_for_expression_addr(value_expr, new_value, addr);
- return pre ? new_value : value;
+ ir_node *const store_value = set_value_for_expression_addr(value_expr, new_value, addr);
+ return pre ? store_value : value;
}
static bool is_local_variable(expression_t *expression)
(void) get_ir_type(type);
return NULL;
}
- if (!is_type_scalar(type)) {
- /* make sure firm type is constructed */
- (void) get_ir_type(type);
- return value_node;
- }
from_type = skip_typeref(from_type);
ir_mode *mode = get_ir_mode_storage(type);
init_ir_types();
PUSH_IRG(get_const_code_irg());
- ir_node *const cnst = _expression_to_firm(expression);
+ ir_node *const cnst = expression_to_firm(expression);
POP_IRG();
set_optimize(old_optimize);
set_opt_constant_folding(old_constant_folding);
-
- if (!is_Const(cnst)) {
- panic("couldn't fold constant");
- }
-
constant_folding = constant_folding_old;
- ir_tarval *const tv = get_Const_tarval(cnst);
- ir_mode *const mode = get_ir_mode_arithmetic(skip_typeref(expression->base.type));
- return tarval_convert_to(tv, mode);
+ if (!is_Const(cnst))
+ panic("couldn't fold constant");
+ return get_Const_tarval(cnst);
}
/* this function is only used in parser.c, but it relies on libfirm functionality */
static ir_node *conditional_to_firm(const conditional_expression_t *expression)
{
- /* first try to fold a constant condition */
- if (is_constant_expression(expression->condition) == EXPR_CLASS_CONSTANT) {
- bool val = fold_constant_to_bool(expression->condition);
- if (val) {
- expression_t *true_expression = expression->true_expression;
- if (true_expression == NULL)
- true_expression = expression->condition;
- return expression_to_firm(true_expression);
- } else {
- return expression_to_firm(expression->false_expression);
- }
- }
-
jump_target true_target;
jump_target false_target;
init_jump_target(&true_target, NULL);
ir_node *const no_mem = new_NoMem();
ir_node *const arg_sel = new_d_simpleSel(dbgi, no_mem, frame, param_ent);
- set_value_for_expression(expr->ap, arg_sel);
+ set_value_for_expression_addr(expr->ap, arg_sel, NULL);
return NULL;
}
static ir_node *va_copy_expression_to_firm(const va_copy_expression_t *const expr)
{
ir_node *const src = expression_to_firm(expr->src);
- set_value_for_expression(expr->dst, src);
+ set_value_for_expression_addr(expr->dst, src, NULL);
return NULL;
}
switch(expression->kind) {
case EXPR_ARRAY_ACCESS:
return array_access_addr(&expression->array_access);
- case EXPR_CALL:
- return call_expression_to_firm(&expression->call);
case EXPR_COMPOUND_LITERAL:
return compound_literal_addr(&expression->compound_literal);
case EXPR_REFERENCE:
return res;
}
- if (is_constant_expression(expression) == EXPR_CLASS_CONSTANT) {
- return new_Const(fold_constant_to_tarval(expression));
- }
-
/* we have to produce a 0/1 from the mode_b expression */
dbg_info *dbgi = get_dbg_info(&expression->base.pos);
ir_mode *mode = get_ir_mode_arithmetic(expression->base.type);
type_t *const init_type = skip_typeref(value->base.type);
if (!is_type_scalar(init_type)) {
- /* skip convs */
- while (value->kind == EXPR_UNARY_CAST)
- value = value->unary.value;
-
if (value->kind != EXPR_COMPOUND_LITERAL)
panic("expected non-scalar initializer to be a compound literal");
initializer = value->compound_literal.initializer;