Mercurial > hg > CbC > old > device
changeset 803:a5f9e5a4db1b i64-worked
global alignment
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 24 Nov 2010 18:52:28 +0900 |
parents | bdb63568ca08 |
children | aec31f182f9f 93587e4c480f |
files | mc-code-powerpc.c mc-parse.c mc-parse.h |
diffstat | 3 files changed, 41 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-powerpc.c Wed Nov 24 16:10:03 2010 +0900 +++ b/mc-code-powerpc.c Wed Nov 24 18:52:28 2010 +0900 @@ -485,7 +485,7 @@ #define func_disp_offset 68 #define func_disp_offset1 16 -#define code_disp_offset0 (0) +#define code_disp_offset0 (-4) #else @@ -498,7 +498,7 @@ #endif -int disp_offset = 0; +int disp_offset = -4; #define CODE_LVAR(l) ((l)+code_disp_offset0) #define CODE_CALLER_ARG(l) ((l)+arg_offset1) @@ -3919,19 +3919,32 @@ NMTBL *n; int init; char *extrn; init=0; + global_list = reversen(global_list); + text_mode(0); for(n = global_list;n!=&null_nptr;n = n->next) { if ((n->sc == GVAR) && n->dsp != -1) { /* n->dsp = -1 means initialized global */ if (init==0) { - data_mode(0); + // data_mode(0); + text_mode(0); + printf("\t.align 3\n"); init=1; } - printf(".comm %s%s,%d\n",npfx,n->nm,size(n->ty)); + int align; + if ((align=attr_value(n,ALIGNED))) { + int a = ilog(caddr(align)); + printf(".comm %s%s,%d,%d\n",npfx,n->nm,size(n->ty),a); + } else if (size(n->ty)>1) { + printf(".comm %s%s,%d,2\n",npfx,n->nm,size(n->ty)); + } else + printf(".comm %s%s,%d\n",npfx,n->nm,size(n->ty)); } else if ((n->sc==STATIC) && n->dsp != -1) { /* n->dsp = -1 means initialized global */ if (is_code(n)||is_function(n)) continue; if (init==0) { - data_mode(0); + text_mode(0); + printf("\t.align 8\n"); + // data_mode(0); init=1; } printf(".lcomm %s%s,%d\n",npfx,n->nm,size(n->ty)); @@ -4001,6 +4014,12 @@ comm(NMTBL *n) { int align = 1; + if ((align=attr_value(n,ALIGNED))) { + align = ilog(caddr(align)); + } else if (size(n->ty)>4) + align = 2; + else if (size(n->ty)>4) + align = 0; switch(n->ty) { case DOUBLE: case LONGLONG:
--- a/mc-parse.c Wed Nov 24 16:10:03 2010 +0900 +++ b/mc-parse.c Wed Nov 24 18:52:28 2010 +0900 @@ -1435,6 +1435,22 @@ return t2; } +NMTBL * +reversen(NMTBL *t1) +{ + NMTBL *t2,*t3; + + t2= &null_nptr; + while(t1 != &null_nptr) { + t3=t1->next; + t1->next = t2; + t2=t1; + t1=t3; + } + return t2; +} + + /* calcurate size of type */
--- a/mc-parse.h Wed Nov 24 16:10:03 2010 +0900 +++ b/mc-parse.h Wed Nov 24 18:52:28 2010 +0900 @@ -163,6 +163,7 @@ extern int neqname(char *p,char *q); extern NMTBL *new_static_name(char *name,int delimit); extern int reverse0(int t1); +extern NMTBL *reversen(NMTBL* t1); extern int size(int t); extern void set_attributes(NMTBL *n, int attr);