public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: sizetype, bitsizetype and DECL_FIELD_BITPOS
@ 1999-12-29 17:35 Richard Kenner
  1999-12-29 19:31 ` Joern Rennecke
  1999-12-31 23:54 ` Richard Kenner
  0 siblings, 2 replies; 14+ messages in thread
From: Richard Kenner @ 1999-12-29 17:35 UTC (permalink / raw)
  To: amylaar; +Cc: gcc

    >                                        I see places where it is
    > used in both contexts and, unless I'm missing something, we are missing
    > conversions.
    
    I suppose you mean this?

          offset = size_binop (PLUS_EXPR, offset,
                               size_binop (EXACT_DIV_EXPR, var,
                                           size_int (BITS_PER_UNIT)));

Yes.  VAR is clearly bitsizetype and OFFSET is supposed to be sizetype
and there's no conversion.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: sizetype, bitsizetype and DECL_FIELD_BITPOS
  1999-12-29 17:35 sizetype, bitsizetype and DECL_FIELD_BITPOS Richard Kenner
@ 1999-12-29 19:31 ` Joern Rennecke
  1999-12-31 23:54   ` Joern Rennecke
  1999-12-31 23:54 ` Richard Kenner
  1 sibling, 1 reply; 14+ messages in thread
From: Joern Rennecke @ 1999-12-29 19:31 UTC (permalink / raw)
  To: Richard Kenner; +Cc: gcc

> Yes.  VAR is clearly bitsizetype and OFFSET is supposed to be sizetype
> and there's no conversion.

size_binop is supposed to convert to sizetype.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: sizetype, bitsizetype and DECL_FIELD_BITPOS
  1999-12-29 19:31 ` Joern Rennecke
@ 1999-12-31 23:54   ` Joern Rennecke
  0 siblings, 0 replies; 14+ messages in thread
From: Joern Rennecke @ 1999-12-31 23:54 UTC (permalink / raw)
  To: Richard Kenner; +Cc: gcc

> Yes.  VAR is clearly bitsizetype and OFFSET is supposed to be sizetype
> and there's no conversion.

size_binop is supposed to convert to sizetype.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: sizetype, bitsizetype and DECL_FIELD_BITPOS
  1999-12-29 17:35 sizetype, bitsizetype and DECL_FIELD_BITPOS Richard Kenner
  1999-12-29 19:31 ` Joern Rennecke
@ 1999-12-31 23:54 ` Richard Kenner
  1 sibling, 0 replies; 14+ messages in thread
From: Richard Kenner @ 1999-12-31 23:54 UTC (permalink / raw)
  To: amylaar; +Cc: gcc

    >                                        I see places where it is
    > used in both contexts and, unless I'm missing something, we are missing
    > conversions.
    
    I suppose you mean this?

          offset = size_binop (PLUS_EXPR, offset,
                               size_binop (EXACT_DIV_EXPR, var,
                                           size_int (BITS_PER_UNIT)));

Yes.  VAR is clearly bitsizetype and OFFSET is supposed to be sizetype
and there's no conversion.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: sizetype, bitsizetype and DECL_FIELD_BITPOS
  1999-12-30  2:10 Richard Kenner
  1999-12-30  9:37 ` Joern Rennecke
@ 1999-12-31 23:54 ` Richard Kenner
  1 sibling, 0 replies; 14+ messages in thread
From: Richard Kenner @ 1999-12-31 23:54 UTC (permalink / raw)
  To: amylaar; +Cc: gcc

    > Yes.  VAR is clearly bitsizetype and OFFSET is supposed to be sizetype
    > and there's no conversion.

    size_binop is supposed to convert to sizetype.

In which cases?  Surely it can't convert both of its args unconditionally to
sizetype since it's called to do an EXACT_DIV_EXPR of a bitsizetype value by
BITS_PER_UNIT.  That division has to be in bitsizetype.  And in that case the
BITS_PER_UNIT also needs to be bitsizetype, while it's currently sizetype.
Moreover, in a number of cases, the WITH_RECORD_EXPR that's being made is
also the wrong type (sizetype instead of bitsizetype).

I'm certainly willing to fix this all up, but I'd like to try to get a
concensus as to what to fix it up *to*.  I'd really like to better understand
the reason for adding all this in the first place since it seems like it'll
be quite a lot of trouble to get this to work properly and I'm not convinced
it's worth it and it wouldn't be simpler just to back this all out and try to
find another way to fix the original problem (which I don't have a complete
explanation of yet).

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: sizetype, bitsizetype and DECL_FIELD_BITPOS
  1999-12-29 17:07 ` Joern Rennecke
