On Wed, Apr 9, 2008 at 4:05 PM, DJ Delorie <[EMAIL PROTECTED]> wrote:
>
>  FYI: my h8/300h builds are failing with the same message, but with
>  different types.  Haven't investigated yet.
>
>
>  > What size is the internal 'sizetype'?
>
>  16 bits.
>
>
>  > Is there an integer type with the same width as the pointer type?
>
>  No.  The m32c doesn't have enough operators to have a pointer-sized
>  sizetype (specifically, it needs an arbitrary-multiply op).
>
>  There is a PSImode type, but no C type to correspond to it.
>
>  Pointers are 24 bits because the address registers are physically 24
>  bits wide, and there are some math operators that operate on them
>  directly (adding and shifting, mostly).  But 24 bit math is
>  incomplete, and 32 bit math is a LOT more expensive than 16 bit math.

I see.

>  > Basically the problems look like converting a pointer to an integer
>  > always either extends or truncates which is both prohibited in the
>  > GIMPLE IL (as the pointer doesn't have a sign we don't know whether
>  > to sign- or zero-extend it).
>
>  In this case, though, we *are* doing signed arithmatic on it before
>  converting.  Plus, the code would work (for m32c) if there were no
>  conversion at all - just leave it as a pointer type.

Sorry, arithmetic on pointer-types is no longer possible.  I guess we
ran into this before (mismatch between sizetype and pointer type size),
but as we have POINTER_PLUS_EXPR it should simply work.  How
does the source look like that we end up converting a pointer to an
integer?  Is the C intptr_t 32bits?  Basically the GIMPLE IL requires
an intermediate conversion to an integral type of the same width
than the pointer type (it wants to leave the decision whether pointers
sign- or zero-extend to the frontends, but at least not to every
optimization pass looking at such conversions).

I see the possibility of a target-hook here that converts a pointer to
either a signed or unsigned (target choice) internal integral type.
This hook would be called by the frontend for pointer-to-integer
conversion.

You may want to look into convert.c:convert_to_integer to "hack"
this in there - just something like
  fold_convert (build_nonstandard_integer_type (TYPE_PRECISION
(ptr_type), true/false), ptr);
as first conversion if you enter with a pointer type argument.

Richard.

Reply via email to