This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: Ulrich dot Weigand at de dot ibm dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 31 Mar 03 14:58:09 EST
- Subject: Re: RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3
Sorry I forgot to get back to this when I got back last week.
What appears to happen is that the Ada source in question defines a
variable-sized object with non-standard alignment requirements, and
Ada reflects this by building a DECL_SIZE_UNIT tree containing various
mult_expr and div_expr nodes. As alignment is counted in bits, those
have type bit_size_type, which on 64-bit platforms corresponds to
TImode. When expanding that tree, the backend emits calls to __divti3.
The point of having separate DECL_SIZE_UNIT and DECL_SIZE is precisely for
the former to only have computations in sizetype and the latter in bitsizetype.
There are very rare situations where a bitsizetype might be in the expression
for DECL_SIZE_UNIT, but other occurrences are a bug. Indeed, there's
a trivial bug in layout_decl that would account for some of those usages.
Here's the diff; I'll do the testing and installation for it within the
next few days.
*************** layout_decl (decl, known_align)
*** 368,372 ****
DECL_SIZE_UNIT (decl) = TYPE_SIZE_UNIT (type);
}
! else
DECL_SIZE_UNIT (decl)
= convert (sizetype, size_binop (CEIL_DIV_EXPR, DECL_SIZE (decl),
--- 365,369 ----
DECL_SIZE_UNIT (decl) = TYPE_SIZE_UNIT (type);
}
! else if (DECL_SIZE_UNIT (decl) == 0)
DECL_SIZE_UNIT (decl)
= convert (sizetype, size_binop (CEIL_DIV_EXPR, DECL_SIZE (decl),
- does bit_size_type really need to be TImode
Perhaps not, but it should for consistency. In practice, not that much needs
to be computed dynamically for bitsizes.
- if so, shouldn't these special cases be implemented more efficiently
somewhere (we divide by an integer constant 8 here)
No.
- in general, are we really supposed to need TImode division
Yes.
How does this work on other 64-bit platforms?
By having __divti3.