Related articles |
---|
Permuting fields of records garavel@imag.fr (1993-06-04) |
Re: Permuting fields of records drw@runge.mit.edu (1993-06-06) |
Re: Permuting fields of records nickh@CS.CMU.EDU (1993-06-08) |
Re: Permuting fields of records henry@zoo.toronto.edu (1993-06-09) |
C structure padding drw@zermelo.mit.edu (1993-06-26) |
Re: C structure padding pat@tesuji.qc.ca (1993-06-27) |
Re: C structure padding lord+@andrew.cmu.edu (Tom Lord) (1993-06-27) |
[4 later articles] |
Newsgroups: | comp.compilers |
From: | garavel@imag.fr (Hubert Garavel) |
Keywords: | optimize, question, comment |
Organization: | IMAG Institute, University of Grenoble, France |
Date: | Fri, 4 Jun 1993 13:55:25 GMT |
Hello,
We are currently considering the problem of packing "record" types by
modifying the order of the record fields. For instance, the following C
structure
struct {
char a;
short b;
char c;
}
usually requires 6 bytes on 32-bytes machines (due to alignment
constraints). However, it is possible to reduce this size to 4 bytes
by permuting fields:
struct {
short b;
char a;
char c;
}
Does anybody know an algorithm (or a heuristic) for solving this problem
automatically? Are there some existing compilers that perform such
optimization? Do they take into account the presence of bit fields?
Thanks in advance.
Hubert
--
Hubert GARAVEL | VERIMAG (U.M.R. C-9939)
hubert.garavel@imag.fr | IMAG Campus B.P. 53X
tel: +(33) 76 51 43 54 | 38041 GRENOBLE cedex
fax: +(33) 76 51 33 79 | FRANCE
[Disregarding bit fields, a heuristic that usually works is to sort the
fields largest first. C compilers don't reorder structure fields because
the ANSI/ISO C standards says they can't. -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.