@ 1999-12-31 23:54   ` Joern Rennecke
  0 siblings, 0 replies; 14+ messages in thread
From: Joern Rennecke @ 1999-12-31 23:54 UTC (permalink / raw)
  To: Richard Kenner; +Cc: gcc

> Also, there is a comment referencing DECL_SIZE_UNIT, but I see no such
> macros.  Then there's the code in get_inner_reference: first of all,
> is OFFSET of bitsizetype or sizetype?

OFFSET is sizetype.

>                                        I see places where it is
> used in both contexts and, unless I'm missing something, we are missing
> conversions.

I suppose you mean this?

          offset = size_binop (PLUS_EXPR, offset,
                               size_binop (EXACT_DIV_EXPR, var,
                                           size_int (BITS_PER_UNIT)));

size_binop is documented to get its type from sizetype.
I appears to do something different, which will matter if offset is zero
and has a type that is not sizetype.

Otherwise, the EXACT_DIV_EXPR should be translated to a straight shift and
the rest of the computation should be done in sizetype.


>               Secondly, the array code talks about if the bitsize
> computation overflow, but I see no overflow test.

Yes, indeed, the comment is imprecise at best.  A non-zero
TREE_INT_CST_HIGH (xindex) doesn't mean that an overflow occured, it
just means that pbitpos is unsuitable to pass the result back to the
caller.  That can happen in a 32->64 bit cross-compilation, for instance.
Incidentally, pbitpos is an int *, but it would have to be a HOST_WIDE_INT
to accomodate TREE_INT_CST_LOW (xindex)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* sizetype, bitsizetype and DECL_FIELD_BITPOS
  1999-12-25 18:36 Richard Kenner
  1999-12-29 17:07 ` Joern Rennecke
@ 1999-12-31 23:54 ` Richard Kenner
  1 sibling, 0 replies; 14+ messages in thread
From: Richard Kenner @ 1999-12-31 23:54 UTC (permalink / raw)
  To: gcc

I'm a bit confused about the new bitsizetype and TYPE_SIZE_UNIT.

As I understand it, the purpose of this new code is to allow types and
objects to be 2**32 *bytes* long instead of 2**32 *bits* long (on
32-bit machines) that we used to allow.

So sizetype always measures bytes and bitsizetype always measures bits.
We have a TYPE_SIZE_UNIT to represent the size of a type in bits and
that's of type sizetype.

On 32-bit machines, as I understand it, sizetype will be 32 bits and
bitsizetype will need 64 bit arithmetic.

But what about DECL_FIELD_BITPOS?  That's used all the time when a fiekld
of a struct has variable size.  It used to be 32-bit, but now it looks
like it involves 64-bit arithmetic.  Is that what was intended?

Also, there is a comment referencing DECL_SIZE_UNIT, but I see no such
macros.  Then there's the code in get_inner_reference: first of all,
is OFFSET of bitsizetype or sizetype?  I see places where it is
used in both contexts and, unless I'm missing something, we are missing
conversions.  Secondly, the array code talks about if the bitsize
computation overflow, but I see no overflow test.

We've always said that DECL_FIELD_BITPOS was either or constant or
a variable possibily plus a constnat, where the variable was known
to be a multiple of BITS_PER_UNIT.  But now do we have to say that
it's a PLUS_EXPR of a conversion plus a constant and then change
teh code using it appropriately? I certainly don't think we want to
force all such computations to 64 bits.

Am I missing something here or are those bugs?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: sizetype, bitsizetype and DECL_FIELD_BITPOS
  1999-12-30  9:37 ` Joern Rennecke
@ 1999-12-31 23:54   ` Joern Rennecke
  0 siblings, 0 replies; 14+ messages in thread
From: Joern Rennecke @ 1999-12-31 23:54 UTC (permalink / raw)
  To: Richard Kenner; +Cc: amylaar, gcc

>     size_binop is supposed to convert to sizetype.
> 
> In which cases?  Surely it can't convert both of its args unconditionally to
> sizetype since it's called to do an EXACT_DIV_EXPR of a bitsizetype value by
> BITS_PER_UNIT.  That division has to be in bitsizetype.  And in that case the
> BITS_PER_UNIT also needs to be bitsizetype, while it's currently sizetype.
> Moreover, in a number of cases, the WITH_RECORD_EXPR that's being made is
> also the wrong type (sizetype instead of bitsizetype).

I read the comment that size_binop is supposed to convert the result
to sizetype.

If size_binop required all inputs and the output to be the same type, it
should just get the result type from one of the arguments, and be called
tree_binop or something similarily type-independent.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: sizetype, bitsizetype and DECL_FIELD_BITPOS
  1999-12-31  1:06 Richard Kenner
@ 1999-12-31 23:54 ` Richard Kenner
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Kenner @ 1999-12-31 23:54 UTC (permalink / raw)
  To: amylaar; +Cc: gcc

    I read the comment that size_binop is supposed to convert the result
    to sizetype.

