diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-20 21:27:06 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-11-16 20:37:00 +0100 |
| commit | 1bd55a66066a2c0ad49237311863d77052f84602 (patch) | |
| tree | addd9c917c79a724ba4ad9a072d79ceb6917b179 | |
| parent | 6e71cf2020fff606a8b57d095d34ffc5bea70d47 (diff) | |
| download | sparse-dev-1bd55a66066a2c0ad49237311863d77052f84602.tar.gz | |
add is_signed_type()
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | compile-i386.c | 14 | ||||
| -rw-r--r-- | show-parse.c | 11 | ||||
| -rw-r--r-- | symbol.h | 9 |
3 files changed, 12 insertions, 22 deletions
diff --git a/compile-i386.c b/compile-i386.c index 7b7ace92..44ef7bba 100644 --- a/compile-i386.c +++ b/compile-i386.c @@ -193,7 +193,6 @@ 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); @@ -1163,7 +1162,7 @@ static void emit_move(struct storage *src, struct storage *dest, if (ctype) { bits = ctype->bit_size; - is_signed = type_is_signed(ctype); + is_signed = is_signed_type(ctype); } else { bits = 32; is_signed = 0; @@ -1355,7 +1354,7 @@ static struct storage *emit_binop(struct expression *expr) if ((expr->op == '/') || (expr->op == '%')) return emit_divide(expr, left, right); - is_signed = type_is_signed(expr->ctype); + is_signed = is_signed_type(expr->ctype); switch (expr->op) { case '+': @@ -2264,15 +2263,6 @@ static void x86_symbol_init(struct symbol *sym) 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); diff --git a/show-parse.c b/show-parse.c index d60a6dec..9b5225da 100644 --- a/show-parse.c +++ b/show-parse.c @@ -949,15 +949,6 @@ static int show_symbol_init(struct symbol *sym) return 0; } -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 int show_cast_expr(struct expression *expr) { struct symbol *old_type, *new_type; @@ -973,7 +964,7 @@ static int show_cast_expr(struct expression *expr) if (oldbits >= newbits) return op; new = new_pseudo(); - is_signed = type_is_signed(old_type); + is_signed = is_signed_type(old_type); if (is_signed) { printf("\tsext%d.%d\tv%d,v%d\n", oldbits, newbits, new, op); } else { @@ -332,6 +332,15 @@ static inline int is_enum_type(const struct symbol *type) return (type->type == SYM_ENUM); } +static inline int is_signed_type(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 inline int is_type_type(struct symbol *type) { return (type->ctype.modifiers & MOD_TYPE) != 0; |
