• R/O
  • SSH

CbC: Commit

micro-C base Continuation based C


Commit MetaInfo

Revision3fb0511cb4f361e50dfcd72724181cb46b5e9183 (tree)
Zeit2006-11-21 10:48:13
Autorshinji_kono
Commitershinji_kono

Log Message

*** empty log message ***

Ändern Zusammenfassung

Diff

diff -r 4aa276299cbe -r 3fb0511cb4f3 Makefile
--- a/Makefile Wed Nov 01 20:01:01 2006 +0900
+++ b/Makefile Tue Nov 21 10:48:13 2006 +0900
@@ -198,7 +198,7 @@
198198 mc-code-mips.c
199199
200200 clean :
201- -rm -f mc mc-null mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i *.cbc.? */*.cbc.?
201+ -rm -f mc mc-null mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i *.cbc.? */*.cbc.? mc-include.h
202202 -rm -f *.tsv ../test/*.tsv ../test/sample/*.tsv
203203
204204 mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
diff -r 4aa276299cbe -r 3fb0511cb4f3 Makefile.linuxzaurus
--- a/Makefile.linuxzaurus Wed Nov 01 20:01:01 2006 +0900
+++ b/Makefile.linuxzaurus Tue Nov 21 10:48:13 2006 +0900
@@ -5,7 +5,7 @@
55 # LDFLAGS = -pg
66 # for Linux Zaurus
77 CFLAGS = -fsigned-char -pipe -g -I. -I/home/zaurus/develop/include -DUSE_CODE_KEYWORD
8-CFLAGS1 = -g -I. -fsigned-char -DUSE_CODE_KEYWORD
8+CFLAGS1 = -g -pipe -I. -fsigned-char -DUSE_CODE_KEYWORD
99 BASE=0
1010 STAGE=1
1111 MFLAGS=$(MFALGS) BASE=$(BASE) STAGE=$(STAGE)
@@ -190,7 +190,7 @@
190190 mc-code-mips.c
191191
192192 clean :
193- -rm -f mc mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i
193+ -rm -f mc mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i mc-include.h
194194
195195 mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
196196 $(CC) -g -o $@ $(PRINTF) b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
diff -r 4aa276299cbe -r 3fb0511cb4f3 Makefile.mips
--- a/Makefile.mips Wed Nov 01 20:01:01 2006 +0900
+++ b/Makefile.mips Tue Nov 21 10:48:13 2006 +0900
@@ -188,7 +188,7 @@
188188 mc-code-mips.c
189189
190190 clean :
191- -rm -f mc mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i
191+ -rm -f mc mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i mc-include.h
192192
193193 mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
194194 $(CC) -g -o $@ $(PRINTF) b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
diff -r 4aa276299cbe -r 3fb0511cb4f3 Makefile.powerpc
--- a/Makefile.powerpc Wed Nov 01 20:01:01 2006 +0900
+++ b/Makefile.powerpc Tue Nov 21 10:48:13 2006 +0900
@@ -198,7 +198,7 @@
198198 mc-code-mips.c
199199
200200 clean :
201- -rm -f mc mc-null mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i *.cbc.? */*.cbc.?
201+ -rm -f mc mc-null mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i *.cbc.? */*.cbc.? mc-include.h
202202 -rm -f *.tsv ../test/*.tsv ../test/sample/*.tsv
203203
204204 mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
diff -r 4aa276299cbe -r 3fb0511cb4f3 mc-code-mips.c
--- a/mc-code-mips.c Wed Nov 01 20:01:01 2006 +0900
+++ b/mc-code-mips.c Tue Nov 21 10:48:13 2006 +0900
@@ -395,7 +395,7 @@
395395 int disp_offset = 0;
396396 #define disp_offset0 0
397397
398-#define func_disp_offset 8
398+
399399 #define code_disp_offset0 0
400400
401401 #define CODE_LVAR(l) ((l)+code_disp_offset0)
@@ -411,12 +411,10 @@
411411 // int code_f = (fnptr->sc==CODE);
412412
413413 disp &= -SIZE_OF_INT;
414- lvar_offsetv = round16(-disp) +
415- round16((max_func_args<2?2:max_func_args)*SIZE_OF_INT) +
416- 2*SIZE_OF_INT;
414+ lvar_offsetv = round16(-disp+16) +
415+ round16((max_func_args<2?2:max_func_args)*SIZE_OF_INT) ;
417416 r1_offsetv = lvar_offsetv + arg_offset + SIZE_OF_INT*2 +
418417 max_reg_var*SIZE_OF_INT+max_freg_var*SIZE_OF_FLOAT+2*SIZE_OF_INT ;
419- lvar_offsetv += round16(r1_offsetv)-r1_offsetv;
420418 r1_offsetv = round16(r1_offsetv);
421419
422420 #if 1
@@ -449,6 +447,12 @@
449447 printf("## max caller arg var=\t%d\n",CALLER_ARG(0));
450448 printf("##\n");
451449 #endif
450+
451+#if 1
452+ printf("## $L_%d=%d\n",r1_offset_label,r1_offsetv);
453+ printf("## $L_%d=%d\n",lvar_offset_label,r1_offsetv-lvar_offsetv);
454+ printf("##\n");
455+#endif
452456 fprintf(asi,"$L_%d=0x%x\n",mask_label,code_mask());
453457 fprintf(asi,"$L_%d=%d\n",mask_offset_label,code_mask_offset());
454458 fprintf(asi,"$L_%d=0x%x\n",fmask_label,code_fmask());
diff -r 4aa276299cbe -r 3fb0511cb4f3 mc-code-powerpc.c
--- a/mc-code-powerpc.c Wed Nov 01 20:01:01 2006 +0900
+++ b/mc-code-powerpc.c Tue Nov 21 10:48:13 2006 +0900
@@ -317,10 +317,10 @@
317317 */
318318 #define arg_offset 24
319319 #define arg_offset1 24
320-int disp_offset = -12;
320+int disp_offset = 0;
321321
322322 #define func_disp_offset 68
323-#define code_disp_offset0 (-12)
323+#define code_disp_offset0 (0)
324324
325325 #define CODE_LVAR(l) ((l)+code_disp_offset0)
326326 #define CODE_CALLER_ARG(l) ((l)+arg_offset1)
@@ -328,20 +328,25 @@
328328 #define CALLER_ARG(l) ((l)+arg_offset1)
329329 #define CALLEE_ARG(l) ((l)+arg_offset)
330330
331+#define round16(a) ((a+0xf)&~0xf)
332+
331333 void
332334 code_offset_set()
333335 {
334336 #if 0
335337 int l;
336338 #endif
337- int lvar_offsetv = -disp+max_func_args*SIZE_OF_INT+func_disp_offset;
338- int r1_offsetv = lvar_offsetv-reg_save+12;
339+ int lvar_offsetv =
340+ round16(-disp+max_func_args*SIZE_OF_INT+func_disp_offset);
341+ int r1_offsetv = round16(lvar_offsetv-reg_save+16);
342+
339343 printf(".set L_%d,%d\n",lvar_offset_label,r1_offsetv-lvar_offsetv);
340344 if (r1_offsetv-lvar_offsetv > 65000) error(-1);
341345 // too large function arguments?
342346 printf(".set L_%d,%d\n",r1_offset_label,r1_offsetv);
343347 if (max_func_arg_label) {
344- printf(".set L_%d,%d\n",max_func_arg_label,max_func_args*SIZE_OF_INT+24);
348+ printf(".set L_%d,%d\n",max_func_arg_label,
349+ round16(max_func_args*SIZE_OF_INT)+24);
345350 max_func_arg_label = 0;
346351 }
347352
diff -r 4aa276299cbe -r 3fb0511cb4f3 mc-codegen.c
--- a/mc-codegen.c Wed Nov 01 20:01:01 2006 +0900
+++ b/mc-codegen.c Tue Nov 21 10:48:13 2006 +0900
@@ -616,6 +616,10 @@
616616 case ST_ASM: st_asm(e1); break;
617617 case ST_LABEL: st_label(e1); break;
618618 case ST_COMMENT: st_comment(e1); break;
619+ case ST_OP:
620+ e3=caddr(e1);
621+ e1=binop(e2,car(e1),cadr(e3),caddr(e3),cadddr(e3));
622+ return g_expr0(e1);
619623 case IVAR: error(-1); break;
620624 case 0: break; // empty case
621625 default:
@@ -2668,7 +2672,7 @@
26682672 // define case label with default label for switch statement
26692673
26702674 extern void
2671-def_label(int cslabel, int dlabel)
2675+df_label(int cslabel, int dlabel)
26722676 {
26732677 int fl;
26742678
@@ -3118,9 +3122,12 @@
31183122 extern NMTBL *
31193123 def(NMTBL *n,int ctmode)
31203124 {
3121- int sz,nsc,ndsp;
3125+ int sz,nsc,ndsp,align;
31223126 int sbit_f = bit_field_disp;
31233127 int type0 = type_value(type);
3128+ int attr = attribute;
3129+ attribute = 0;
3130+
31243131 bit_field_disp = 0; // default is 0, recover only in bit-field
31253132
31263133 if (n==0) {
@@ -3134,6 +3141,7 @@
31343141 if ((mode==GDECL)) {
31353142 fcheck(n);
31363143 set_ctmode(n,ctmode);
3144+ set_attributes(n,attr);
31373145 return n;
31383146 /* function and code segment are defined using fdecl/code_decl */
31393147 /* in decl() */
@@ -3168,9 +3176,20 @@
31683176 disp = ((disp+(size_of_int-1))&~(size_of_int-1));
31693177 }
31703178 #endif
3179+ if ((align=attr_value_in_list(attr,ALIGNED))) {
3180+int hoge = disp;
3181+ if (car(align)!=CONST) error(-1);
3182+ // align have to be 2^n
3183+ align = caddr(align);
3184+ disp = ((disp+(align-1))&~(align-1));
3185+if (hoge!=disp)
3186+printf("# field %s %d->%d (align %d)\n",n->nm,hoge,disp,align);
3187+
3188+ }
31713189 }
31723190 if (n!=&null_nptr)
31733191 fields = list4(type,fields,(int)(n->nm),disp);
3192+ // don't set attribute to n
31743193 } else if (mode==GUDECL||mode==LUDECL) { // union
31753194 /* disp is pushded and reset in sdecl */
31763195 if (type0>0 && car(type0)==BIT_FIELD) {
@@ -3223,6 +3242,7 @@
32233242 }
32243243 gpc +=sz;
32253244 set_ctmode(n,ctmode);
3245+ set_attributes(n,attr);
32263246 return n;
32273247 case GSDECL: case LSDECL: // struct
32283248 disp += sz;
@@ -3234,9 +3254,11 @@
32343254 case GTDECL: // typedef
32353255 nsc = TYPE;
32363256 gtypedefed=glist2((int)gnptr,gtypedefed);
3257+ set_attributes(n,attr);
32373258 break;
32383259 case LTDECL: // local typedef
32393260 nsc = TYPE;
3261+ set_attributes(n,attr);
32403262 break;
32413263 case LLDECL: // label def (gcc extension)
32423264 nsc = FLABEL;
@@ -3281,6 +3303,8 @@
32813303 #if 1
32823304 } else if(type0>0&&(car(type0)==UNION||car(type0)==STRUCT)) {
32833305 /* alignment in struct in argument */
3306+ /* should be GCD of member alignment */
3307+ /* __attribute(alignment(16)) is ignored in argments */
32843308 n->dsp = args;
32853309 args += ((sz+(size_of_int-1))&~(size_of_int-1));
32863310 #endif
@@ -3295,11 +3319,13 @@
32953319 } else {
32963320 n->ty = type;
32973321 }
3322+ // don't set attribute
32983323 set_ctmode(n,ctmode);
32993324 return n;
33003325 case STAT: /* return (struct hoge)f() case? */
33013326 case LDECL: // local variable
3302- if (stmode==REGISTER && !inmode) {
3327+ set_attributes(n,attr);
3328+ if (stmode==REGISTER && !(inmode==INLINE)) {
33033329 if(scalar(type0)) {
33043330 ndsp = get_register_var(n);
33053331 #if FLOAT_CODE
@@ -3315,13 +3341,19 @@
33153341 } else error(DCERR);
33163342 nsc = car(ndsp);
33173343 ndsp = cadr(ndsp);
3318- } else if (inmode) {
3344+ } else if (inmode==INLINE) {
33193345 nsc = IVAR;
33203346 ndsp = --disp;
33213347 } else {
33223348 /* local variable alignment is done by new_lvar */
3323- nsc = LVAR;
3324- ndsp = new_lvar(sz);
3349+ if ((align=attr_value(n,ALIGNED))) {
3350+ if (car(align)!=CONST) error(-1);
3351+ nsc = LVAR;
3352+ ndsp = new_lvar_align(sz,caddr(align));
3353+ } else {
3354+ nsc = LVAR;
3355+ ndsp = new_lvar(sz);
3356+ }
33253357 }
33263358 n->sc = nsc;
33273359 n->dsp = ndsp;
@@ -3330,6 +3362,7 @@
33303362 default:
33313363 error(DCERR);
33323364 }
3365+ // should be an error?
33333366 n->sc = nsc;
33343367 n->dsp = ndsp;
33353368 set_ctmode(n,ctmode);
@@ -3338,6 +3371,19 @@
33383371 return n;
33393372 }
33403373
3374+extern char *
3375+nm(NMTBL *n) {
3376+ int e;
3377+ NMTBL *str;
3378+ if (n->attr) {
3379+ if ((e=attr_value(n,ASM))) {
3380+ if (car(e)!=STRING) error(-1);
3381+ str = (NMTBL*)caddr(e);
3382+ return str->nm;
3383+ }
3384+ }
3385+ return n->nm;
3386+}
33413387
33423388 extern void
33433389 emit_init_vars(void)
@@ -4560,6 +4606,7 @@
45604606 else if (type==SHORT) t=INT;
45614607 else if (type==USHORT) t=UNSIGNED;
45624608 }
4609+ // is this correct?
45634610 if ((t1=type_value(type))>0 &&
45644611 car(type_value(type))==ARRAY && car(e)==GVAR) {
45654612 if (!chk)
@@ -4769,14 +4816,14 @@
47694816 static int lvar_list,lvar_free_list;
47704817
47714818 extern int
4772-new_lvar0(int sz)
4819+new_lvar0(int sz, int align)
47734820 {
47744821 disp-=sz;
4775-#if 1
4776- if (sz>=4 && (disp & (4-1))) { // alignment
4822+ if (align) {
4823+ disp &= ~(align-1);
4824+ } else if (sz>=4 && (disp & (4-1))) { // alignment 4
47774825 disp &= ~(4-1);
47784826 }
4779-#endif
47804827 return disp;
47814828 }
47824829
@@ -4784,14 +4831,15 @@
47844831 Allocate new local variable in flat scope
47854832 */
47864833
4834+
47874835 extern int
4788-new_lvar(int size)
4836+new_lvar_align(int size,int align)
47894837 {
47904838 int lvar,plvar;
47914839
47924840 /* Can we reuse previously freed local variable? */
47934841 for (plvar = 0,lvar = lvar_free_list;lvar;lvar = cadr(lvar)) {
4794- if (caddr(lvar)==size) {
4842+ if (caddr(lvar)==size && (~align|| car(lvar)%align==0)) {
47954843 if (plvar) cadr(plvar) = cadr(lvar);
47964844 else lvar_free_list = cadr(lvar);
47974845 break;
@@ -4799,7 +4847,7 @@
47994847 plvar = lvar;
48004848 }
48014849 if (!lvar) {
4802- lvar_list = glist3((lvar=new_lvar0(size)),lvar_list,size);
4850+ lvar_list = glist3((lvar=new_lvar0(size,align)),lvar_list,size);
48034851 } else {
48044852 cadr(lvar) = lvar_list; lvar_list = lvar;
48054853 lvar = car(lvar_list);
@@ -4807,6 +4855,11 @@
48074855 return lvar;
48084856 }
48094857
4858+extern int
4859+new_lvar(int size) {
4860+ return new_lvar_align(size,0);
4861+}
4862+
48104863 /*
48114864 Free the allocated local variable. It may be reused again.
48124865 */
diff -r 4aa276299cbe -r 3fb0511cb4f3 mc-codegen.h
--- a/mc-codegen.h Wed Nov 01 20:01:01 2006 +0900
+++ b/mc-codegen.h Tue Nov 21 10:48:13 2006 +0900
@@ -59,7 +59,7 @@
5959 extern int indop(int e);
6060 extern int integral(int t);
6161 extern int new_lvar(int size);
62-extern int new_lvar0(int sz);
62+extern int new_lvar0(int sz, int align);
6363 extern int rvalue(int e);
6464 extern int rvalue_t(int e,int t);
6565 extern int search_struct_type(int type,char *name,int *dsp);
@@ -74,7 +74,7 @@
7474 extern void codegen_init(); /* called only once */
7575 extern void codegen_reinit(); /* called for each file */
7676 extern void data_closing(NMTBL *n);
77-extern void def_label(int cslabel, int dlabel);
77+extern void df_label(int cslabel, int dlabel);
7878 extern void emit_init_vars(void);
7979 extern void fcheck(NMTBL *n);
8080 extern void fdecl_struct(int fntype);
@@ -134,6 +134,9 @@
134134
135135 extern int ilog(int i);
136136
137+extern char * nm(NMTBL *n) ;
138+extern int new_lvar_align(int size,int align);
139+
137140 /* used by mc-tree */
138141
139142 extern NMTBL str_ret;
@@ -142,4 +145,6 @@
142145 extern int rop_dual(int op);
143146 extern int copy_expr(int e);
144147
148+
149+
145150 /* end */
diff -r 4aa276299cbe -r 3fb0511cb4f3 mc-inline.c
--- a/mc-inline.c Wed Nov 01 20:01:01 2006 +0900
+++ b/mc-inline.c Tue Nov 21 10:48:13 2006 +0900
@@ -226,12 +226,12 @@
226226 if (control) gen_jmp(blabel);
227227 genswitch(cslist,cslabel);
228228 } else if (!cslist) {
229- if(dlabel) def_label(cslabel,dlabel);
229+ if(dlabel) df_label(cslabel,dlabel);
230230 else fwddef(cslabel);
231231 }
232232 #else
233233 if (!(cst && cslist)) {
234- if(dlabel) def_label(cslabel,dlabel);
234+ if(dlabel) df_label(cslabel,dlabel);
235235 else fwddef(cslabel);
236236 }
237237 #endif
diff -r 4aa276299cbe -r 3fb0511cb4f3 mc-macro.c
--- a/mc-macro.c Wed Nov 01 20:01:01 2006 +0900
+++ b/mc-macro.c Tue Nov 21 10:48:13 2006 +0900
@@ -337,7 +337,7 @@
337337 getline(void)
338338 {
339339 int i;
340- int c;
340+ int c = 0;
341341 char num[10]; // for 32bit
342342 char *p;
343343
@@ -426,6 +426,7 @@
426426 chptr = p;
427427 if (macro_processing()) return;
428428 }
429+ if (c==EOF) break;
429430 } while(!in_quote && (macro_if_skip || linebuf[0] == '#'));
430431 }
431432
diff -r 4aa276299cbe -r 3fb0511cb4f3 mc-parse.c
--- a/mc-parse.c Wed Nov 01 20:01:01 2006 +0900
+++ b/mc-parse.c Tue Nov 21 10:48:13 2006 +0900
@@ -1,4 +1,4 @@
1-/* Micro-C Parser Part */
1+
22
33
44 /************************************************************************
@@ -174,7 +174,7 @@
174174 static void getstring(void);
175175 static void init(void);
176176 static void newfile(void);
177-static void reserve(char *s, int d);
177+static void reserve(char *s, int d, int sc);
178178 static void reverse(int t1);
179179 static void set_converter(char *s);
180180 static int escape(void);
@@ -193,6 +193,7 @@
193193 static void attributes();
194194 static void macro_convert();
195195 extern void sym_print(int,FILE *);
196+static void copy_attributes(NMTBL *n) ;
196197
197198 // current value of constant symbol
198199
@@ -564,70 +565,73 @@
564565
565566 heap_init();
566567
567- reserve("int",INT);
568- reserve("void",VOID);
569- reserve("char",CHAR);
570- reserve("const",KONST);
571- reserve("__const__",KONST);
572- reserve("struct",STRUCT);
573- reserve("union",UNION);
574- reserve("unsigned",UNSIGNED);
575- reserve("signed",SIGNED);
576- reserve("static",STATIC);
577- reserve("goto",GOTO);
578- reserve("return",RETURN);
579- reserve("break",BREAK);
580- reserve("continue",CONTINUE);
581- reserve("if",IF);
582- reserve("else",ELSE);
583- reserve("for",FOR);
584- reserve("do",DO);
585- reserve("while",WHILE);
586- reserve("switch",SWITCH);
587- reserve("case",CASE);
588- reserve("default",DEFAULT);
589- reserve("typedef",TYPEDEF);
590- reserve("sizeof",SIZEOF);
591- reserve("long",LONG);
592- reserve("short",SHORT);
593- reserve("extern",EXTRN);
594- reserve("defined",DEFINED);
595- reserve("register",REGISTER);
568+ reserve("int",INT,RESERVE);
569+ reserve("void",VOID,RESERVE);
570+ reserve("char",CHAR,RESERVE);
571+ reserve("const",KONST,RESERVE);
572+ reserve("__const__",KONST,RESERVE);
573+ reserve("struct",STRUCT,RESERVE);
574+ reserve("union",UNION,RESERVE);
575+ reserve("unsigned",UNSIGNED,RESERVE);
576+ reserve("signed",SIGNED,RESERVE);
577+ reserve("static",STATIC,RESERVE);
578+ reserve("goto",GOTO,RESERVE);
579+ reserve("return",RETURN,RESERVE);
580+ reserve("break",BREAK,RESERVE);
581+ reserve("continue",CONTINUE,RESERVE);
582+ reserve("if",IF,RESERVE);
583+ reserve("else",ELSE,RESERVE);
584+ reserve("for",FOR,RESERVE);
585+ reserve("do",DO,RESERVE);
586+ reserve("while",WHILE,RESERVE);
587+ reserve("switch",SWITCH,RESERVE);
588+ reserve("case",CASE,RESERVE);
589+ reserve("default",DEFAULT,RESERVE);
590+ reserve("typedef",TYPEDEF,RESERVE);
591+ reserve("sizeof",SIZEOF,RESERVE);
592+ reserve("long",LONG,RESERVE);
593+ reserve("short",SHORT,RESERVE);
594+ reserve("extern",EXTRN,RESERVE);
595+ reserve("defined",DEFINED,RESERVE);
596+ reserve("register",REGISTER,RESERVE);
596597 #ifdef USE_CODE_KEYWORD
597- reserve("code",CODE);
598+ reserve("code",CODE,RESERVE);
598599 #endif
599- reserve("__code",CODE);
600- reserve("environment",ENVIRONMENT);
601- reserve("float",FLOAT);
602- reserve("double",DOUBLE);
603- reserve("inline",INLINE);
604- reserve("enum",ENUM);
605- reserve("volatile",VOLATILE);
606- reserve("__volatile__",VOLATILE);
607- reserve("restrict",RESTRICT);
608- reserve("typeof",TYPEOF);
609- reserve("__typeof__",TYPEOF);
610- reserve("__builtin_alloca",ALLOCA);
611- reserve("__builtin_constant_p",BUILTINP);
612- reserve("__builtin_expect",BUILTIN_EXPECT);
613- reserve("__builtin_fabs",BUILTIN_FABS);
614- reserve("__builtin_fabsf",BUILTIN_FABSF);
615- reserve("__builtin_fabsl",BUILTIN_FABSL);
616- reserve("__builtin_inf",BUILTIN_INF);
617- reserve("__builtin_inff",BUILTIN_INFF);
618- reserve("__builtin_infl",BUILTIN_INFL);
619- reserve("__attribute__",ATTRIBUTE);
620- reserve("__attribute",ATTRIBUTE);
621- reserve("__label__",LABEL);
622- reserve("__FILE__",C_FILE);
623- reserve("__FUNCTION__",C_FUNCTION);
624- reserve("__func__",C_FUNCTION);
625- reserve("__LINE__",C_LINE);
600+ reserve("__code",CODE,RESERVE);
601+ reserve("environment",ENVIRONMENT,RESERVE);
602+ reserve("float",FLOAT,RESERVE);
603+ reserve("double",DOUBLE,RESERVE);
604+ reserve("inline",INLINE,RESERVE);
605+ reserve("enum",ENUM,RESERVE);
606+ reserve("volatile",VOLATILE,RESERVE);
607+ reserve("__volatile__",VOLATILE,RESERVE);
608+ reserve("restrict",RESTRICT,RESERVE);
609+ reserve("typeof",TYPEOF,RESERVE);
610+ reserve("__typeof__",TYPEOF,RESERVE);
611+ reserve("__builtin_alloca",ALLOCA,RESERVE);
612+ reserve("__builtin_constant_p",BUILTINP,RESERVE);
613+ reserve("__builtin_expect",BUILTIN_EXPECT,RESERVE);
614+ reserve("__builtin_fabs",BUILTIN_FABS,RESERVE);
615+ reserve("__builtin_fabsf",BUILTIN_FABSF,RESERVE);
616+ reserve("__builtin_fabsl",BUILTIN_FABSL,RESERVE);
617+ reserve("__builtin_inf",BUILTIN_INF,RESERVE);
618+ reserve("__builtin_inff",BUILTIN_INFF,RESERVE);
619+ reserve("__builtin_infl",BUILTIN_INFL,RESERVE);
620+ reserve("__attribute__",ATTRIBUTE,RESERVE);
621+ reserve("__attribute",ATTRIBUTE,RESERVE);
622+ reserve("__label__",LABEL,RESERVE);
623+ reserve("__FILE__",C_FILE,RESERVE);
624+ reserve("__FUNCTION__",C_FUNCTION,RESERVE);
625+ reserve("__func__",C_FUNCTION,RESERVE);
626+ reserve("__LINE__",C_LINE,RESERVE);
626627 #if ASM_CODE
627- reserve("asm",ASM);
628- reserve("__asm",ASM); // ?
629- reserve("__asm__",ASM);
628+ reserve("asm",ASM,RESERVE);
629+ reserve("__asm",ASM,RESERVE); // ?
630+ reserve("__asm__",ASM,RESERVE);
630631 #endif
632+ // attributes ( in different name space )
633+ reserve("aligned",ALIGNED,ATTRIBUTE);
634+ reserve("noreturn",NORETURN,ATTRIBUTE);
631635
632636 codegen_reinit();
633637 macro_define("__restrict\n");
@@ -778,14 +782,13 @@
778782 */
779783
780784 static void
781-reserve(char *s, int d)
785+reserve(char *s, int d, int sc)
782786 {
783787 NMTBL *nptr;
784788
785789
786- (nptr = name_space_search(get_name(s,0,DEF),d?0:MACRO))->sc = RESERVE;
790+ (nptr = name_space_search(get_name(s,0,DEF),d?0:MACRO))->sc = sc;
787791 if (d==0) {
788- nptr->sc = MACRO;
789792 nptr->dsp = (int)""; nptr->ty=0;
790793 } else {
791794 nptr->dsp = d;
@@ -896,7 +899,9 @@
896899 error(DCERR); return;
897900 }
898901 }
899- while (sym==ATTRIBUTE||sym==ASM) { getsym(0); attributes(); }
902+ while (sym==ATTRIBUTE||sym==ASM) {
903+ int sym0 = sym; getsym(0); attributes(sym0);
904+ }
900905 if(sym==LC || ( sym!=SM && sym!=COMMA && sym!=ASS)) {
901906 /* function body */
902907 if (mode!=GDECL) {
@@ -953,27 +958,43 @@
953958 }
954959
955960 static void
956-attributes()
961+attributes(int attr)
957962 {
958- int sattribute;
963+ int smode = mode; mode=ATTRIBUTE;
959964 checksym(LPAR);
965+ if (attr==ASM) {
966+ // int r __asm("r0")
967+ getsym(ATTRIBUTE);
968+ if (sym==STRING) {
969+ attribute = list3(ASM,attribute,(int)nptr);
970+ }
971+ mode = smode;
972+ checksym(RPAR);
973+ return;
974+ }
960975 while(sym!=RPAR) {
961976 if (sym==LPAR) {
962- sattribute = attribute;
963- attribute = 0;
964- attributes();
965- attribute = list3(ATTRIBUTE,sattribute,attribute);
977+ attributes(0);
966978 } else if (sym==IDENT) {
967979 attribute = list3(IDENT,attribute,(int)nptr);
968- getsym(0);
980+ getsym(ATTRIBUTE);
969981 } else if (sym==STRING) {
970- attribute = list3(STRING,attribute,(int)nptr->nm);
971- getsym(0);
982+ attribute = list3(STRING,attribute,(int)nptr);
983+ getsym(ATTRIBUTE);
972984 } else {
973- attribute = list3(sym,attribute,symval);
974- getsym(0);
985+ attribute = list3(sym,attribute,0);
986+ getsym(ATTRIBUTE);
987+ if (sym==LPAR) {
988+ getsym(ATTRIBUTE);
989+ while(sym!=RPAR) {
990+ caddr(attribute) = list3(sym,caddr(attribute),symval);
991+ getsym(ATTRIBUTE);
992+ }
993+ getsym(ATTRIBUTE);
994+ }
975995 }
976996 }
997+ mode = smode;
977998 getsym(0);
978999 }
9791000
@@ -993,7 +1014,7 @@
9931014 break;
9941015 case ATTRIBUTE:
9951016 getsym(0);
996- attributes();
1017+ attributes(ATTRIBUTE);
9971018 continue;
9981019 case INLINE:
9991020 inmode = INLINE;
@@ -1124,9 +1145,12 @@
11241145 if (nptr->sc==TYPE) {
11251146 t=nptr->ty;
11261147 typedefed=glist2((int)nptr,typedefed);
1148+ // have to be type attribute
1149+ copy_attributes(nptr);
11271150 getsym(0);
11281151 break;
11291152 } else if(nptr->sc==EMPTY && gnptr->sc==TYPE) {
1153+ // ???
11301154 getsym(0);
11311155 break;
11321156 }
@@ -1150,6 +1174,7 @@
11501174 {
11511175 NMTBL *n;
11521176 if(sym==MUL) {
1177+ attribute = 0; // do not inherite type attributes
11531178 getsym(0);
11541179 qualifiers();
11551180 n=decl0();
@@ -1299,10 +1324,12 @@
12991324 } else {
13001325 if(sym==DOTS) {
13011326 argtypes=list2(DOTS,argtypes);
1327+ attribute = 0;
13021328 getsym(0);
13031329 break;
13041330 }
13051331 if((t=typespec())==0) {
1332+ attribute = 0;
13061333 error(DCERR);
13071334 break;
13081335 }
@@ -1313,10 +1340,12 @@
13131340 args = sargs;
13141341 reverse(t); // this sets type also
13151342 if (arg != &null_nptr) {
1316- if (smode==GDECL)
1343+ if (smode==GDECL) {
13171344 def(arg,ctmode);
1345+ }
13181346 }
13191347 }
1348+ attribute = 0;
13201349 argtypes=list2(type,argtypes);
13211350 if(sym==RPAR) break;
13221351 }
@@ -1601,6 +1630,7 @@
16011630 decl_data(int t, NMTBL *n,int offset,int skip)
16021631 {
16031632 int t0,t1=0,e,i,mode_save,lc=0;
1633+ int offset0;
16041634
16051635 conv->decl_data_();
16061636 t0 = type_value(t);
@@ -1650,9 +1680,13 @@
16501680 conv->decl_data_begin_();
16511681 mode = mode_save;
16521682 t1 = cadr(t);
1653- for(i=0;;i++) {
1654- if (sym!=RC)
1683+ i = 0;
1684+ for(;;) {
1685+ if (sym!=RC) {
1686+ offset0 = offset;
16551687 offset=decl_data(t1,n,offset,0); /* array of some thing */
1688+ if (offset0!=offset) i++;
1689+ }
16561690 if (sym==COMMA) {
16571691 conv->comma_();
16581692 continue;
@@ -1660,9 +1694,9 @@
16601694 conv->decl_data_end_();
16611695 conv->rc_();
16621696 if (caddr(t)==0) { /* size not defined */
1663- caddr(t)=i+1; /* define array size */
1664- } else if (caddr(t)!=i+1) { /* size match? */
1665- if (caddr(t) < i+1 ) { /* too many data */
1697+ caddr(t)=i; /* define array size */
1698+ } else if (caddr(t)!=i) { /* size match? */
1699+ if (caddr(t) < i ) { /* too many data */
16661700 // this check is sligtly odd (fix me)
16671701 // error(INERR);
16681702 } else if (!decl_str_init)
@@ -2618,7 +2652,7 @@
26182652 genswitch(cslist,cslabel);
26192653 } else if (!cslist) {
26202654 if(dlabel) {
2621- def_label(cslabel,dlabel);
2655+ df_label(cslabel,dlabel);
26222656 cslist=1;
26232657 } else {
26242658 // no matched value, but some statement may haave control
@@ -2629,7 +2663,7 @@
26292663 }
26302664 #else
26312665 if (!(cst && cslit)) {
2632- if(dlabel) def_label(cslabel,dlabel);
2666+ if(dlabel) df_label(cslabel,dlabel);
26332667 else fwddef(cslabel);
26342668 }
26352669 #endif
@@ -3603,7 +3637,7 @@
36033637 nptr1->sc=EMPTY;
36043638 nptr1=l_top_search(nptr->nm,0);
36053639 nptr1->sc = FLABEL;
3606- if (!inmode)
3640+ if (inmode!=INLINE)
36073641 nptr1->dsp = fwdlabel();
36083642 else
36093643 nptr1->dsp = --disp;
@@ -3611,7 +3645,7 @@
36113645 type = list2(POINTER,VOID);
36123646 // can be global?!
36133647 return list2(LABEL,
3614- list3(inmode?IVAR:LVAR,nptr1->dsp,(int)nptr1));
3648+ list3(inmode==INLINE?IVAR:LVAR,nptr1->dsp,(int)nptr1));
36153649 }
36163650 e=expr14();
36173651
@@ -3887,6 +3921,7 @@
38873921 parse = sparse;
38883922 lastexp = 0;
38893923 } else {
3924+#if 1
38903925 int l,b,l2,cntl=control;
38913926 // if COMMA expr is not gexpred by !control,
38923927 // l2 is not defined and generates undefined error.
@@ -3905,6 +3940,17 @@
39053940 lastexp = 0;
39063941 if (l) fwddef(l);
39073942 control=cntl;
3943+#else
3944+ // we already have parse tree mode, why don't we?
3945+ int sparse = parse; parse=0;
3946+ inmode = INLINE+1;
3947+ // this does not work well... we need some work later
3948+ docomp(1);
3949+ e1 = list3(COMMA,reverse0(parse),lastexp);
3950+ parse = sparse;
3951+ lastexp = 0;
3952+ inmode = 0;
3953+#endif
39083954 }
39093955 } else {
39103956 e1=expr0();
@@ -4044,6 +4090,7 @@
40444090 }
40454091 } else if(car(argtypes)==DOTS) at=DOTS;
40464092 else { at=car(argtypes); argtypes=cadr(argtypes); }
4093+ if (at>0&&car(at)==ARRAY) at = list2(POINTER,cadr(at));
40474094 e = correct_type(e,at);
40484095 arglist=list3(e,arglist,type);
40494096 if(sym!=COMMA) break;
@@ -4135,6 +4182,7 @@
41354182 ndecl0(void)
41364183 {
41374184 if(sym==MUL) {
4185+ attribute = 0; // do not inherite type attributes
41384186 getsym(0);
41394187 return type=list2(POINTER,ndecl0());
41404188 }
@@ -4605,7 +4653,10 @@
46054653 }
46064654 /* global variable name table */
46074655 nptr0 = name_space_search(nlist,sc);
4608- if (nptr0->sc == RESERVE) return sym = nptr0->dsp;
4656+ if (nptr0->sc == RESERVE)
4657+ return sym = nptr0->dsp;
4658+ if (mode==ATTRIBUTE && nptr0->sc == ATTRIBUTE)
4659+ return sym = nptr0->dsp;
46094660 sym = IDENT;
46104661 gnptr=nptr=nptr0;
46114662
@@ -5142,6 +5193,7 @@
51425193 switch (mode) {
51435194 case GDECL: case GSDECL: case GUDECL: case GTDECL:
51445195 case MDECL: case ADECL: case LSDECL: case LUDECL: case GEDECL:
5196+ case ATTRIBUTE:
51455197 e=gfree;
51465198 gfree+=n;
51475199 break;
@@ -5406,6 +5458,38 @@
54065458 return;
54075459 }
54085460
5461+/*
5462+ transfer attribtes() value to nptr;
5463+ */
5464+
5465+extern void
5466+set_attributes(NMTBL *n,int attr) {
5467+ int e;
5468+ for(e = attr; e ; e = cadr(e)) {
5469+ set_attr(n,car(e),caddr(e));
5470+ }
5471+}
5472+
5473+extern int
5474+attr_value_in_list(int list,int attr)
5475+{
5476+ int e;
5477+ e = list;
5478+ for(;e;e=cadr(e)) {
5479+ if (car(e)==attr) return caddr(e);
5480+ }
5481+ return 0;
5482+}
5483+
5484+static void
5485+copy_attributes(NMTBL *n) {
5486+ int attr;
5487+ for(attr=n->attr;attr;attr=cadr(attr)) {
5488+ attribute = list3(car(attr),attribute,caddr(attr));
5489+ }
5490+}
5491+
5492+
54095493 extern void
54105494 display_ntable(NMTBL *n, char *s)
54115495 {
diff -r 4aa276299cbe -r 3fb0511cb4f3 mc-parse.h
--- a/mc-parse.h Wed Nov 01 20:01:01 2006 +0900
+++ b/mc-parse.h Tue Nov 21 10:48:13 2006 +0900
@@ -55,6 +55,7 @@
5555 extern int inline_funcs; /* inline function list */
5656
5757 extern int parse; /* parse tree */
58+extern int attribute; /* attribute list (in __attribute()) */
5859
5960 /*
6061 STRING nptr
@@ -157,6 +158,10 @@
157158 extern NMTBL *new_static_name(char *name,int delimit);
158159 extern int reverse0(int t1);
159160 extern int size(int t);
161+extern void set_attributes(NMTBL *n, int attr);
162+
163+extern int attr_value_in_list(int list,int attr);
164+
160165
161166 /* used in mc-macro.c */
162167
diff -r 4aa276299cbe -r 3fb0511cb4f3 mc-switch.c
--- a/mc-switch.c Wed Nov 01 20:01:01 2006 +0900
+++ b/mc-switch.c Tue Nov 21 10:48:13 2006 +0900
@@ -40,6 +40,24 @@
4040 merge: list4(continuous number of chunk,next,delta,case_count);
4141 index list
4242 index: list4(label,next,max,min);
43+
44+
45+
46+ A list of value label pair is generated in do_case, in sorted list.
47+
48+ The list is separated in continous cslists which has a same
49+ delta in make_chunk(int cslist).
50+
51+ merge_chunk(int chunks) tries to findout possible merge of continous
52+ cslist. If merge_chunk_p() accepts reasonably densed switch talbe,
53+ the cslists are merged.
54+
55+ switch_index() makes hierachical indexed branches, using switch_leaf().
56+ switch_leaf(). switch_leaf() generates table jump if it is suitable.
57+ Otherwise it generates multi-stage cascading jump. siwtch_make_index()
58+ generates multi-stage index in a recursive way.
59+
60+
4361 */
4462
4563 #define chunk_max(chunks) caddr(cadddr(chunks))
@@ -183,6 +201,10 @@
183201 return merge;
184202 }
185203
204+/*
205+ Generates series of compare immideate. It is suitable for
206+ small amount of jump and random value.
207+ */
186208 static int
187209 cascade_compare(int count,int cslist)
188210 {
@@ -205,6 +227,10 @@
205227 return cslist;
206228 }
207229
230+/*
231+ Make table jump code, suitable for fixed delta and large size
232+ table.
233+ */
208234 static int
209235 table_jump(int count,int delta,int chunks)
210236 {
@@ -296,6 +322,7 @@
296322 fwddef(cslabel);
297323 switch_make_index_leaf(-1,index0,level);
298324 } else {
325+ // too large index, make hihger index
299326 while (index0) {
300327 check_djmp();
301328 l = backdef();
@@ -310,6 +337,7 @@
310337 count-=CASE_INDEX_COUNT;
311338 icount++;
312339 }
340+ // process higher indexes in a recursive way
313341 switch_make_index(reverse0(index),icount,cslabel,gmax,level+1);
314342 }
315343 }
@@ -356,6 +384,8 @@
356384 chnkcnt++;
357385 count += cadddr(m);
358386 if (count > CASE_INDEX_COUNT || (index && !cadr(m))) {
387+ // too large for single stage cascading or
388+ // we already have indexies and this is the last one.
359389 icount++;
360390 min = car(car(chunks));
361391 check_djmp();
@@ -367,6 +397,7 @@
367397 }
368398 }
369399 if (index) {
400+ // yes we have indexes
370401 index = reverse0(index);
371402 // check lower bound
372403 // switch_index_jmp(index,dlabel?dlabel:blabel);
diff -r 4aa276299cbe -r 3fb0511cb4f3 mc.h
--- a/mc.h Wed Nov 01 20:01:01 2006 +0900
+++ b/mc.h Tue Nov 21 10:48:13 2006 +0900
@@ -110,6 +110,9 @@
110110 #define C_FUNCTION (-63)
111111 #define C_LINE (-64)
112112
113+#define ALIGNED (-65)
114+#define NORETURN (-66)
115+
113116 /* reserved word end */
114117
115118 #define EMPTY (-99)
@@ -566,7 +569,7 @@
566569
567570 extern void print_expr(int e, FILE *vout);
568571
569-#if 1
572+#if 0
570573 extern int heapsize;
571574 #define CHECK_HEAP(b) ({int _k=(int)(b);if(_k>heapsize||_k<0)error(-1);_k;})
572575 #else
diff -r 4aa276299cbe -r 3fb0511cb4f3 test/asm-powerpc.c
--- a/test/asm-powerpc.c Wed Nov 01 20:01:01 2006 +0900
+++ b/test/asm-powerpc.c Tue Nov 21 10:48:13 2006 +0900
@@ -10,7 +10,7 @@
1010 unsigned long ptrace;
1111 } c0;
1212
13-// register struct task_struct *current asm ("r2");
13+register struct task_struct *current asm ("r2");
1414 typedef struct { volatile int counter; } atomic_t;
1515
1616 struct thread_info {
diff -r 4aa276299cbe -r 3fb0511cb4f3 test/code-gen.c
--- a/test/code-gen.c Wed Nov 01 20:01:01 2006 +0900
+++ b/test/code-gen.c Tue Nov 21 10:48:13 2006 +0900
@@ -1,5 +1,4 @@
11 /* Micro-C Code Generator Checker */
2-/* $Id$ */
32
43 #define FLOAT_CODE 1
54 #define LONGLONG_CODE 1
diff -r 4aa276299cbe -r 3fb0511cb4f3 test/ps2.c
--- a/test/ps2.c Wed Nov 01 20:01:01 2006 +0900
+++ b/test/ps2.c Tue Nov 21 10:48:13 2006 +0900
@@ -3,11 +3,86 @@
33 #endif
44
55 int printf(const char *,...);
6+void bzero(void *b, unsigned int len);
7+
8+
9+int align100 ;
10+int align101 __attribute__((aligned (16)));
11+int align102 __attribute__((aligned (8)));
12+char align103;
13+char align104;
14+int align105;
15+int align106 __attribute__((aligned (8)));
16+
17+void *aligns[] = {
18+ &align100,
19+ &align101,
20+ &align102,
21+ &align103,
22+ &align104,
23+ &align105,
24+ &align106,
25+};
26+
27+void *aligns1[] = {
28+ &align100,
29+ &align101,
30+ &align102,
31+ &align103,
32+ &align104,
33+ &align105,
34+ &align106
35+};
36+
637
738 typedef float ps2_vu0_fmatrix[4][4] __attribute__((aligned (16)));
839 typedef ps2_vu0_fmatrix FMATRIX;
940
41+typedef float ps2_vu0_fmatrix1[4][4];
42+typedef ps2_vu0_fmatrix1 FMATRIX1;
1043
44+typedef struct objNode {
45+ void* object;
46+ void (*mtd)(struct objNode*);
47+ void (*draw)(struct objNode*, FMATRIX, FMATRIX);
48+ struct objNode *next;
49+ struct objNode *parent;
50+ struct objNode *child;
51+} ObjNode, *ObjNodePtr;
52+
53+INLINE void draw(ObjNode *this, FMATRIX m, FMATRIX n)
54+{
55+ printf("work %g ",m[1][1]);
56+ printf("base %g\n",n[1][1]);
57+ m[1][1] += -0.7;
58+ n[1][1] += 0.7;
59+}
60+
61+ObjNode c = {
62+ 0, 0, draw, 0, 0, 0
63+};
64+
65+ObjNode p = {
66+ 0, 0, draw, &c, 0, &c
67+};
68+
69+
70+INLINE void
71+graphic_ObjNode_draw( ObjNode *this, FMATRIX base )
72+{
73+ FMATRIX work;
74+ bzero(&work,sizeof(work)); work[1][1] = 0.33;
75+
76+ if(!this) return;
77+ if(this->mtd) this->mtd( this );
78+ if(this->draw) this->draw( this, work, base );
79+ printf("offset draw %d\n",((char*)(&this->draw) - ((char*)&this->object)));
80+ printf("offset next %d\n",((char*)(&this->next) - ((char*)&this->object)));
81+
82+ if(this->child) graphic_ObjNode_draw( this->child, work );
83+ if(this->next) graphic_ObjNode_draw( this->next, base );
84+ return;
85+}
1186
1287
1388 INLINE void ps2_vu0_unit_matrix(ps2_vu0_fmatrix m)
@@ -16,12 +91,64 @@
1691 m[1][1] = -0.5;
1792 }
1893
94+
95+#define mod16(a) (((int)(&a))%16)
96+
97+int
98+align16(int i, FMATRIX a, FMATRIX b) {
99+ FMATRIX m;
100+ FMATRIX n;
101+ int k = i;
102+ FMATRIX o;
103+ if (i==0) return i;
104+#ifdef OFFSET
105+ printf("offset %d\n",((char*)a) - ((char*)(&m)));
106+#endif
107+ printf("%d %d %d\n",mod16(m),mod16(n),mod16(o));
108+ align16(i-1,m,n);
109+ return k;
110+}
111+
112+int
113+align16_1(int i, FMATRIX1 a, FMATRIX1 b) {
114+ FMATRIX1 m;
115+ FMATRIX1 n;
116+ int k = i;
117+ FMATRIX1 o;
118+ if (i==0) return i;
119+#ifdef OFFSET
120+ printf("offset %d\n",((char*)a) - ((char*)(&m)));
121+#endif
122+ printf("%d %d %d\n",mod16(m),mod16(n),mod16(o));
123+ align16_1(i-1,m,n);
124+ return k;
125+}
126+
127+
19128 int
20129 main(int ac, char *av[])
21130 {
22131 FMATRIX m;
132+ int i;
133+ int aligned = 10;
23134
24135 m[1][1] = 0.5;
25136 ps2_vu0_unit_matrix(m);
26- printf("%g\n",m[1][1]);
137+ printf("%g %d\n",m[1][1],aligned);
138+ align16(2,m,m);
139+ align16_1(2,m,m);
140+ graphic_ObjNode_draw( &p, m);
141+
142+ printf("sizeof(aligns)==%d %d\n",
143+ sizeof(aligns),sizeof(aligns1));
144+ printf("sizeof(aligns)/sizeof(void *)==%d\n",
145+ sizeof(aligns)/sizeof(void *));
146+
147+ for(i=0;i<sizeof(aligns)/sizeof(void *);i++) {
148+ printf("align10%d %d\n",i,mod16(aligns[i]));
149+ }
150+
27151 }
152+
153+
154+/* end */
Show on old repository browser