it's called thread-jumps now
[cparser] / ast2firm.c
index 78006e5..ab7516b 100644 (file)
@@ -2399,21 +2399,18 @@ static ir_node *handle_assume(dbg_info *dbi, const expression_t *expression)
        }
 }
 
-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;
@@ -2432,20 +2429,17 @@ static ir_node *cast_to_firm(const unary_expression_t *expression)
                }
        }
 
+       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;
 }
 
@@ -2499,8 +2493,11 @@ static ir_node *unary_expression_to_firm(const unary_expression_t *expression)
        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);
@@ -2718,13 +2715,12 @@ static ir_node *create_assign_binop(const binary_expression_t *expression)
        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);
@@ -3427,19 +3423,15 @@ static ir_node *get_label_block(label_t *label)
  * 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);
 }
 
 /**
@@ -4995,12 +4987,14 @@ static ir_node *get_break_label(void)
 
 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);
@@ -5263,7 +5257,7 @@ static void asm_statement_to_firm(const asm_statement_t *statement)
                                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;
@@ -5577,7 +5571,7 @@ static void initialize_function_parameters(entity_t *entity)
 
        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;
        }
 
@@ -5611,7 +5605,7 @@ static void initialize_function_parameters(entity_t *entity)
                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);
@@ -5883,6 +5877,8 @@ static void scope_to_firm(scope_t *scope)
                        (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);
                }
        }