Mercurial > hg > CbC > old > device
changeset 164:1c2a9232ea93
mc.h generation
author | kono |
---|---|
date | Mon, 24 Nov 2003 09:29:06 +0900 |
parents | fc8514c9d685 |
children | 6409ff6bc219 |
files | Changes mc-code-mips.c mc-code-powerpc.c mc-codegen.c mc-mips.c mc-nop-386.c mc-parse.c mc.h |
diffstat | 8 files changed, 233 insertions(+), 181 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Mon Nov 24 00:52:18 2003 +0900 +++ b/Changes Mon Nov 24 09:29:06 2003 +0900 @@ -3489,3 +3489,11 @@ という感じで余計なfieldが定義されてるみたい。 adecl で nptr が引数の最後を指してしまうのがまずかった。 + +Mon Nov 24 00:52:31 JST 2003 + +signed char は実装しましたが... test routine がない。 + +あと、short は、code_crxxxx の中でbyteの大きさに従って +処理するのがいいかな。 +
--- a/mc-code-mips.c Mon Nov 24 00:52:18 2003 +0900 +++ b/mc-code-mips.c Mon Nov 24 09:29:06 2003 +0900 @@ -1429,7 +1429,7 @@ !contains_in_list(e3,FUNCTION) && !contains_in_list(e3,CONV) && !contains_in_list(e3,RSTRUCT) && - !contains_in_list(e3,SASS) + !contains_in_list(e3,STASS) ; }
--- a/mc-code-powerpc.c Mon Nov 24 00:52:18 2003 +0900 +++ b/mc-code-powerpc.c Mon Nov 24 09:29:06 2003 +0900 @@ -1415,7 +1415,7 @@ !contains_in_list(e3,FUNCTION) && !contains_in_list(e3,CONV) && !contains_in_list(e3,RSTRUCT) && - !contains_in_list(e3,SASS) + !contains_in_list(e3,STASS) ; }
--- a/mc-codegen.c Mon Nov 24 00:52:18 2003 +0900 +++ b/mc-codegen.c Mon Nov 24 09:29:06 2003 +0900 @@ -305,7 +305,7 @@ code_set_fixed_creg(1,t); fwddef(e3); return t; - case SASS: + case STASS: sassign(e1); return RSTRUCT; case ASS: case CASS: @@ -1314,58 +1314,28 @@ { while(e) { if (car(e)==type) return 1; - switch (car(e)){ + if (LIST_ARGS(car(e))){ /* list arguments */ - case FUNCTION: case CODE: return contains_in_list(caddr(e),type); + } else if (UNARY_ARGS(car(e))) { /* unary operators */ - case INDIRECT: case RINDIRECT: case CRINDIRECT: case CURINDIRECT: - case DRINDIRECT: case FRINDIRECT: case ADDRESS: case MINUS: case DMINUS: - case BNOT: case LNOT: - case PREINC: case POSTINC: case DPREINC: case DPOSTINC: - case FPREINC: case FPOSTINC: case CPOSTINC: - case CPREINC: case CPOSTDEC: case CPREDEC: - case CUPOSTINC: - case CUPREINC: case CUPOSTDEC: case CUPREDEC: - case RSTRUCT: - /* case I2D: case D2I: case U2D: case D2U: */ - case CONV: e = cadr(e); continue; + } else if (BINARY_ARGS(car(e))) { /* biary operators */ - case MUL: case UMUL: case DIV: case UDIV: case MOD: case UMOD: - case LSHIFT: case ULSHIFT: case RSHIFT: case URSHIFT: - case ADD: case SUB: case BAND: case EOR: case BOR: case CMP: - case DMUL: case DDIV: case DADD: case DSUB: case DCMP: case DCMPGE: - case FMUL: case FDIV: case FADD: case FSUB: case FCMP: case FCMPGE: - case SASS: case ASS: case CASS: case FASS: case DASS: case LASS: - case ASSOP: case CASSOP: case DASSOP: case FASSOP: case COMMA: - case EQ: case NEQ: - case LAND: case LOR: - case DOP+EQ: case DOP+NEQ: - case FOP+EQ: case FOP+NEQ: - case LT: case ULT: case LE: case ULE: - case GT: case UGT: case GE: case UGE: - case DOP+LT: case DOP+LE: case DOP+GT: case DOP+GE: - case FOP+LT: case FOP+LE: case FOP+GT: case FOP+GE: if (contains(cadr(e),type)) return 1; e = caddr(e); continue; + } else if (TARNARY_ARGS(car(e))) { /* tarary operators */ - case COND: case DCOND: case FCOND: if (contains(cadr(e), type)) return 1; if (contains(caddr(e),type)) return 1; e = cadddr(e); continue; + } else if (NULLARY_ARGS(car(e))) { /* nullary operators */ - case GVAR: case RGVAR: case CRGVAR: case LVAR: case CURGVAR: - case REGISTER: case DREGISTER: case FREGISTER: - case RLVAR: case CRLVAR: case CURLVAR: case FRLVAR: case FRGVAR: - case DRLVAR: case DRGVAR: - case FNAME: case CONST: case DCONST: case FCONST: case STRING: - case RETURN: case ENVIRONMENT: return 0; - default: + } else { fprintf(stderr,"Unknown Tree ID %d\n",car(e)); error(-1); return 0;
--- a/mc-mips.c Mon Nov 24 00:52:18 2003 +0900 +++ b/mc-mips.c Mon Nov 24 09:29:06 2003 +0900 @@ -573,7 +573,7 @@ use_register(creg,e4,1); fwddef(e3); return; - case SASS: + case STASS: sassign(e1); return; case ASS: case CASS:
--- a/mc-nop-386.c Mon Nov 24 00:52:18 2003 +0900 +++ b/mc-nop-386.c Mon Nov 24 09:29:06 2003 +0900 @@ -677,7 +677,7 @@ use_register(creg,REG_EAX,1); fwddef(e3); return; - case SASS: + case STASS: sassign(e1); return; case ASS: case CASS:
--- a/mc-parse.c Mon Nov 24 00:52:18 2003 +0900 +++ b/mc-parse.c Mon Nov 24 09:29:06 2003 +0900 @@ -807,7 +807,7 @@ return n; } } - if (n->sc!=EMPTY && !((n->sc&~1)==EXTRN)) { + if (n->sc!=EMPTY && !(n->sc==EXTRN||n->sc==EXTRN1)) { if (mode==ADECL) { if (n->sc==LVAR && n->ty==INT); else if ( n->sc==REGISTER && n->ty==INT); @@ -1682,7 +1682,7 @@ } else { type = caddr(struct_return); e1 = rvalue_t(cadr(struct_return),INT); /* size */ - gexpr(list4(SASS,rvalue(car(struct_return)),e,e1),0); + gexpr(list4(STASS,rvalue(car(struct_return)),e,e1),0); } } else { error(TYERR); /* should check compatible */ @@ -1852,7 +1852,7 @@ replace_return_struct(cadr(e2),e1); return cadr(e2); } else { - return (list4(SASS,e1,e2,size(t))); + return (list4(STASS,e1,e2,size(t))); } } else { error(TYERR); return list3(ASS,e1,e2); @@ -2294,6 +2294,7 @@ static void extrn_use(NMTBL *nptr) { + /* EXTRN1 means that defined extern is used in this source */ if(nptr->sc==EXTRN) nptr->sc=EXTRN1; }
--- a/mc.h Mon Nov 24 00:52:18 2003 +0900 +++ b/mc.h Mon Nov 24 09:29:06 2003 +0900 @@ -11,6 +11,8 @@ #define SIZE_INT 4 +/* reserved word start */ + #define INT (-1) #define UNSIGNED (-2) #define CHAR (-3) @@ -38,38 +40,40 @@ #define TAG (-24) #define FIELD (-25) #define IDENT (-26) -#define STRING (-27) -#define MACRO (-28) -#define BLABEL (-29) -#define FLABEL (-30) -#define TYPEDEF (-31) -#define SIZEOF (-32) -#define TYPE (-33) -#define LONG (-34) -#define ULONG (-35) -#define SHORT (-36) -#define USHORT (-37) -#define EXTRN (-38) -#define EXTRN1 (-39) -#define VOID (-40) -#define REGISTER (-41) -#define CODE (-42) -#define ENVIRONMENT (-43) -#define DEFINED (-44) -#define KONST (-45) -#define FMACRO (-46) -#define LMACRO (-47) -#define DOTS (-49) +#define MACRO (-27) +#define BLABEL (-28) +#define FLABEL (-29) +#define TYPEDEF (-30) +#define SIZEOF (-31) +#define TYPE (-32) +#define LONG (-33) +#define ULONG (-34) +#define SHORT (-35) +#define USHORT (-36) +#define EXTRN (-37) +#define EXTRN1 (-38) +#define VOID (-39) +#define REGISTER (-40) +#define CODE (-41) +#define ENVIRONMENT (-42) +#define DEFINED (-43) +#define KONST (-44) +#define FMACRO (-45) +#define LMACRO (-46) +#define DOTS (-47) -#define FLOAT (-50) -#define DOUBLE (-51) -#define FREGISTER (-52) -#define DREGISTER (-53) -#define LONGLONG (-54) -#define ULONGLONG (-55) +#define FLOAT (-48) +#define DOUBLE (-49) +#define FREGISTER (-50) +#define DREGISTER (-51) +#define LONGLONG (-52) +#define ULONGLONG (-53) + +/* reserved word end */ #define EMPTY (-99) +/* mode start */ #define TOP 0 #define GDECL 1 #define GSDECL 2 @@ -84,6 +88,20 @@ #define LTDECL 11 #define IFDEF 12 #define MDECL 13 +/* mode end */ + +#define US 1 +#define AS 1000 +#define SOP 200 +#define DOP 400 +#define FOP 600 +#define LOP 800 + +/* tree node tags start */ + +#define LIST_ARGS(i) (i==FUNCTION||i==CODE) + +/* nullary argments */ #define GVAR 1 #define RGVAR 2 @@ -93,77 +111,121 @@ #define RLVAR 6 #define CRLVAR 7 #define CURLVAR 8 +#define FRGVAR (FOP+RGVAR) +#define FRLVAR (FOP+RLVAR) +#define DRGVAR (DOP+RGVAR) +#define DRLVAR (DOP+RLVAR) +#define SRGVAR (SOP+RGVAR) +#define SRLVAR (SOP+RLVAR) +#define SURGVAR (SOP+CURGVAR) +#define SURLVAR (SOP+CURLVAR) +#define LRGVAR (LOP+RGVAR) +#define LRLVAR (LOP+RLVAR) +#define LURGVAR (LOP+CURGVAR) +#define LURLVAR (LOP+CURLVAR) + #define CONST 9 -#define FNAME 10 -#define INDIRECT 11 -#define RINDIRECT 12 -#define CRINDIRECT 13 -#define CURINDIRECT 14 -#define ADDRESS 15 -#define MINUS 16 -#define LNOT 17 -#define BNOT 18 -#define INC 19 -#define POSTINC 20 -#define PREINC 21 -#define CPOSTINC 22 -#define CPREINC 23 +#define DCONST (DOP+CONST) +#define FCONST (FOP+CONST) +#define LCONST (LOP+CONST) +#define STRING 10 +#define FNAME 11 + +#define NULLARY_ARGS(i) (GVAR<=(i%SOP)&&(i%SOP)<=FNAME) + +/* unary argments */ + +#define ADDRESS 12 +#define MINUS 13 +#define LNOT 14 +#define BNOT 15 +#define INC 16 +#define POSTINC 17 +#define PREINC 18 +#define DEC 19 +#define CPOSTINC 20 +#define CPREINC 21 +#define CPOSTDEC 22 +#define CPREDEC 23 #define CUPOSTINC 24 -#define CUPREINC 25 -#define DEC 26 -#define CPOSTDEC 27 -#define CPREDEC 28 -#define CUPOSTDEC 29 -#define CUPREDEC 30 -#define MUL 31 -#define UMUL 32 -#define DIV 33 -#define UDIV 34 -#define MOD 35 -#define UMOD 36 -#define ADD 37 -#define SUB 38 -#define CMP 39 -#define RSHIFT 40 -#define URSHIFT 41 -#define LSHIFT 42 -#define ULSHIFT 43 -#define GT 44 -#define UGT 45 -#define GE 46 -#define UGE 47 -#define LT 48 -#define ULT 49 -#define LE 50 -#define ULE 51 -#define EQ 52 -#define NEQ 53 -#define BAND 54 -#define EOR 55 -#define BOR 56 -#define LAND 57 -#define LOR 58 -#define COND 59 -#define ASS 60 -#define CASS 61 -#define ASSOP 62 -#define CASSOP 63 -#define CUASSOP 64 +#define CUPREINC 25 +#define CUPOSTDEC 26 +#define CUPREDEC 27 +#define SPOSTINC (SOP+CPOSTINC) +#define SPREINC (SOP+CPREINC) +#define SPOSTDEC (SOP+CPOSTDEC) +#define SPREDEC (SOP+CPREDEC) +#define SUPOSTINC (SOP+CUPOSTINC) +#define SUPREINC (SOP+CUPREINC) +#define SUPOSTDEC (SOP+CUPOSTDEC) +#define SUPREDEC (SOP+CUPREDEC) +#define FPOSTINC (FOP+POSTINC) +#define FPREINC (FOP+PREINC) +#define DPOSTINC (DOP+POSTINC) +#define DPREINC (DOP+PREINC) +#define LPOSTINC (LOP+POSTINC) +#define LPREINC (LOP+PREINC) +#define LUPOSTINC (LOP+CUPOSTINC) +#define LUPREINC (LOP+CUPREINC) +#define INDIRECT 28 +#define RINDIRECT 29 +#define CRINDIRECT 30 +#define CURINDIRECT 31 +#define SRINDIRECT (SOP+CRINDIRECT) +#define SURINDIRECT (SOP+CURINDIRECT) +#define FRINDIRECT (FOP+RINDIRECT) +#define DRINDIRECT (DOP+RINDIRECT) +#define LRINDIRECT (DOP+RINDIRECT) +#define RSTRUCT 32 +#define CONV 33 + +#define UNARY_ARGS(i) (ADDRESS<=(i%SOP)&&(i%SOP)<=CONV) + +/* binary argments */ + +#define MUL 34 +#define UMUL 35 +#define DIV 36 +#define UDIV 37 +#define MOD 38 +#define UMOD 39 +#define ADD 40 +#define SUB 41 +#define CMP 42 +#define RSHIFT 43 +#define URSHIFT 44 +#define LSHIFT 45 +#define ULSHIFT 46 +#define GT 47 +#define UGT 48 +#define GE 49 +#define UGE 50 +#define LT 51 +#define ULT 52 +#define LE 53 +#define ULE 54 +#define EQ 55 +#define NEQ 56 +#define BAND 57 +#define EOR 58 +#define BOR 59 +#define LAND 60 +#define LOR 61 +#define ASS 62 +#define CMPGE 63 +#define ASSOP 64 #define COMMA 65 -#define LPAR 66 -#define RPAR 67 -#define LBRA 68 -#define RBRA 69 -#define LC 70 -#define RC 71 -#define COLON 72 -#define SM 73 -#define PERIOD 74 -#define ARROW 75 -#define CNAME 76 -#define SASS 77 -#define RSTRUCT 78 + +#define CASS 66 +#define CASSOP 67 +#define CUASSOP 68 +#define SASS (SOP+ASS) +#define SASSOP (SOP+CASSOP) +#define SUASSOP (SOP+CUASSOP) + +#define DASS (DOP+ASS) +#define DCMPGE (DOP+CMPGE) #define DASSOP (DOP+ASSOP) #define DCMP (DOP+CMP) #define DMINUS (DOP+MINUS) @@ -171,6 +233,9 @@ #define DDIV (DOP+DIV) #define DADD (DOP+ADD) #define DSUB (DOP+SUB) + +#define FASS (FOP+ASS) +#define FCMPGE (FOP+CMPGE) #define FASSOP (FOP+ASSOP) #define FCMP (FOP+CMP) #define FMINUS (FOP+MINUS) @@ -178,53 +243,60 @@ #define FDIV (FOP+DIV) #define FADD (FOP+ADD) #define FSUB (FOP+SUB) -#define CMPGE 79 -#define DCMPGE (DOP+CMPGE) -#define FCMPGE (FOP+CMPGE) -#define LMUL 80 -#define LDIV 81 -#define LADD 82 -#define LSUB 83 -#define FRGVAR 84 -#define FRLVAR 85 -#define FRINDIRECT 86 -#define DRGVAR 87 -#define DRLVAR 88 -#define DRINDIRECT 90 -#define LRGVAR 91 -#define LRLVAR 92 -#define LRINDIRECT 93 -#define DCONST (DOP+CONST) -#define FCONST (FOP+CONST) -#define LCONST 94 -#define DASS 95 -#define FASS 96 -#define LASS 97 -#define SHASS 98 +#define LASS (LOP+ASS) +#define LCMPGE (LOP+CMPGE) +#define LASSOP (LOP+CASSOP) +#define LUASSOP (LOP+CUASSOP) +#define LMUL (LOP+MUL) +#define LDIV (LOP+DIV) +#define LUMUL (LOP+UMUL) +#define LUDIV (LOP+UDIV) +#define LADD (LOP+ADD) +#define LSUB (LOP+SUB) -#define I2D 99 -#define D2I 100 -#define U2D 101 -#define D2U 102 -#define F2D 103 -#define D2F 104 -#define I2F 105 -#define F2I 106 -#define U2F 107 -#define F2U 108 -#define FPOSTINC (FOP+POSTINC) -#define DPOSTINC (DOP+POSTINC) -#define FPREINC (FOP+PREINC) -#define DPREINC (DOP+PREINC) +#define STASS 69 + +#define BINARY_ARGS(i) (MUL<=(i%SOP)&&(i%SOP)<=STASS) + +/* tarnary argments */ + +#define COND 70 +#define SCOND (SOP+COND) #define DCOND (DOP+COND) #define FCOND (FOP+COND) -#define CONV 109 +#define LCOND (LOP+COND) + +#define TARNARY_ARGS(i) (COND==(i%SOP)) + +/* not appeared as tags */ -#define US 1 -#define AS 200 -#define DOP 400 -#define FOP 600 +#define I2D 71 +#define D2I 72 +#define U2D 73 +#define D2U 74 +#define F2D 75 +#define D2F 76 +#define I2F 77 +#define F2I 78 +#define U2F 79 +#define F2U 80 + +#define LPAR 81 +#define RPAR 82 +#define LBRA 83 +#define RBRA 84 +#define LC 85 +#define RC 86 +#define COLON 87 +#define SM 88 +#define PERIOD 89 +#define ARROW 90 +#define CNAME 91 + +/* tree node tags end */ + +/* error number start */ #define FILERR 1 #define DCERR 2 @@ -247,6 +319,7 @@ #define REG_ERR 19 #define CODE_ERR 20 #define MSERR 21 +/* error number end */ #define GSYMS 9000 #define LSYMS 500