Mercurial > hg > CbC > old > device
comparison mc-code-mips.c @ 195:c193120ee2a6
*** empty log message ***
author | kono |
---|---|
date | Sun, 04 Apr 2004 21:17:10 +0900 |
parents | f53d70110377 |
children | 5f70abd9453d |
comparison
equal
deleted
inserted
replaced
194:114e9d64b5cc | 195:c193120ee2a6 |
---|---|
177 if (!is_double_reg(i)) i = dreg; | 177 if (!is_double_reg(i)) i = dreg; |
178 if (!regs[i]) regs[i]=1; | 178 if (!regs[i]) regs[i]=1; |
179 return i; | 179 return i; |
180 } | 180 } |
181 | 181 |
182 int use_longlong(int i) { | |
183 return i; | |
184 } | |
185 | |
186 #if FLOAT_CODE | |
182 static int code_d1(double d); | 187 static int code_d1(double d); |
183 static int code_d2(double d); | 188 static int code_d2(double d); |
189 #endif | |
184 | 190 |
185 static void code_save_stacks(); | 191 static void code_save_stacks(); |
186 static void code_save_input_registers(); | 192 static void code_save_input_registers(); |
187 static void set_creg(int,int); | 193 static void set_creg(int,int); |
188 static void set_freg(int,int); | 194 static void set_freg(int,int); |
401 (reg_stack[i]=new_lvar(size_of_int)),reg,0); | 407 (reg_stack[i]=new_lvar(size_of_int)),reg,0); |
402 reg_stack[i]= reg_stack[i]-REG_LVAR_OFFSET; | 408 reg_stack[i]= reg_stack[i]-REG_LVAR_OFFSET; |
403 return reg; | 409 return reg; |
404 } | 410 } |
405 } | 411 } |
412 #if FLOAT_CODE | |
406 /* search dregister stack */ | 413 /* search dregister stack */ |
407 for(i=0;i<dreg_sp;i++) { | 414 for(i=0;i<dreg_sp;i++) { |
408 if ((reg=dreg_stack[i])>=0) { | 415 if ((reg=dreg_stack[i])>=0) { |
409 code_dassign_lvar( | 416 code_dassign_lvar( |
410 (dreg_stack[i]=new_lvar(size_of_double)),reg,1); | 417 (dreg_stack[i]=new_lvar(size_of_double)),reg,1); |
411 dreg_stack[i]= dreg_stack[i]-REG_LVAR_OFFSET; | 418 dreg_stack[i]= dreg_stack[i]-REG_LVAR_OFFSET; |
412 free_register(reg); | 419 free_register(reg); |
413 return get_register(); /* 今度は必ずある */ | 420 return get_register(); /* 今度は必ずある */ |
414 } | 421 } |
415 } | 422 } |
423 #endif | |
416 for(i=0;i<REG_VAR_BASE-REG_VAR_MIN;i++) { | 424 for(i=0;i<REG_VAR_BASE-REG_VAR_MIN;i++) { |
417 reg =REG_VAR_BASE-i; | 425 reg =REG_VAR_BASE-i; |
418 if (! regs[reg]) { /* 使われていないなら */ | 426 if (! regs[reg]) { /* 使われていないなら */ |
419 regs[reg]=USING_REG; /* そのレジスタを使うことを宣言し */ | 427 regs[reg]=USING_REG; /* そのレジスタを使うことを宣言し */ |
420 regv[reg]=0; | 428 regv[reg]=0; |
429 int | 437 int |
430 pop_register(void) | 438 pop_register(void) |
431 { /* レジスタから値を取り出す */ | 439 { /* レジスタから値を取り出す */ |
432 return reg_stack[--reg_sp]; | 440 return reg_stack[--reg_sp]; |
433 } | 441 } |
442 | |
443 #if FLOAT_CODE | |
434 | 444 |
435 static int | 445 static int |
436 get_dregister1() { | 446 get_dregister1() { |
437 int i; | 447 int i; |
438 for(i=MAX_TMP_DREG+DREG_OFFSET;i>MIN_TMP_DREG+DREG_OFFSET;i--) { | 448 for(i=MAX_TMP_DREG+DREG_OFFSET;i>MIN_TMP_DREG+DREG_OFFSET;i--) { |
530 int | 540 int |
531 pop_dregister(void) | 541 pop_dregister(void) |
532 { /* レジスタから値を取り出す */ | 542 { /* レジスタから値を取り出す */ |
533 return dreg_stack[--dreg_sp]; | 543 return dreg_stack[--dreg_sp]; |
534 } | 544 } |
545 #endif | |
546 | |
547 #if LONGLONG_CODE | |
548 int | |
549 get_lregister_var(NMTBL *n) | |
550 { | |
551 return -1; | |
552 } | |
553 #endif | |
554 | |
535 | 555 |
536 void | 556 void |
537 emit_pop_free(int xreg) | 557 emit_pop_free(int xreg) |
538 { | 558 { |
539 if (xreg>=0) | 559 if (xreg>=0) |
638 int i; | 658 int i; |
639 for(i=0;i<MAX_REGISTER;i++) { regs[i]=0; regv[i]=0; } | 659 for(i=0;i<MAX_REGISTER;i++) { regs[i]=0; regv[i]=0; } |
640 for(i=0;i<MAX_FREGISTER;i++) { regs[i+FREG_OFFSET]=0; regv[i+FREG_OFFSET]=0; } | 660 for(i=0;i<MAX_FREGISTER;i++) { regs[i+FREG_OFFSET]=0; regv[i+FREG_OFFSET]=0; } |
641 for(i=0;i<MAX_DREGISTER;i++) { regs[i+DREG_OFFSET]=0; regv[i+DREG_OFFSET]=0; } | 661 for(i=0;i<MAX_DREGISTER;i++) { regs[i+DREG_OFFSET]=0; regv[i+DREG_OFFSET]=0; } |
642 creg = get_register(); | 662 creg = get_register(); |
663 #if FLOAT_CODE | |
643 freg = get_dregister(0); | 664 freg = get_dregister(0); |
644 dreg = DREG_DREGISTER; | 665 dreg = DREG_DREGISTER; |
666 #endif | |
645 set_creg(CREG_REGISTER,0); | 667 set_creg(CREG_REGISTER,0); |
646 set_freg(FREG_FREGISTER,0); | 668 set_freg(FREG_FREGISTER,0); |
647 set_dreg(DREG_DREGISTER,0); | 669 set_dreg(DREG_DREGISTER,0); |
648 return; | 670 return; |
649 } | 671 } |
2070 | 2092 |
2071 void | 2093 void |
2072 emit_data(int e, int t, NMTBL *n) | 2094 emit_data(int e, int t, NMTBL *n) |
2073 { | 2095 { |
2074 int l; | 2096 int l; |
2097 #if FLOAT_CODE | |
2075 double d; | 2098 double d; |
2076 float f; | 2099 float f; |
2100 #endif | |
2077 char *name; | 2101 char *name; |
2078 name = n->nm; | 2102 name = n->nm; |
2079 if(mode!=GDECL&&mode!=STADECL) { | 2103 if(mode!=GDECL&&mode!=STADECL) { |
2080 error(-1); return; | 2104 error(-1); return; |
2081 } | 2105 } |
2101 gpc += 2; | 2125 gpc += 2; |
2102 } else { | 2126 } else { |
2103 printf("\t.word %d\n",cadr(e)); | 2127 printf("\t.word %d\n",cadr(e)); |
2104 gpc += size_of_int; | 2128 gpc += size_of_int; |
2105 } | 2129 } |
2130 #if FLOAT_CODE | |
2106 } else if(t==DOUBLE) { | 2131 } else if(t==DOUBLE) { |
2107 d = dcadr(e); | 2132 d = dcadr(e); |
2108 printf("\t.word\t0x%x\n\t.word\t0x%x\n",code_d1(d),code_d2(d)); | 2133 printf("\t.word\t0x%x\n\t.word\t0x%x\n",code_d1(d),code_d2(d)); |
2109 } else if(t==FLOAT) { | 2134 } else if(t==FLOAT) { |
2110 f = dcadr(e); | 2135 f = dcadr(e); |
2111 printf("\t.word\t0x%x\n",*(int *)&f); | 2136 printf("\t.word\t0x%x\n",*(int *)&f); |
2137 #endif | |
2112 } else if(t!=CHAR) { | 2138 } else if(t!=CHAR) { |
2113 gpc += size_of_int; | 2139 gpc += size_of_int; |
2114 if(car(e)==ADDRESS&&car(cadr(e))==GVAR) { | 2140 if(car(e)==ADDRESS&&car(cadr(e))==GVAR) { |
2115 printf("\t.word _%s\n",((NMTBL *)cadr(cadr(e)))->nm); | 2141 printf("\t.word _%s\n",((NMTBL *)cadr(cadr(e)))->nm); |
2116 } else if(car(e)==FNAME) { | 2142 } else if(car(e)==FNAME) { |
2209 output_mode = DATA_EMIT_MODE; | 2235 output_mode = DATA_EMIT_MODE; |
2210 } | 2236 } |
2211 if (name) | 2237 if (name) |
2212 printf("\t.type\t%s,@object\n",name); | 2238 printf("\t.type\t%s,@object\n",name); |
2213 } | 2239 } |
2240 | |
2241 #if FLOAT_CODE | |
2214 | 2242 |
2215 char * | 2243 char * |
2216 fstore(int d) | 2244 fstore(int d) |
2217 { | 2245 { |
2218 return (d?"stfd":"stfs"); | 2246 return (d?"stfd":"stfs"); |
2745 creg = freg = new_reg; | 2773 creg = freg = new_reg; |
2746 regv[freg]=1; | 2774 regv[freg]=1; |
2747 } | 2775 } |
2748 } | 2776 } |
2749 | 2777 |
2778 #endif | |
2779 | |
2750 void | 2780 void |
2751 code_save_stacks() | 2781 code_save_stacks() |
2752 { | 2782 { |
2753 int i,reg; | 2783 int i,reg; |
2754 for(i=0;i<reg_sp;i++) { | 2784 for(i=0;i<reg_sp;i++) { |
2756 code_assign_lvar( | 2786 code_assign_lvar( |
2757 (reg_stack[i]=new_lvar(size_of_int)),reg,0); | 2787 (reg_stack[i]=new_lvar(size_of_int)),reg,0); |
2758 reg_stack[i]= reg_stack[i]-REG_LVAR_OFFSET; | 2788 reg_stack[i]= reg_stack[i]-REG_LVAR_OFFSET; |
2759 } | 2789 } |
2760 } | 2790 } |
2791 #if FLOAT_CODE | |
2761 for(i=0;i<dreg_sp;i++) { | 2792 for(i=0;i<dreg_sp;i++) { |
2762 if ((reg=dreg_stack[i])>=0) { | 2793 if ((reg=dreg_stack[i])>=0) { |
2763 code_dassign_lvar( | 2794 code_dassign_lvar( |
2764 (dreg_stack[i]=new_lvar(size_of_double)),reg,1); | 2795 (dreg_stack[i]=new_lvar(size_of_double)),reg,1); |
2765 dreg_stack[i]= dreg_stack[i]-REG_LVAR_OFFSET; | 2796 dreg_stack[i]= dreg_stack[i]-REG_LVAR_OFFSET; |
2770 code_dassign_lvar( | 2801 code_dassign_lvar( |
2771 (freg_stack[i]=new_lvar(size_of_float)),reg,0); | 2802 (freg_stack[i]=new_lvar(size_of_float)),reg,0); |
2772 freg_stack[i]= freg_stack[i]-REG_LVAR_OFFSET; | 2803 freg_stack[i]= freg_stack[i]-REG_LVAR_OFFSET; |
2773 } | 2804 } |
2774 } | 2805 } |
2806 #endif | |
2775 } | 2807 } |
2776 | 2808 |
2777 void | 2809 void |
2778 emit_lib(char *p[]) | 2810 emit_lib(char *p[]) |
2779 { | 2811 { |
2788 global_table(); | 2820 global_table(); |
2789 /* printf("\t.ident \"Micro-C compiled\"\n"); */ | 2821 /* printf("\t.ident \"Micro-C compiled\"\n"); */ |
2790 fclose(asi); | 2822 fclose(asi); |
2791 } | 2823 } |
2792 | 2824 |
2825 | |
2826 #if LONGLONG_CODE | |
2827 | |
2828 | |
2829 /* 64bit int part */ | |
2830 | |
2831 void lrexpr(int e1, int e2,int l1, int op) | |
2832 { | |
2833 } | |
2834 | |
2835 int lpop_register() | |
2836 { | |
2837 return 0; | |
2838 } | |
2839 | |
2840 int emit_lpop() | |
2841 { | |
2842 return 0; | |
2843 } | |
2844 | |
2845 void code_lregister(int e2,int reg) | |
2846 { | |
2847 | |
2848 } | |
2849 | |
2850 void code_cmp_lregister(int reg) | |
2851 { | |
2852 | |
2853 } | |
2854 | |
2855 void code_cmp_lrgvar(int e1,int e2) | |
2856 { | |
2857 | |
2858 } | |
2859 | |
2860 void code_cmp_lrlvar(int e1,int e2) | |
2861 { | |
2862 | |
2863 } | |
2864 | |
2865 void code_lassign(int e1,int e2) | |
2866 { | |
2867 | |
2868 } | |
2869 | |
2870 void code_lassign_gvar(int e1,int e2) | |
2871 { | |
2872 | |
2873 } | |
2874 | |
2875 void code_lassign_lvar(int e1,int e2) | |
2876 { | |
2877 | |
2878 } | |
2879 | |
2880 void code_lassign_lregister(int e2,int reg) | |
2881 { | |
2882 | |
2883 } | |
2884 | |
2885 void code_lconst(int e1,int e2) | |
2886 { | |
2887 | |
2888 } | |
2889 | |
2890 void code_lneg(int e1,int e2) | |
2891 { | |
2892 | |
2893 } | |
2894 | |
2895 void code_lrgvar(int e1,int e2) | |
2896 { | |
2897 | |
2898 } | |
2899 | |
2900 void code_lrlvar(int e1,int e2) | |
2901 { | |
2902 | |
2903 } | |
2904 | |
2905 void ltosop(int e1,int e2) | |
2906 { | |
2907 | |
2908 } | |
2909 | |
2910 void emit_lpop_free(int e1) | |
2911 { | |
2912 | |
2913 } | |
2914 | |
2915 void emit_lpush() | |
2916 { | |
2917 | |
2918 } | |
2919 | |
2920 void code_i2ll(int creg) | |
2921 { | |
2922 | |
2923 } | |
2924 | |
2925 void code_i2ull(int creg) | |
2926 { | |
2927 | |
2928 } | |
2929 | |
2930 void code_u2ll(int creg) | |
2931 { | |
2932 | |
2933 } | |
2934 | |
2935 void code_u2ull(int creg) | |
2936 { | |
2937 | |
2938 } | |
2939 | |
2940 void code_ll2i(int creg) | |
2941 { | |
2942 | |
2943 } | |
2944 | |
2945 void code_ll2u(int creg) | |
2946 { | |
2947 | |
2948 } | |
2949 | |
2950 void code_ull2i(int creg) | |
2951 { | |
2952 | |
2953 } | |
2954 | |
2955 void code_ull2u(int creg) | |
2956 { | |
2957 | |
2958 } | |
2959 | |
2960 #if FLOAT_CODE | |
2961 void code_d2ll(int creg) | |
2962 { | |
2963 | |
2964 } | |
2965 | |
2966 void code_d2ull(int creg) | |
2967 { | |
2968 | |
2969 } | |
2970 | |
2971 void code_f2ll(int creg) | |
2972 { | |
2973 | |
2974 } | |
2975 | |
2976 void code_f2ull(int creg) | |
2977 { | |
2978 | |
2979 } | |
2980 | |
2981 void code_ll2d(int creg) | |
2982 { | |
2983 | |
2984 } | |
2985 | |
2986 void code_ll2f(int creg) | |
2987 { | |
2988 | |
2989 } | |
2990 | |
2991 void code_ull2d(int creg) | |
2992 { | |
2993 | |
2994 } | |
2995 | |
2996 void code_ull2f(int creg) | |
2997 { | |
2998 | |
2999 } | |
3000 | |
3001 void code_ull2ll(int creg) | |
3002 { | |
3003 | |
3004 } | |
3005 | |
3006 void code_ull2ull(int creg) | |
3007 { | |
3008 | |
3009 } | |
3010 | |
3011 #endif | |
3012 | |
3013 | |
3014 void code_lpreinc(int e1,int e2,int reg) | |
3015 { | |
3016 | |
3017 } | |
3018 | |
3019 void code_lpostinc(int e1,int e2,int reg) | |
3020 { | |
3021 | |
3022 } | |
3023 | |
3024 void code_lassop(int op) | |
3025 { | |
3026 | |
3027 } | |
3028 | |
3029 | |
3030 #endif | |
3031 | |
2793 /* end */ | 3032 /* end */ |
2794 | 3033 |