Hmm... well, that *will* work in all current usages, except that we don't
always pass both inputs of the same type, but I'm concerned about such
a specification since it means that somebody accidentally calling it
to add two bitsizetype values will have an unexpected truncation.

    If size_binop required all inputs and the output to be the same type,
    it should just get the result type from one of the arguments, and be
    called tree_binop or something similarily type-independent.

Well, yes, I quite understand that.  And that's part of the reason why I'm
getting increasingly dubious about this whole idea of having both sizetype and
bitsizetype: it makes the use of size_binop *very* tricky.  Indeed, size_int
has the same problem. We have a bitsize_int now, but it seems that, for
some reason, its parameters are different (and nearly always called wrong,
since "0L" is totally bogus).  Perhaps we need a bitsize_binop and then
an explicit conversion, but I'd still like to be convinced that all this
complexity is actually buying us something that justifies it.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: sizetype, bitsizetype and DECL_FIELD_BITPOS
@ 1999-12-31  1:06 Richard Kenner
  1999-12-31 23:54 ` Richard Kenner
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Kenner @ 1999-12-31  1:06 UTC (permalink / raw)
  To: amylaar; +Cc: gcc

    I read the comment that size_binop is supposed to convert the result
    to sizetype.

Hmm... well, that *will* work in all current usages, except that we don't
always pass both inputs of the same type, but I'm concerned about such
a specification since it means that somebody accidentally calling it
to add two bitsizetype values will have an unexpected truncation.

    If size_binop required all inputs and the output to be the same type,
    it should just get the result type from one of the arguments, and be
    called tree_binop or something similarily type-independent.

Well, yes, I quite understand that.  And that's part of the reason why I'm
getting increasingly dubious about this whole idea of having both sizetype and
bitsizetype: it makes the use of size_binop *very* tricky.  Indeed, size_int
has the same problem. We have a bitsize_int now, but it seems that, for
some reason, its parameters are different (and nearly always called wrong,
since "0L" is totally bogus).  Perhaps we need a bitsize_binop and then
an explicit conversion, but I'd still like to be convinced that all this
complexity is actually buying us something that justifies it.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: sizetype, bitsizetype and DECL_FIELD_BITPOS
  1999-12-30  2:10 Richard Kenner
@ 1999-12-30  9:37 ` Joern Rennecke
  1999-12-31 23:54   ` Joern Rennecke
  1999-12-31 23:54 ` Richard Kenner
  1 sibling, 1 reply; 14+ messages in thread
From: Joern Rennecke @ 1999-12-30  9:37 UTC (permalink / raw)
  To: Richard Kenner; +Cc: amylaar, gcc

>     size_binop is supposed to convert to sizetype.
> 
> In which cases?  Surely it can't convert both of its args unconditionally to
> sizetype since it's called to do an EXACT_DIV_EXPR of a bitsizetype value by
> BITS_PER_UNIT.  That division has to be in bitsizetype.  And in that case the
> BITS_PER_UNIT also needs to be bitsizetype, while it's currently sizetype.
> Moreover, in a number of cases, the WITH_RECORD_EXPR that's being made is
> also the wrong type (sizetype instead of bitsizetype).

I read the comment that size_binop is supposed to convert the result
to sizetype.

If size_binop required all inputs and the output to be the same type, it
should just get the result type from one of the arguments, and be called
tree_binop or something similarily type-independent.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: sizetype, bitsizetype and DECL_FIELD_BITPOS
@ 1999-12-30  2:10 Richard Kenner
  1999-12-30  9:37 ` Joern Rennecke
  1999-12-31 23:54 ` Richard Kenner
  0 siblings, 2 replies; 14+ messages in thread
From: Richard Kenner @ 1999-12-30  2:10 UTC (permalink / raw)
  To: amylaar; +Cc: gcc

    > Yes.  VAR is clearly bitsizetype and OFFSET is supposed to be sizetype
    > and there's no conversion.

    size_binop is supposed to convert to sizetype.

In which cases?  Surely it can't convert both of its args unconditionally to
sizetype since it's called to do an EXACT_DIV_EXPR of a bitsizetype value by
BITS_PER_UNIT.  That division has to be in bitsizetype.  And in that case the
BITS_PER_UNIT also needs to be bitsizetype, while it's currently sizetype.
Moreover, in a number of cases, the WITH_RECORD_EXPR that's being made is
also the wrong type (sizetype instead of bitsizetype).

