}
}
-static ir_node *cast_to_firm(const unary_expression_t *expression)
+static ir_node *create_cast(dbg_info *dbgi, ir_node *value_node,
+ type_t *from_type, type_t *type)
{
- dbg_info *dbgi = get_dbg_info(&expression->base.source_position);
- type_t *type = skip_typeref(expression->base.type);
- const expression_t *value = expression->value;
- ir_node *value_node = expression_to_firm(value);
-
+ type = skip_typeref(type);
if (!is_type_scalar(type)) {
/* make sure firm type is constructed */
(void) get_ir_type(type);
return value_node;
}
- type_t *from_type = skip_typeref(value->base.type);
- ir_mode *mode = get_ir_mode_storage(type);
+ from_type = skip_typeref(from_type);
+ ir_mode *mode = get_ir_mode_storage(type);
/* check for conversion from / to __based types */
if (is_type_pointer(type) && is_type_pointer(from_type)) {
const variable_t *from_var = from_type->pointer.base_variable;
}
}
+ if (is_type_atomic(type, ATOMIC_TYPE_BOOL)) {
+ /* bool adjustments (we save a mode_Bu, but have to temporarily
+ * convert to mode_b so we only get a 0/1 value */
+ value_node = create_conv(dbgi, value_node, mode_b);
+ }
+
ir_mode *mode_arith = get_ir_mode_arithmetic(type);
ir_node *node = create_conv(dbgi, value_node, mode);
node = do_strict_conv(dbgi, node);
node = create_conv(dbgi, node, mode_arith);
- if (is_type_atomic(type, ATOMIC_TYPE_BOOL)) {
- /* bool adjustments (have to compare to get 0/1 value */
- ir_node *zero = new_Const(get_mode_null(mode_arith));
- ir_node *cmp = new_d_Cmp(dbgi, node, zero);
- ir_node *proj = new_d_Proj(dbgi, cmp, mode_b, pn_Cmp_Lg);
- ir_node *one = new_Const_long(mode_arith, 1);
- node = new_d_Mux(dbgi, proj, zero, one, mode_arith);
- }
-
return node;
}
case EXPR_UNARY_PREFIX_DECREMENT:
return create_incdec(expression);
case EXPR_UNARY_CAST_IMPLICIT:
- case EXPR_UNARY_CAST:
- return cast_to_firm(expression);
+ case EXPR_UNARY_CAST: {
+ ir_node *value_node = expression_to_firm(value);
+ type_t *from_type = value->base.type;
+ return create_cast(dbgi, value_node, from_type, type);
+ }
case EXPR_UNARY_ASSUME:
if (firm_opt.confirm)
return handle_assume(dbgi, value);
dbg_info *const dbgi = get_dbg_info(&expression->base.source_position);
const expression_t *left_expr = expression->left;
type_t *type = skip_typeref(left_expr->base.type);
- ir_mode *left_mode = get_ir_mode_storage(type);
ir_node *right = expression_to_firm(expression->right);
ir_node *left_addr = expression_to_addr(left_expr);
ir_node *left = get_value_from_lvalue(left_expr, left_addr);
ir_node *result = create_op(dbgi, expression, left, right);
- result = create_conv(dbgi, result, left_mode);
+ result = create_cast(dbgi, result, expression->right->base.type, type);
result = do_strict_conv(dbgi, result);
result = set_value_for_expression_addr(left_expr, result, left_addr);
* Pointer to a label. This is used for the
* GNU address-of-label extension.
*/
-static ir_node *label_address_to_firm(
- const label_address_expression_t *label)
+static ir_node *label_address_to_firm(const label_address_expression_t *label)
{
- ir_node *block = get_label_block(label->label);
- ir_label_t nr = get_Block_label(block);
+ dbg_info *dbgi = get_dbg_info(&label->base.source_position);
+ ir_node *block = get_label_block(label->label);
+ ir_entity *entity = create_Block_entity(block);
- if (nr == 0) {
- nr = get_irp_next_label_nr();
- set_Block_label(block, nr);
- }
symconst_symbol value;
- value.label = nr;
- return new_SymConst(mode_P_code, value, symconst_label);
+ value.entity_p = entity;
+ return new_d_SymConst(dbgi, mode_P_code, value, symconst_addr_ent);
}
/**
static void switch_statement_to_firm(switch_statement_t *statement)
{
- ir_node *first_block = get_cur_block();
+ ir_node *first_block = NULL;
dbg_info *dbgi = get_dbg_info(&statement->base.source_position);
ir_node *cond = NULL;
- if (first_block != NULL) {
+
+ if (get_cur_block() != NULL) {
ir_node *expression = expression_to_firm(statement->expression);
cond = new_d_Cond(dbgi, expression);
+ first_block = get_cur_block();
}
set_cur_block(NULL);
char buf[64];
ir_node *value = get_value_from_lvalue(expr, addr);
- snprintf(buf, sizeof(buf), "%u", pos);
+ snprintf(buf, sizeof(buf), "%u", (unsigned) out_size);
ir_asm_constraint constraint;
constraint.pos = pos;
if (entity->function.need_closure) {
/* add an extra parameter for the static link */
- entity->function.static_link = new_r_Proj(irg, start_block, args, mode_P_data, 0);
+ entity->function.static_link = new_r_Proj(start_block, args, mode_P_data, 0);
++first_param_nr;
}
ir_mode *param_mode = get_type_mode(param_irtype);
long pn = n + first_param_nr;
- ir_node *value = new_r_Proj(irg, start_block, args, param_mode, pn);
+ ir_node *value = new_r_Proj(start_block, args, param_mode, pn);
ir_mode *mode = get_ir_mode_storage(type);
value = create_conv(NULL, value, mode);
(void)get_function_entity(entity, NULL);
} else if (entity->kind == ENTITY_VARIABLE) {
create_global_variable(entity);
+ } else if (entity->kind == ENTITY_NAMESPACE) {
+ scope_to_firm(&entity->namespacee.members);
}
}