Mercurial > hg > CbC > old > device
changeset 600:c6afbdf982f7
*** empty log message ***
author | kono |
---|---|
date | Thu, 26 Jan 2006 21:12:47 +0900 |
parents | df04bc5fd5fe |
children | 6b808480f08b |
files | mc-codegen.c |
diffstat | 1 files changed, 61 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-codegen.c Thu Jan 26 15:19:55 2006 +0900 +++ b/mc-codegen.c Thu Jan 26 21:12:47 2006 +0900 @@ -3378,11 +3378,11 @@ NMTBL str_ret; /* - If function has structure return value, it has an extra - argument for where to write the structure. It have to be - a first argument. We add it here and we have to fix all arguments' - offset. If it is the last value, we don't have to fix, but - gcc has a first argument convention. + If function has a structure return value, it has an extra + argument for where to write the structure. It has to be + the first argument. We add the argument here and we have + to fix all arguments' offset. If this is the last value, + we don't have to fix, but gcc has a first argument convention. */ extern void @@ -3398,7 +3398,7 @@ mode=ADECL; type_save = type; /* extra argument for struct return */ - /* this extra dummy arguments are set at calling sequence */ + /* This dummy variable is set in the calling sequence */ str_ret.nm = "str_ret"; str_ret.sc = EMPTY; str_ret.dsp = 0; str_ret.ty = 0; type=list2(POINTER,t); @@ -3480,12 +3480,18 @@ t==UCHAR||t==SHORT||t==USHORT||t==ENUM); } +/* + Delayed jmp code generation. A jump code will be delayed until + new code generation or new label. If label is equal the jumped + label, no jump code is necesarry. + */ + extern void checkjmp(int l) { int p = pending_jmp; - pending_jmp = 0; if (p) { + pending_jmp = 0; if (p!=l) { control=0; if (!chk) @@ -3494,6 +3500,12 @@ } } +/* + Delayed jmp code to function leaveing part. The lastexp in + a statement expression is also checked. It also handle the + first case statement jump in switch statement. + */ + extern void checkret(void) { @@ -3521,6 +3533,10 @@ } } +/* + In casading call of struct valued function, an argument for + return position will be replaced by calling function. + */ extern void replace_return_struct(int func,int left) { @@ -3531,7 +3547,7 @@ } -/* right value , get the value of the variable */ +/* indirect right value , get the value of the variable */ static int indirect(int t,int e1,int type) @@ -3550,6 +3566,10 @@ return list4(t,e1,offset,type); } +/* + make right value from original left value. + type will be changed. + */ extern int rvalue(int e) { @@ -3623,6 +3643,9 @@ } } +/* + right value with preserving type global variable + */ extern int rvalue_t(int e,int t) { @@ -3633,6 +3656,9 @@ return e; } +/* + left value check. Can we assign a value to it? + */ extern void lcheck(int e) { @@ -3653,6 +3679,9 @@ error(LVERR); } +/* + Indirect operator. + */ extern int indop(int e) { @@ -3670,7 +3699,7 @@ return(list2(INDIRECT,e)); } -/* filed name search */ +/* struct field name search */ /* type = list4(s,disp,fields,tag_nptr); */ @@ -3693,6 +3722,11 @@ return 0; } +/* + Structure operation + a.b, a->b + */ + extern int strop(int e,int ind) { @@ -3743,6 +3777,9 @@ } /* + + Binary operator parse tree generation (and optimization) + I don't know how to handle type attribute (const/volatie) in binop */ @@ -4312,6 +4349,9 @@ return e; } +/* + Integer Constant expression is required + */ extern int cexpr(int e) @@ -4459,18 +4499,23 @@ { disp-=sz; #if 1 - if (sz>=4 && (disp & (4-1))) { + if (sz>=4 && (disp & (4-1))) { // alignment disp &= ~(4-1); } #endif return disp; } +/* + Allocate new local variable in flat scope + */ + extern int new_lvar(int size) { int lvar,plvar; + /* Can we reuse previously freed local variable? */ for (plvar = 0,lvar = lvar_free_list;lvar;lvar = cadr(lvar)) { if (caddr(lvar)==size) { if (plvar) cadr(plvar) = cadr(lvar); @@ -4488,6 +4533,10 @@ return lvar; } +/* + Free the allocated local variable. It may be reused again. + */ + extern void free_lvar(int disp) { @@ -4604,6 +4653,8 @@ /* global name pointer cache + global pointer needs dynamic loading or table. + it may used again, put it to a register as a cache. */ extern void