I'm certainly willing to fix this all up, but I'd like to try to get a
concensus as to what to fix it up *to*.  I'd really like to better understand
the reason for adding all this in the first place since it seems like it'll
be quite a lot of trouble to get this to work properly and I'm not convinced
it's worth it and it wouldn't be simpler just to back this all out and try to
find another way to fix the original problem (which I don't have a complete
explanation of yet).

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: sizetype, bitsizetype and DECL_FIELD_BITPOS
  1999-12-25 18:36 Richard Kenner
@ 1999-12-29 17:07 ` Joern Rennecke
  1999-12-31 23:54   ` Joern Rennecke
  1999-12-31 23:54 ` Richard Kenner
  1 sibling, 1 reply; 14+ messages in thread
From: Joern Rennecke @ 1999-12-29 17:07 UTC (permalink / raw)
  To: Richard Kenner; +Cc: gcc

> Also, there is a comment referencing DECL_SIZE_UNIT, but I see no such
> macros.  Then there's the code in get_inner_reference: first of all,
> is OFFSET of bitsizetype or sizetype?

OFFSET is sizetype.

>                                        I see places where it is
> used in both contexts and, unless I'm missing something, we are missing
> conversions.

I suppose you mean this?

          offset = size_binop (PLUS_EXPR, offset,
                               size_binop (EXACT_DIV_EXPR, var,
                                           size_int (BITS_PER_UNIT)));

size_binop is documented to get its type from sizetype.
I appears to do something different, which will matter if offset is zero
and has a type that is not sizetype.

Otherwise, the EXACT_DIV_EXPR should be translated to a straight shift and
the rest of the computation should be done in sizetype.


>               Secondly, the array code talks about if the bitsize
> computation overflow, but I see no overflow test.

Yes, indeed, the comment is imprecise at best.  A non-zero
TREE_INT_CST_HIGH (xindex) doesn't mean that an overflow occured, it
just means that pbitpos is unsuitable to pass the result back to the
caller.  That can happen in a 32->64 bit cross-compilation, for instance.
Incidentally, pbitpos is an int *, but it would have to be a HOST_WIDE_INT
to accomodate TREE_INT_CST_LOW (xindex)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* sizetype, bitsizetype and DECL_FIELD_BITPOS
@ 1999-12-25 18:36 Richard Kenner
  1999-12-29 17:07 ` Joern Rennecke
  1999-12-31 23:54 ` Richard Kenner
  0 siblings, 2 replies; 14+ messages in thread
From: Richard Kenner @ 1999-12-25 18:36 UTC (permalink / raw)
  To: gcc

I'm a bit confused about the new bitsizetype and TYPE_SIZE_UNIT.

As I understand it, the purpose of this new code is to allow types and
objects to be 2**32 *bytes* long instead of 2**32 *bits* long (on
32-bit machines) that we used to allow.

So sizetype always measures bytes and bitsizetype always measures bits.
We have a TYPE_SIZE_UNIT to represent the size of a type in bits and
that's of type sizetype.

On 32-bit machines, as I understand it, sizetype will be 32 bits and
bitsizetype will need 64 bit arithmetic.

But what about DECL_FIELD_BITPOS?  That's used all the time when a fiekld
of a struct has variable size.  It used to be 32-bit, but now it looks
like it involves 64-bit arithmetic.  Is that what was intended?

Also, there is a comment referencing DECL_SIZE_UNIT, but I see no such
macros.  Then there's the code in get_inner_reference: first of all,
is OFFSET of bitsizetype or sizetype?  I see places where it is
used in both contexts and, unless I'm missing something, we are missing
conversions.  Secondly, the array code talks about if the bitsize
computation overflow, but I see no overflow test.

We've always said that DECL_FIELD_BITPOS was either or constant or
a variable possibily plus a constnat, where the variable was known
to be a multiple of BITS_PER_UNIT.  But now do we have to say that
it's a PLUS_EXPR of a conversion plus a constant and then change
teh code using it appropriately? I certainly don't think we want to
force all such computations to 64 bits.

Am I missing something here or are those bugs?

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~1999-12-31 23:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-29 17:35 sizetype, bitsizetype and DECL_FIELD_BITPOS Richard Kenner
1999-12-29 19:31 ` Joern Rennecke
1999-12-31 23:54   ` Joern Rennecke
1999-12-31 23:54 ` Richard Kenner
  -- strict thread matches above, loose matches on Subject: below --
1999-12-31  1:06 Richard Kenner
1999-12-31 23:54 ` Richard Kenner
1999-12-30  2:10 Richard Kenner
1999-12-30  9:37 ` Joern Rennecke
1999-12-31 23:54   ` Joern Rennecke
1999-12-31 23:54 ` Richard Kenner
1999-12-25 18:36 Richard Kenner
1999-12-29 17:07 ` Joern Rennecke
1999-12-31 23:54   ` Joern Rennecke
1999-12-31 23:54 ` Richard Kenner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).