Mercurial > hg > CbC > old > device
changeset 312:a93e619cf772
typeof, MIPS stdarg
author | kono |
---|---|
date | Sat, 12 Jun 2004 15:58:56 +0900 |
parents | 38c9976863b7 |
children | f73b93de216a |
files | Changes mc-code-mips.c mc-parse.c mc-switch.c mc.h test/macro.c test/tmp8.c |
diffstat | 7 files changed, 47 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Sat Jun 12 11:51:45 2004 +0900 +++ b/Changes Sat Jun 12 15:58:56 2004 +0900 @@ -4884,3 +4884,18 @@ そうか、inline のために constant switch とかをやると、全体的 に statement をskip するってのを書かないといけないわけね。chk を使えば良いんだろうけど。それほど、難しくはないけど.... + +alloca も r1 と $sp を動かしているだけじゃん。 + +残りは、 + alloca + inline + asm +と言うことになりましたが... MIPS のstdargも動いてないけど... +問題は include file の方だものな。 + +typeof かぁ。 + typeof (hoge) i; + sizeof(typeof(hoge)); + ((typeof (hoge)) fuga) +みたいな感じ。
--- a/mc-code-mips.c Sat Jun 12 11:51:45 2004 +0900 +++ b/mc-code-mips.c Sat Jun 12 15:58:56 2004 +0900 @@ -445,17 +445,12 @@ lvar_address(e2,reg); } -/* -#define va_list int\n\ -#define va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\ -#define va_arg(ap,type) (*((type *)ap)++)\n\ -#define va_end\n\ - */ char *init_src = "\ #define __builtin_va_list int\n\ #define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\ #define __builtin_va_arg(ap,type) (*((type *)ap)++)\n\ +#define __builtin_next_arg(arg) ap=((void *)(&arg)),va_arg(ap,typeof(arg))\n\ #define __mips__ 1\n\ #define __LITTLE_ENDIAN__ 1\n\ #define __STDC__ 1\n\ @@ -463,6 +458,8 @@ #define __externsion__\n\ #define __flexarr\n\ #define __WCHAR_TYPE__ int\n\ +#define __alignof__(type) (sizeof(type)==1?1:sizeof(type)==2?2:sizeof(type)<=4?4:8)\n\ +#define __PTRDIFF_TYPE__ int "; void
--- a/mc-parse.c Sat Jun 12 11:51:45 2004 +0900 +++ b/mc-parse.c Sat Jun 12 15:58:56 2004 +0900 @@ -318,6 +318,7 @@ reserve("inline",INLINE); reserve("enum",ENUM); reserve("volatile",VOLATILE); + reserve("typeof",TYPEOF); gpc=glineno=0; gfree=ilabel=1; @@ -546,13 +547,14 @@ typespec(void) { int t = INT; + int slfree; stypedecl = 0; while (sym==KONST) { getsym(0); } if (sym==INLINE) { - getsym(0); + getsym(0); // should be static? } switch(sym) { case VOID: @@ -627,6 +629,15 @@ } else if(sym==INT) { getsym(0); } else if(sym==UNSIGNED) { t=UNSIGNED; getsym(0); } break; + case TYPEOF: + getsym(0); + checksym(LPAR); + slfree=lfree; + expr(0); type=t; + lfree=slfree; + checksym(RPAR); + return t; + break; default: if(sym==IDENT) { if(nptr->sc==TYPE) { @@ -3762,7 +3773,7 @@ return (integral(s) || s==CODE || s==SHORT || s==LONG || s==STRUCT || s==UNION || s==ENUM || s==LONGLONG || s==FLOAT || s==DOUBLE || s==VOID || - s==ULONGLONG || + s==ULONGLONG || s==TYPEOF || (s==IDENT && nptr->sc==TYPE)); } @@ -4906,6 +4917,7 @@ local_define(char *macro,char *value) { NMTBL *nptr0; + while(*macro==' '||*macro=='\t') macro++; nptr0 = msearch0(macro); /* save nptr previous contents in a list */ nptr0->ty=list3(nptr0->sc,nptr0->ty,nptr0->dsp); @@ -4974,6 +4986,10 @@ macrop=macro_eval(macrop,macro,list2((int)macro,history)); macrop = list2((int)macropp,macrop); } else if (nptrm->sc==FMACRO) { + if (c==' '||c=='\t') { + while (c==' '||c=='\t') c=*body++; + body--; + } if(c!='(') error(MCERR); *macropp++=0; body++; macrop = macro_function(macrop,&body,nptrm,
--- a/mc-switch.c Sat Jun 12 11:51:45 2004 +0900 +++ b/mc-switch.c Sat Jun 12 15:58:56 2004 +0900 @@ -347,8 +347,8 @@ genswitch(int cslist,int cslabel) { int chunks,merge,gmax; +#if 0 int i; -#if 0 int j; for(i=cslist;i;i=cadr(i)) { printf("# case %d L_%d\n",car(i),caddr(i));
--- a/mc.h Sat Jun 12 11:51:45 2004 +0900 +++ b/mc.h Sat Jun 12 15:58:56 2004 +0900 @@ -75,6 +75,7 @@ #define LONGLONG (-55) #define ULONGLONG (-56) #define VOLATILE (-57) +#define TYPEOF (-58) /* reserved word end */