Re: representation of struct field offsets

2006-10-01 Thread Chris Lattner
On Oct 1, 2006, at 7:57 PM, Richard Kenner wrote: It can't be normalized to BITS_PER_UNIT, but to DECL_OFFSET_ALIGN since we are asserting that DECL_FIELD_OFFSET is aligned to DECL_OFFSET_ALIGN. That doesn't make sense to me. It seems to me that we can normalize it however we please; ul

Re: representation of struct field offsets

2006-10-01 Thread Richard Kenner
> > It can't be normalized to BITS_PER_UNIT, but to DECL_OFFSET_ALIGN since > > we are asserting that DECL_FIELD_OFFSET is aligned to DECL_OFFSET_ALIGN. > > That doesn't make sense to me. It seems to me that we can normalize it > however we please; ultimately, all these representations just give

Re: representation of struct field offsets

2006-10-01 Thread Mark Mitchell
Richard Kenner wrote: That doesn't explain why the bit value isn't normalized to be smaller than BITS_PER_UNIT; any whole bytes could be incorporated into the variably sized offset. It can't be normalized to BITS_PER_UNIT, but to DECL_OFFSET_ALIGN since we are asserting that DECL_FIELD_OFFSET

Re: representation of struct field offsets

2006-09-30 Thread Richard Kenner
> That doesn't explain why the bit value isn't normalized to be smaller > than BITS_PER_UNIT; any whole bytes could be incorporated into the > variably sized offset. It can't be normalized to BITS_PER_UNIT, but to DECL_OFFSET_ALIGN since we are asserting that DECL_FIELD_OFFSET is aligned to DECL

Re: representation of struct field offsets

2006-09-29 Thread Mark Mitchell
Richard Kenner wrote: I don't follow. The current representation of variable-position fields uses *both* fields, a variable offset in *bytes*, plus a constant offset in *bits*. That doesn't explain why the bit value isn't normalized to be smaller than BITS_PER_UNIT; any whole bytes could be

Re: representation of struct field offsets

2006-09-29 Thread Richard Kenner
> Unique, but uncommon. Right. > Thus, it would make sense to make it a union with the other > information with a discriminator. As a plus, you'd be able to tell > variable offset fields by checking a single bit instead of a load > (TREE_CODE ). > > IE > unsigned int: offset_is_variable:1; > un

Re: representation of struct field offsets

2006-09-29 Thread Daniel Berlin
On 9/28/06, Richard Kenner <[EMAIL PROTECTED]> wrote: > The only trouble you'll probably run into is with fields whose offset > from the start of a structure is variable. Exactly. That's the reason it's defined the way it is. There is no way to synthesize that field from any other in the FIELD

Re: representation of struct field offsets

2006-09-28 Thread Richard Kenner
> The only trouble you'll probably run into is with fields whose offset > from the start of a structure is variable. Exactly. That's the reason it's defined the way it is. There is no way to synthesize that field from any other in the FIELD_DECL in the most general case: it is unique informati

Re: representation of struct field offsets

2006-09-28 Thread Mark Mitchell
Chris Lattner wrote: Also, because of GCC's internal representation of integers, you have to be careful that you have enough bits; for example, you need 72 bits to represent things in a 64-bit address space. Actually, just 67, right? Does GCC support structures whose size is greater than 2^

Re: representation of struct field offsets

2006-09-28 Thread Sandra Loosemore
Mark Mitchell wrote: Are you going through the stor_layout.c:place_field routines when creating structure types? If so, I wouldn't; here, you know where stuff is supposed to go, so I would just put it there, and set DECL_FIELD_OFFSET, etc., accordingly. No, I'm not using the fancy stor_lay

Re: representation of struct field offsets

2006-09-28 Thread Chris Lattner
On Sep 28, 2006, at 1:58 PM, Mark Mitchell wrote: Chris Lattner wrote: An alternative design, which would save a field, is just to keep the offset of a field, in bits, from the start of the structure. Yes, that would also work. But, in many cases, you need the byte offset, so there's a

Re: representation of struct field offsets

2006-09-28 Thread Mark Mitchell
Chris Lattner wrote: An alternative design, which would save a field, is just to keep the offset of a field, in bits, from the start of the structure. Yes, that would also work. But, in many cases, you need the byte offset, so there's a time/space tradeoff. Also, because of GCC's internal

Re: representation of struct field offsets

2006-09-28 Thread Chris Lattner
On Sep 28, 2006, at 1:43 PM, Mark Mitchell wrote: Sandra Loosemore wrote: I've been having a heck of a time figuring out how to translate the offsets for struct fields from the DWARF encoding back to GCC's internal encoding for the LTO project. Yes, that's a nasty bit. I think the DECL_FI

Re: representation of struct field offsets

2006-09-28 Thread Mark Mitchell
Sandra Loosemore wrote: I've been having a heck of a time figuring out how to translate the offsets for struct fields from the DWARF encoding back to GCC's internal encoding for the LTO project. Yes, that's a nasty bit. I think the DECL_FIELD_OFFSET/DECL_FIELD_BIT_OFFSET stuff is, quite sim

Re: representation of struct field offsets

2006-09-28 Thread Dale Johannesen
On Sep 27, 2006, at 7:04 PM, Sandra Loosemore wrote: I've been having a heck of a time figuring out how to translate the offsets for struct fields from the DWARF encoding back to GCC's internal encoding for the LTO project. I've got a handle on the DWARF encoding and how to do the necessa