From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10419 invoked by alias); 4 Aug 2009 05:39:45 -0000 Received: (qmail 10165 invoked by uid 22791); 4 Aug 2009 05:39:43 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_15,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-px0-f193.google.com (HELO mail-px0-f193.google.com) (209.85.216.193) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 04 Aug 2009 05:39:36 +0000 Received: by pxi31 with SMTP id 31so2846380pxi.14 for ; Mon, 03 Aug 2009 22:39:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.141.26.8 with SMTP id d8mr4674592rvj.37.1249364375099; Mon, 03 Aug 2009 22:39:35 -0700 (PDT) In-Reply-To: <4A771CCD.8010205@codesourcery.com> References: <4A771CCD.8010205@codesourcery.com> From: Mohamed Shafi Date: Tue, 04 Aug 2009 06:24:00 -0000 Message-ID: Subject: Re: How to set the alignment To: Jim Wilson Cc: GCC 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/msg00051.txt.bz2 2009/8/3 Jim Wilson : > On 08/03/2009 02:14 AM, Mohamed Shafi wrote: >> >> short - 2 bytes >> 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 > > You haven't explained what the actual problem is. =A0Is there a problem w= ith > global variables? =A0Is the variable initialized or uninitialized? If it = is > uninitialized, is it common? =A0If this a local variable? =A0Is this a fu= nction > argument or parameter? =A0Is this a named or unnamed (stdarg) argument or > parameter? =A0Etc. =A0It always helps to include a testcase. > > You should also mention what gcc is currently emitting, why it is wrong, = and > what the output should be instead. > > All this talk about stack and parm boundary suggests that it might be an > issue with function arguments, in which case you will probably have to > describe the calling conventions a bit so we can understand what you want. > This is the test case that i tried short funs (int a, int b, char w,short e,short r) { return e+r; } 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) funs: add 16,sp mov d0,(sp-16) mov d1,(sp-12) movh (sp-19),d0 movh d0,(sp-8) movh (sp-21),d0 movh d0,(sp-6) movh (sp-8),d1 movh (sp-6),d0 add d1,d0,d0 sub 16,sp ret =46rom the above code you can see that some of the half word access is not aligned on a 2byte boundary. So where am i going wrong. Hope this info is enough Regards, Shafi