From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12734 invoked by alias); 5 Aug 2009 10:06:56 -0000 Received: (qmail 12725 invoked by uid 22791); 5 Aug 2009 10:06:55 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from rv-out-0708.google.com (HELO rv-out-0708.google.com) (209.85.198.242) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Aug 2009 10:06:50 +0000 Received: by rv-out-0708.google.com with SMTP id c5so1617036rvf.56 for ; Wed, 05 Aug 2009 03:06:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.157.5 with SMTP id f5mr6026215rve.242.1249466808079; Wed, 05 Aug 2009 03:06:48 -0700 (PDT) In-Reply-To: <1249441866.2510.8.camel@localhost> References: <4A771CCD.8010205@codesourcery.com> <1249441866.2510.8.camel@localhost> From: Mohamed Shafi Date: Wed, 05 Aug 2009 11:20:00 -0000 Message-ID: Subject: Re: How to set the alignment To: Jim Wilson Cc: GCC , jean.christophe.beyler@gmail.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-08/txt/msg00087.txt.bz2 2009/8/5 Jim Wilson : > On Tue, 2009-08-04 at 11:09 +0530, Mohamed Shafi wrote: >> >> i am not able to implement the alignment for short. >> >> The following is are the macros that i used for this >> >> #define PARM_BOUNDARY 8 >> >> #define STACK_BOUNDARY 64 >> The target is 32bit . The first two parameters are passed in registers >> and the rest in stack. For the parameters that are passed in stack the >> alignment is that of the data type. The stack pointer is 8 byte >> aligned. char is 1 byte, int is 4 byte and short is 2 byte. The code >> that is getting generated is give below (-O0 -fomit-frame-pointer) > > Er, wait. =A0You set PARM_BOUNDARY to 8. =A0This means all arguments will= be > padded to at most an 8-bit boundary, which means that yes, a short after > a char will have only 1 byte alignment. =A0If you want all arguments to > have 2-byte alignment, then you need to set PARM_BOUNDARY to 16. =A0But > you probably want a value of 32 here so that 4-byte ints get 4-byte > alignment. =A0This will allocate a minimum 4-byte stack slot for every > argument. =A0I don't know the calling convention, so I don't know exactly > how you want arguments arranged on the stack. > > If you are pushing arguments, then you can lie in the PUSH_ROUNDING > macro. =A0You could say for instance that one byte pushes always push 2 > bytes. =A0This ensures that the stack always has 2-byte alignment while > pushing arguments. =A0If your push instruction doesn't actually do this, > then you need to modify the pushqi pattern to emit two pushes or use a > HImode push to get the right behaviour. > > Try looking at the code in store_one_arg in calls.c, and emit_push_insn > in expr.c. > What i did was to define FUNCTION_ARG_BOUNDARY macro to return the alignment as per the requirement. i.e 8bits for char, 16bits for short, 32bits for int and kept PARM_BOUNDARY to 8. Now the complier is emitting the alignment prperly. Is this OK? Regards, Shafi