Print this page
new smatch

*** 191,201 **** static const char *current_section; static void emit_comment(const char * fmt, ...) FORMAT_ATTR(1); static void emit_move(struct storage *src, struct storage *dest, struct symbol *ctype, const char *comment); - static int type_is_signed(struct symbol *sym); static struct storage *x86_address_gen(struct expression *expr); static struct storage *x86_symbol_expr(struct symbol *sym); static void x86_symbol(struct symbol *sym); static struct storage *x86_statement(struct statement *stmt); static struct storage *x86_expression(struct expression *expr); --- 191,200 ----
*** 450,460 **** break; case STOR_REG: strcpy(name, s->reg->name); break; case STOR_VALUE: ! sprintf(name, "$%Ld", s->value); break; case STOR_LABEL: sprintf(name, "%s.L%d", s->flags & STOR_LABEL_VAL ? "$" : "", s->label); break; --- 449,459 ---- break; case STOR_REG: strcpy(name, s->reg->name); break; case STOR_VALUE: ! sprintf(name, "$%lld", s->value); break; case STOR_LABEL: sprintf(name, "%s.L%d", s->flags & STOR_LABEL_VAL ? "$" : "", s->label); break;
*** 935,945 **** default: type = NULL; break; } assert(type != NULL); ! printf("\t.%s\t%Ld\n", type, ll); } static void emit_global_noinit(const char *name, unsigned long modifiers, unsigned long alignment, unsigned int byte_size) { --- 934,944 ---- default: type = NULL; break; } assert(type != NULL); ! printf("\t.%s\t%lld\n", type, ll); } static void emit_global_noinit(const char *name, unsigned long modifiers, unsigned long alignment, unsigned int byte_size) {
*** 1161,1171 **** unsigned int is_dest = (src->type == STOR_REG); const char *opname; if (ctype) { bits = ctype->bit_size; ! is_signed = type_is_signed(ctype); } else { bits = 32; is_signed = 0; } --- 1160,1170 ---- unsigned int is_dest = (src->type == STOR_REG); const char *opname; if (ctype) { bits = ctype->bit_size; ! is_signed = is_signed_type(ctype); } else { bits = 32; is_signed = 0; }
*** 1353,1363 **** /* Divides have special register constraints */ if ((expr->op == '/') || (expr->op == '%')) return emit_divide(expr, left, right); ! is_signed = type_is_signed(expr->ctype); switch (expr->op) { case '+': opname = "add"; break; --- 1352,1362 ---- /* Divides have special register constraints */ if ((expr->op == '/') || (expr->op == '%')) return emit_divide(expr, left, right); ! is_signed = is_signed_type(expr->ctype); switch (expr->op) { case '+': opname = "add"; break;
*** 1553,1581 **** return val; } static struct storage *emit_conditional_expr(struct expression *expr) { ! struct storage *cond, *true = NULL, *false = NULL; struct storage *new = stack_alloc(expr->ctype->bit_size / 8); int target_false, cond_end; /* evaluate conditional */ cond = x86_expression(expr->conditional); target_false = emit_conditional_test(cond); /* handle if-true part of the expression */ ! true = x86_expression(expr->cond_true); ! emit_copy(new, true, expr->ctype); cond_end = emit_conditional_end(target_false); /* handle if-false part of the expression */ ! false = x86_expression(expr->cond_false); ! emit_copy(new, false, expr->ctype); /* end of conditional; jump target for if-true branch */ emit_label(cond_end, "end conditional"); return new; --- 1552,1580 ---- return val; } static struct storage *emit_conditional_expr(struct expression *expr) { ! struct storage *cond, *stot = NULL, *stof = NULL; struct storage *new = stack_alloc(expr->ctype->bit_size / 8); int target_false, cond_end; /* evaluate conditional */ cond = x86_expression(expr->conditional); target_false = emit_conditional_test(cond); /* handle if-true part of the expression */ ! stot = x86_expression(expr->cond_true); ! emit_copy(new, stot, expr->ctype); cond_end = emit_conditional_end(target_false); /* handle if-false part of the expression */ ! stof = x86_expression(expr->cond_false); ! emit_copy(new, stof, expr->ctype); /* end of conditional; jump target for if-true branch */ emit_label(cond_end, "end conditional"); return new;
*** 1582,1600 **** } static struct storage *emit_select_expr(struct expression *expr) { struct storage *cond = x86_expression(expr->conditional); ! struct storage *true = x86_expression(expr->cond_true); ! struct storage *false = x86_expression(expr->cond_false); struct storage *reg_cond, *reg_true, *reg_false; struct storage *new = stack_alloc(4); emit_comment("begin SELECT"); reg_cond = get_reg_value(cond, get_regclass(expr->conditional)); ! reg_true = get_reg_value(true, get_regclass(expr)); ! reg_false = get_reg_value(false, get_regclass(expr)); /* * Do the actual select: check the conditional for zero, * move false over true if zero */ --- 1581,1599 ---- } static struct storage *emit_select_expr(struct expression *expr) { struct storage *cond = x86_expression(expr->conditional); ! struct storage *stot = x86_expression(expr->cond_true); ! struct storage *stof = x86_expression(expr->cond_false); struct storage *reg_cond, *reg_true, *reg_false; struct storage *new = stack_alloc(4); emit_comment("begin SELECT"); reg_cond = get_reg_value(cond, get_regclass(expr->conditional)); ! reg_true = get_reg_value(stot, get_regclass(expr)); ! reg_false = get_reg_value(stof, get_regclass(expr)); /* * Do the actual select: check the conditional for zero, * move false over true if zero */
*** 2234,2244 **** if (sym->ctype.modifiers & (MOD_TOPLEVEL | MOD_EXTERN | MOD_STATIC)) { printf("\tmovi.%d\t\tv%d,$%s\n", bits_in_pointer, new->pseudo, show_ident(sym->ident)); return new; } if (sym->ctype.modifiers & MOD_ADDRESSABLE) { ! printf("\taddi.%d\t\tv%d,vFP,$%lld\n", bits_in_pointer, new->pseudo, sym->value); return new; } printf("\taddi.%d\t\tv%d,vFP,$offsetof(%s:%p)\n", bits_in_pointer, new->pseudo, show_ident(sym->ident), sym); return new; } --- 2233,2243 ---- if (sym->ctype.modifiers & (MOD_TOPLEVEL | MOD_EXTERN | MOD_STATIC)) { printf("\tmovi.%d\t\tv%d,$%s\n", bits_in_pointer, new->pseudo, show_ident(sym->ident)); return new; } if (sym->ctype.modifiers & MOD_ADDRESSABLE) { ! printf("\taddi.%d\t\tv%d,vFP,$%lld\n", bits_in_pointer, new->pseudo, 0LL); return new; } printf("\taddi.%d\t\tv%d,vFP,$offsetof(%s:%p)\n", bits_in_pointer, new->pseudo, show_ident(sym->ident), sym); return new; }
*** 2262,2280 **** } priv->addr = new; } - static int type_is_signed(struct symbol *sym) - { - if (sym->type == SYM_NODE) - sym = sym->ctype.base_type; - if (sym->type == SYM_PTR) - return 0; - return !(sym->ctype.modifiers & MOD_UNSIGNED); - } - static struct storage *x86_label_expr(struct expression *expr) { struct storage *new = stack_alloc(4); printf("\tmovi.%d\t\tv%d,.L%p\n", bits_in_pointer, new->pseudo, expr->label_symbol); return new; --- 2261,2270 ----