comparison mc-code-powerpc.c @ 339:375d21a2b845

emit_data
author kono
date Fri, 25 Jun 2004 21:28:01 +0900
parents 7fe7ce0a791f
children 0150de6a3244
comparison
equal deleted inserted replaced
338:7fe7ce0a791f 339:375d21a2b845
2954 align(t); 2954 align(t);
2955 printf("_%s:\n",name); 2955 printf("_%s:\n",name);
2956 } else { 2956 } else {
2957 data_mode(0); 2957 data_mode(0);
2958 } 2958 }
2959 if (t==EMPTY) { 2959 switch(t) {
2960 case EMPTY:
2960 if(car(e)!=CONST) error(-1); 2961 if(car(e)!=CONST) error(-1);
2961 printf("\t.space\t%d\n",cadr(e)); 2962 printf("\t.space\t%d\n",cadr(e));
2962 return; 2963 return;
2963 } 2964 case CHAR: case UCHAR:
2964 if(car(e)==CONST) { 2965 printf("\t.byte %d\n",cadr(e));
2965 if (t==CHAR||t==UCHAR) { 2966 if (data_alignment>0)
2966 printf("\t.byte %d\n",cadr(e)); 2967 data_alignment++;
2967 if (data_alignment>0) 2968 return;
2968 data_alignment++; 2969 case SHORT: case USHORT:
2969 gpc += 1; 2970 printf("\t.short %d\n",cadr(e));
2970 } else if (t==SHORT||t==USHORT) { 2971 if (data_alignment>0) data_alignment++;
2971 printf("\t.short %d\n",cadr(e)); 2972 return;
2972 if (data_alignment>0) data_alignment++; 2973 case INT: case UNSIGNED: case ENUM:
2973 gpc += SIZE_OF_SHORT; 2974 printf("\t.long %d\n",cadr(e));
2974 } else if (t==INT||t==UNSIGNED||t==ENUM||(t>0&&car(t)==POINTER)) { 2975 return;
2975 printf("\t.long %d\n",cadr(e));
2976 gpc += SIZE_OF_INT;
2977 } else {
2978 // fprintf(stderr,"type= %d\n",t);
2979 error(TYERR);
2980 }
2981 #if LONGLONG_CODE 2976 #if LONGLONG_CODE
2982 } else if(t==LONGLONG||t==ULONGLONG) { 2977 case LONGLONG: case ULONGLONG:
2983 ll = lcadr(e); 2978 ll = lcadr(e);
2984 printf("\t.long\t0x%x,0x%x\n",code_l2(ll),code_l1(ll)); 2979 printf("\t.long\t0x%x,0x%x\n",code_l2(ll),code_l1(ll));
2980 return;
2985 #endif 2981 #endif
2986 #if FLOAT_CODE 2982 #if FLOAT_CODE
2987 } else if(t==DOUBLE) { 2983 case DOUBLE:
2988 d = dcadr(e); 2984 d = dcadr(e);
2989 printf("\t.long\t0x%x,0x%x\n",code_d2(d),code_d1(d)); 2985 printf("\t.long\t0x%x,0x%x\n",code_d2(d),code_d1(d));
2990 } else if(t==FLOAT) { 2986 return;
2987 case FLOAT:
2991 f = dcadr(e); 2988 f = dcadr(e);
2992 printf("\t.long\t0x%x\n",*(int *)&f); 2989 printf("\t.long\t0x%x\n",*(int *)&f);
2993 #endif 2990 return;
2994 } else if(t!=CHAR) { 2991 #endif
2995 gpc += SIZE_OF_INT; 2992 default:
2996 if(car(e)==ADDRESS&&car(cadr(e))==GVAR) { 2993 if (t<0) error(-1);
2997 printf("\t.long _%s\n",((NMTBL *)cadr(cadr(e)))->nm); 2994 #if BIT_FIELD_CODE
2998 } else if(car(e)==FNAME) { 2995 if (car(t)==BIT_FIELD) {
2996 return;
2997 }
2998 #endif
2999 if (car(t)!=POINTER&&car(t)!=ARRAY) error(-1);
3000 switch(car(e)) {
3001 case CONST:
3002 printf("\t.long %d\n",cadr(e));
3003 return;
3004 case ADDRESS:
3005 if (car(cadr(e))==GVAR)
3006 printf("\t.long _%s\n",((NMTBL *)cadr(cadr(e)))->nm);
3007 else error(INERR);
3008 return;
3009 case FNAME:
2999 printf("\t.long _%s\n",((NMTBL *)cadr(e))->nm); 3010 printf("\t.long _%s\n",((NMTBL *)cadr(e))->nm);
3000 } else if(car(e)==GVAR) { 3011 return;
3012 case GVAR:
3001 printf("\t.long _%s\n",((NMTBL *)cadr(e))->nm); 3013 printf("\t.long _%s\n",((NMTBL *)cadr(e))->nm);
3002 } else if(car(e)==STRING) { 3014 return;
3003 if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) { 3015 case STRING:
3004 l = emit_string_label(); 3016 if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) {
3005 ascii((char *)cadr(e)); 3017 l = emit_string_label();
3006 data_mode(0); 3018 ascii((char *)cadr(e));
3007 printf("\t.long L_%d\n",l); 3019 data_mode(0);
3008 } else 3020 printf("\t.long L_%d\n",l);
3009 ascii((char *)cadr(e)); 3021 } else
3010 } else error(TYERR); 3022 ascii((char *)cadr(e));
3011 } else error(TYERR); 3023 return;
3024 }
3025 // fprintf(stderr,"# type= %d\n",t);
3026 }
3027 error(INERR);
3012 } 3028 }
3013 3029
3014 void 3030 void
3015 emit_data_closing(NMTBL *n) 3031 emit_data_closing(NMTBL *n)
3016 { 3032 {