Mercurial > hg > CbC > old > device
changeset 649:f1d71563a46a
array size fix
author | kono |
---|---|
date | Sat, 18 Nov 2006 15:37:37 +0900 |
parents | 234bc5f79a11 |
children | fe0a971a6666 |
files | mc-code-powerpc.c mc-codegen.c mc-parse.c test/asm-powerpc.c test/ps2.c |
diffstat | 5 files changed, 60 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-powerpc.c Fri Nov 17 22:30:24 2006 +0900 +++ b/mc-code-powerpc.c Sat Nov 18 15:37:37 2006 +0900 @@ -317,10 +317,10 @@ */ #define arg_offset 24 #define arg_offset1 24 -int disp_offset = -12; +int disp_offset = 0; #define func_disp_offset 68 -#define code_disp_offset0 (-12) +#define code_disp_offset0 (0) #define CODE_LVAR(l) ((l)+code_disp_offset0) #define CODE_CALLER_ARG(l) ((l)+arg_offset1) @@ -338,7 +338,7 @@ #endif int lvar_offsetv = round16(-disp+max_func_args*SIZE_OF_INT+func_disp_offset); - int r1_offsetv = round16(lvar_offsetv-reg_save)+12; + int r1_offsetv = round16(lvar_offsetv-reg_save+16); printf(".set L_%d,%d\n",lvar_offset_label,r1_offsetv-lvar_offsetv); if (r1_offsetv-lvar_offsetv > 65000) error(-1);
--- a/mc-codegen.c Fri Nov 17 22:30:24 2006 +0900 +++ b/mc-codegen.c Sat Nov 18 15:37:37 2006 +0900 @@ -3172,6 +3172,11 @@ disp = ((disp+(size_of_int-1))&~(size_of_int-1)); } #endif + if ((align=attr_value(n,ALIGNED))) { + if (car(align)!=CONST) error(-1); + // align have to be 2^n + disp = ((disp+(align-1))&~(align-1)); + } } if (n!=&null_nptr) fields = list4(type,fields,(int)(n->nm),disp); @@ -3327,7 +3332,7 @@ if ((align=attr_value(n,ALIGNED))) { if (car(align)!=CONST) error(-1); nsc = LVAR; - ndsp = new_lvar_align(sz,cadr(align)); + ndsp = new_lvar_align(sz,caddr(align)); } else { nsc = LVAR; ndsp = new_lvar(sz);
--- a/mc-parse.c Fri Nov 17 22:30:24 2006 +0900 +++ b/mc-parse.c Sat Nov 18 15:37:37 2006 +0900 @@ -1630,6 +1630,7 @@ decl_data(int t, NMTBL *n,int offset,int skip) { int t0,t1=0,e,i,mode_save,lc=0; + int offset0; conv->decl_data_(); t0 = type_value(t); @@ -1679,9 +1680,13 @@ conv->decl_data_begin_(); mode = mode_save; t1 = cadr(t); - for(i=0;;i++) { - if (sym!=RC) + i = 0; + for(;;) { + if (sym!=RC) { + offset0 = offset; offset=decl_data(t1,n,offset,0); /* array of some thing */ + if (offset0!=offset) i++; + } if (sym==COMMA) { conv->comma_(); continue; @@ -1689,9 +1694,9 @@ conv->decl_data_end_(); conv->rc_(); if (caddr(t)==0) { /* size not defined */ - caddr(t)=i+1; /* define array size */ - } else if (caddr(t)!=i+1) { /* size match? */ - if (caddr(t) < i+1 ) { /* too many data */ + caddr(t)=i; /* define array size */ + } else if (caddr(t)!=i) { /* size match? */ + if (caddr(t) < i ) { /* too many data */ // this check is sligtly odd (fix me) // error(INERR); } else if (!decl_str_init) @@ -5187,6 +5192,7 @@ switch (mode) { case GDECL: case GSDECL: case GUDECL: case GTDECL: case MDECL: case ADECL: case LSDECL: case LUDECL: case GEDECL: + case ATTRIBUTE: e=gfree; gfree+=n; break;
--- a/test/asm-powerpc.c Fri Nov 17 22:30:24 2006 +0900 +++ b/test/asm-powerpc.c Sat Nov 18 15:37:37 2006 +0900 @@ -10,7 +10,7 @@ unsigned long ptrace; } c0; -// register struct task_struct *current asm ("r2"); +register struct task_struct *current asm ("r2"); typedef struct { volatile int counter; } atomic_t; struct thread_info {
--- a/test/ps2.c Fri Nov 17 22:30:24 2006 +0900 +++ b/test/ps2.c Sat Nov 18 15:37:37 2006 +0900 @@ -6,6 +6,34 @@ void bzero(void *b, unsigned int len); +int align100 ; +int align101 __attribute__((aligned (16))); +int align102 __attribute__((aligned (8))); +char align103; +char align104; +int align105; +int align106 __attribute__((aligned (8))); + +void *aligns[] = { + &align100, + &align101, + &align102, + &align103, + &align104, + &align105, + &align106, +}; + +void *aligns1[] = { + &align100, + &align101, + &align102, + &align103, + &align104, + &align105, + &align106 +}; + typedef float ps2_vu0_fmatrix[4][4] __attribute__((aligned (16))); typedef ps2_vu0_fmatrix FMATRIX; @@ -99,6 +127,7 @@ main(int ac, char *av[]) { FMATRIX m; + int i; int aligned = 10; m[1][1] = 0.5; @@ -107,6 +136,16 @@ align16(2,m,m); align16_1(2,m,m); graphic_ObjNode_draw( &p, m); + + printf("sizeof(aligns)==%d %d\n", + sizeof(aligns),sizeof(aligns1)); + printf("sizeof(aligns)/sizeof(void *)==%d\n", + sizeof(aligns)/sizeof(void *)); + + for(i=0;i<sizeof(aligns)/sizeof(void *);i++) { + printf("align10%d %d\n",i,mod16(aligns[i])); + } + }