Mercurial > hg > CbC > old > device
diff mc-code-powerpc.c @ 339:375d21a2b845
emit_data
author | kono |
---|---|
date | Fri, 25 Jun 2004 21:28:01 +0900 |
parents | 7fe7ce0a791f |
children | 0150de6a3244 |
line wrap: on
line diff
--- a/mc-code-powerpc.c Fri Jun 25 14:30:43 2004 +0900 +++ b/mc-code-powerpc.c Fri Jun 25 21:28:01 2004 +0900 @@ -2956,59 +2956,75 @@ } else { data_mode(0); } - if (t==EMPTY) { + switch(t) { + case EMPTY: if(car(e)!=CONST) error(-1); printf("\t.space\t%d\n",cadr(e)); return; - } - if(car(e)==CONST) { - if (t==CHAR||t==UCHAR) { - printf("\t.byte %d\n",cadr(e)); - if (data_alignment>0) - data_alignment++; - gpc += 1; - } else if (t==SHORT||t==USHORT) { - printf("\t.short %d\n",cadr(e)); - if (data_alignment>0) data_alignment++; - gpc += SIZE_OF_SHORT; - } else if (t==INT||t==UNSIGNED||t==ENUM||(t>0&&car(t)==POINTER)) { - printf("\t.long %d\n",cadr(e)); - gpc += SIZE_OF_INT; - } else { - // fprintf(stderr,"type= %d\n",t); - error(TYERR); - } + case CHAR: case UCHAR: + printf("\t.byte %d\n",cadr(e)); + if (data_alignment>0) + data_alignment++; + return; + case SHORT: case USHORT: + printf("\t.short %d\n",cadr(e)); + if (data_alignment>0) data_alignment++; + return; + case INT: case UNSIGNED: case ENUM: + printf("\t.long %d\n",cadr(e)); + return; #if LONGLONG_CODE - } else if(t==LONGLONG||t==ULONGLONG) { + case LONGLONG: case ULONGLONG: ll = lcadr(e); printf("\t.long\t0x%x,0x%x\n",code_l2(ll),code_l1(ll)); + return; #endif #if FLOAT_CODE - } else if(t==DOUBLE) { + case DOUBLE: d = dcadr(e); printf("\t.long\t0x%x,0x%x\n",code_d2(d),code_d1(d)); - } else if(t==FLOAT) { + return; + case FLOAT: f = dcadr(e); printf("\t.long\t0x%x\n",*(int *)&f); + return; #endif - } else if(t!=CHAR) { - gpc += SIZE_OF_INT; - if(car(e)==ADDRESS&&car(cadr(e))==GVAR) { - printf("\t.long _%s\n",((NMTBL *)cadr(cadr(e)))->nm); - } else if(car(e)==FNAME) { - printf("\t.long _%s\n",((NMTBL *)cadr(e))->nm); - } else if(car(e)==GVAR) { + default: + if (t<0) error(-1); +#if BIT_FIELD_CODE + if (car(t)==BIT_FIELD) { + return; + } +#endif + if (car(t)!=POINTER&&car(t)!=ARRAY) error(-1); + switch(car(e)) { + case CONST: + printf("\t.long %d\n",cadr(e)); + return; + case ADDRESS: + if (car(cadr(e))==GVAR) + printf("\t.long _%s\n",((NMTBL *)cadr(cadr(e)))->nm); + else error(INERR); + return; + case FNAME: printf("\t.long _%s\n",((NMTBL *)cadr(e))->nm); - } else if(car(e)==STRING) { - if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) { - l = emit_string_label(); - ascii((char *)cadr(e)); - data_mode(0); - printf("\t.long L_%d\n",l); - } else - ascii((char *)cadr(e)); - } else error(TYERR); - } else error(TYERR); + return; + case GVAR: + printf("\t.long _%s\n",((NMTBL *)cadr(e))->nm); + return; + case STRING: + if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) { + l = emit_string_label(); + ascii((char *)cadr(e)); + data_mode(0); + printf("\t.long L_%d\n",l); + } else + ascii((char *)cadr(e)); + return; + } + // fprintf(stderr,"# type= %d\n",t); + } + error(INERR); } void