diff options
| author | Linus Torvalds <torvalds@penguin.transmeta.com> | 2003-04-01 16:57:19 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:00:02 -0700 |
| commit | 2823bff27b1ad4bc42f29163fc0d2711fdb0990f (patch) | |
| tree | c5724d7f715cc6655b78e155c5e2572772c8f732 | |
| parent | 731d979ea2e87de7090d5e5f92ad70ea5ffdd09f (diff) | |
| download | sparse-dev-2823bff27b1ad4bc42f29163fc0d2711fdb0990f.tar.gz | |
Move symbol alignment into the "ctype" part of the symbol,
so that type parsing gets access to it.
| -rw-r--r-- | evaluate.c | 7 | ||||
| -rw-r--r-- | show-parse.c | 4 | ||||
| -rw-r--r-- | symbol.c | 41 | ||||
| -rw-r--r-- | symbol.h | 9 |
4 files changed, 31 insertions, 30 deletions
@@ -52,8 +52,7 @@ static struct symbol *evaluate_string(struct expression *expr) sym->array_size = length; sym->bit_size = BITS_IN_CHAR * length; - sym->alignment = 1; - + sym->ctype.alignment = 1; sym->ctype.modifiers = MOD_CONST; sym->ctype.base_type = &char_ctype; expr->ctype = sym; @@ -191,7 +190,7 @@ static struct symbol *degenerate(struct expression *expr, struct symbol *ctype) struct symbol *sym = alloc_symbol(expr->pos, SYM_PTR); sym->ctype = ctype->ctype; sym->bit_size = BITS_IN_POINTER; - sym->alignment = POINTER_ALIGNMENT; + sym->ctype.alignment = POINTER_ALIGNMENT; ctype = sym; } return ctype; @@ -592,8 +591,8 @@ static struct symbol *evaluate_preop(struct expression *expr) case '&': { struct symbol *symbol = alloc_symbol(expr->pos, SYM_PTR); symbol->ctype.base_type = ctype; + symbol->ctype.alignment = POINTER_ALIGNMENT; symbol->bit_size = BITS_IN_POINTER; - symbol->alignment = POINTER_ALIGNMENT; expr->ctype = symbol; return symbol; } diff --git a/show-parse.c b/show-parse.c index a700fe71..5913fcb5 100644 --- a/show-parse.c +++ b/show-parse.c @@ -54,7 +54,7 @@ void show_struct_member(struct symbol *sym, void *data, int flags) { if (flags & ITERATE_FIRST) printf(" {\n\t"); - printf("%s:%d:%d at offset %ld", show_ident(sym->ident), sym->bit_size, sym->alignment, sym->offset); + printf("%s:%d:%ld at offset %ld", show_ident(sym->ident), sym->bit_size, sym->ctype.alignment, sym->offset); if (sym->fieldwidth) printf("[%d..%d]", sym->bit_offset, sym->bit_offset+sym->fieldwidth-1); if (flags & ITERATE_LAST) @@ -420,7 +420,7 @@ void show_statement_list(struct statement_list *stmt, const char *sep) static void show_size(struct symbol *sym) { if (sym) - printf("%d:%d", sym->bit_size, sym->alignment); + printf("%d:%ld", sym->bit_size, sym->ctype.alignment); } static void show_one_expression(struct expression *expr, void *sep, int flags) @@ -49,8 +49,8 @@ static void lay_out_union(struct symbol *sym, void *_info, int flags) struct struct_union_info *info = _info; examine_symbol_type(sym); - if (sym->alignment > info->max_align) - info->max_align = sym->alignment; + if (sym->ctype.alignment > info->max_align) + info->max_align = sym->ctype.alignment; if (sym->bit_size > info->bit_size) info->bit_size = sym->bit_size; @@ -67,12 +67,12 @@ static void lay_out_struct(struct symbol *sym, void *_info, int flags) unsigned long align_bit_mask; examine_symbol_type(sym); - if (sym->alignment > info->max_align) - info->max_align = sym->alignment; + if (sym->ctype.alignment > info->max_align) + info->max_align = sym->ctype.alignment; bit_size = info->bit_size; base_size = sym->bit_size; - align_bit_mask = (sym->alignment << 3) - 1; + align_bit_mask = (sym->ctype.alignment << 3) - 1; /* * Bitfields have some very special rules.. @@ -112,7 +112,8 @@ static void examine_struct_union_type(struct symbol *sym, int advance) bit_align = (info.max_align << 3)-1; bit_size = (bit_size + bit_align) & ~bit_align; sym->bit_size = bit_size; - sym->alignment = info.max_align; + if (info.max_align > sym->ctype.alignment) + sym->ctype.alignment = info.max_align; } static void examine_array_type(struct symbol *sym) @@ -126,9 +127,9 @@ static void examine_array_type(struct symbol *sym) bit_size = base_type->bit_size * sym->array_size; if (sym->array_size < 0) bit_size = -1; - alignment = base_type->alignment; - if (!sym->alignment) - sym->alignment = alignment; + alignment = base_type->ctype.alignment; + if (!sym->ctype.alignment) + sym->ctype.alignment = alignment; sym->bit_size = bit_size; } @@ -145,9 +146,9 @@ static void examine_bitfield_type(struct symbol *sym) warn(sym->pos, "impossible field-width for this type"); sym->fieldwidth = bit_size; } - alignment = base_type->alignment; - if (!sym->alignment) - sym->alignment = alignment; + alignment = base_type->ctype.alignment; + if (!sym->ctype.alignment) + sym->ctype.alignment = alignment; sym->bit_size = bit_size; } @@ -181,15 +182,15 @@ struct symbol *examine_symbol_type(struct symbol * sym) case SYM_PTR: if (!sym->bit_size) sym->bit_size = BITS_IN_POINTER; - if (!sym->alignment) - sym->alignment = POINTER_ALIGNMENT; + if (!sym->ctype.alignment) + sym->ctype.alignment = POINTER_ALIGNMENT; sym->ctype.base_type = examine_symbol_type(sym->ctype.base_type); return sym; case SYM_ENUM: if (!sym->bit_size) sym->bit_size = BITS_IN_ENUM; - if (!sym->alignment) - sym->alignment = ENUM_ALIGNMENT; + if (!sym->ctype.alignment) + sym->ctype.alignment = ENUM_ALIGNMENT; return sym; case SYM_BITFIELD: examine_bitfield_type(sym); @@ -216,14 +217,14 @@ struct symbol *examine_symbol_type(struct symbol * sym) sym->ctype.base_type = base_type; bit_size = base_type->bit_size; - alignment = base_type->alignment; + alignment = base_type->ctype.alignment; if (base_type->fieldwidth) sym->fieldwidth = base_type->fieldwidth; } else bit_size = 0; - if (!sym->alignment) - sym->alignment = alignment; + if (!sym->ctype.alignment) + sym->ctype.alignment = alignment; sym->bit_size = bit_size; return sym; } @@ -430,7 +431,7 @@ void init_symbols(void) if (alignment > ctype->maxalign) alignment = ctype->maxalign; sym->bit_size = bit_size; - sym->alignment = alignment; + sym->ctype.alignment = alignment; sym->ctype.base_type = ctype->base_type; sym->ctype.modifiers = ctype->modifiers; } @@ -48,6 +48,7 @@ enum type { struct ctype { unsigned long modifiers; + unsigned long alignment; struct symbol *base_type; }; @@ -68,8 +69,10 @@ struct symbol { struct symbol *next; /* Next symbol at this level */ unsigned long offset; unsigned int bit_size; - unsigned int alignment:24, - bit_offset:8; + unsigned int bit_offset:8, + fieldwidth:8, + arg_count:10, + variadic:1; int array_size; struct ctype ctype; struct symbol_list *arguments; @@ -77,8 +80,6 @@ struct symbol { struct symbol_list *symbol_list; struct expression *initializer; long long value; /* Initial value */ - int fieldwidth; - int arg_count:10, variadic:1; }; }; }; |
