2009/8/3 Jim Wilson <wil...@codesourcery.com>: > 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. Is there a problem with > global variables? Is the variable initialized or uninitialized? If it is > uninitialized, is it common? If this a local variable? Is this a function > argument or parameter? Is this a named or unnamed (stdarg) argument or > parameter? Etc. It 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 From 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