From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23608 invoked by alias); 24 Apr 2003 18:04:57 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 23436 invoked from network); 24 Apr 2003 18:04:56 -0000 Received: from unknown (HELO lacrosse.corp.redhat.com) (66.187.233.200) by sources.redhat.com with SMTP; 24 Apr 2003 18:04:56 -0000 Received: from prospero.boston.redhat.com (sebastian-int.corp.redhat.com [172.16.52.221]) by lacrosse.corp.redhat.com (8.11.6/8.9.3) with ESMTP id h3OI4sV10620; Thu, 24 Apr 2003 14:04:54 -0400 Received: by prospero.boston.redhat.com (Postfix, from userid 4046) id DAC04F8CF4; Thu, 24 Apr 2003 14:01:32 -0400 (EDT) To: Zack Weinberg Cc: Geert Bosch , Alexandre Oliva , kenner@vlsi1.ultra.nyu.edu (Richard Kenner), gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org, Jakub Jelinek , Richard Henderson , Jason Merrill Subject: Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT From: Jason Merrill In-Reply-To: <87d6jbkdi9.fsf@egil.codesourcery.com> (Zack Weinberg's message of "Thu, 24 Apr 2003 10:32:14 -0700") References: <386D9560-7618-11D7-8766-00039344BF4A@gnat.com> <87d6jbkdi9.fsf@egil.codesourcery.com> Date: Thu, 24 Apr 2003 19:31:00 -0000 Message-ID: User-Agent: Gnus/5.090013 (Oort Gnus v0.13) Emacs/21.2 (i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-04/txt/msg01246.txt.bz2 On Thu, 24 Apr 2003 10:32:14 -0700, Zack Weinberg wrote: > Jason Merrill writes: > >> 1) For types, we want to be able to force a minimum alignment for >> efficiency/correctness of access. >> 2) For fields, we want to be able to force a minimum alignment. >> 3) For fields, we want to be able to reduce alignment for packing efficiency. >> 4) For objects, we want to be able to force a minimum alignment. >> 5) For objects, we want to be able to force an exact alignment for building >> up special sections (and for other reasons?). >> >> Anything else? >> >> 1 is handled by TYPE_ALIGN/TYPE_USER_ALIGN. >> 2 and 4/5 are handled by DECL_ALIGN/DECL_USER_ALIGN. >> 3 is handled by DECL_PACKED. > > I'm leery of bringing DECL_PACKED into this -- the "packed" concept > has never really been nailed down as far as I know, and I worry that > it might bring in a whole 'nother set of conflicting assumptions from > the user community of __attribute__ ((packed)). It seems pretty clear to me, though the comment in tree.h is wrong. __attribute ((packed)) means use the smallest alignment possible, unless a greater alignment is specified with __attribute ((aligned (n))). So DECL_PACKED means "don't pad to an alignment greater than DECL_ALIGN". > My suggestion would be that we rip out all the existing ALIGN stuff in > favor of two TYPE fields and two DECL fields named TYPE_MIN_ALIGN, > TYPE_MAX_ALIGN, DECL_MIN_ALIGN, and DECL_MAX_ALIGN. This sounds interesting, but I think that one integer and two flags is actually what we need. > The semantics are that *_MIN_ALIGN is the minimum alignment to enforce > for a type or object Yes. > and *_MAX_ALIGN is the maximum alignment that can be assumed for a type > or object. No! That's another meaning of *_MIN_ALIGN. The enforced alignment is also the alignment that can be assumed. These are the two parties to the alignment contract. DECL_MAX_ALIGN would be the maximum alignment that can be applied to an object. But if you want to specify a maximum alignment at all, I can't think of a situation in which we would a maximum different from the minimum, so a flag should be adequate. We also still need to be able to suppress the effects of BIGGEST_FIELD_ALIGNMENT, which is why we have DECL_USER_ALIGN in the first place. So, we need: A numerical alignment. A flag which says "no, really, don't reduce the alignment, even if the ABI says to." A flag which says "don't add extra padding." It's not clear to me that we need the second flag for types. The first flag is only really meaningful for FIELD_DECLs, and the second is only really meaningful for VAR_DECLs. Currently, both flags use DECL_USER_ALIGN. Option A is to declare this to be intended, and make the one-line fix to do_type_align to only copy TYPE_USER_ALIGN to DECL_USER_ALIGN for FIELD_DECLs. Option B is to use a different macro for the second flag. DECL_PACKED already means "don't increase the alignment", so it seems appropriate to use it in this context, too. Currently, there's no way to declare a misaligned VAR_DECL. Do we care? Jason