comparison mc-code-mips.c @ 253:7b2762739df6

*** empty log message ***
author kono
date Wed, 12 May 2004 19:48:42 +0900
parents 1452eb0eab20
children 5aaca4f9d96b
comparison
equal deleted inserted replaced
252:1452eb0eab20 253:7b2762739df6
92 #define REAL_MAX_LREGISTER 16 92 #define REAL_MAX_LREGISTER 16
93 93
94 #define FREG_OFFSET REAL_MAX_REGISTER 94 #define FREG_OFFSET REAL_MAX_REGISTER
95 #define LREG_OFFSET (REAL_MAX_REGISTER+REAL_MAX_FREGISTER) 95 #define LREG_OFFSET (REAL_MAX_REGISTER+REAL_MAX_FREGISTER)
96 96
97 int MAX_INPUT_REGISTER_VAR = 7-MIN_TMP_REG; 97 int MAX_INPUT_REGISTER_VAR = 4;
98 int MAX_CODE_INPUT_REGISTER_VAR = 7-MIN_TMP_REG; 98 int MAX_CODE_INPUT_REGISTER_VAR = 7-MIN_TMP_REG;
99 int MAX_INPUT_DREGISTER_VAR = 2; 99 int MAX_INPUT_DREGISTER_VAR = 2;
100 int MAX_INPUT_FREGISTER_VAR = 1; 100 int MAX_INPUT_FREGISTER_VAR = 1;
101 int MAX_CODE_INPUT_DREGISTER_VAR = 14-MIN_TMP_FREG; 101 int MAX_CODE_INPUT_DREGISTER_VAR = 14-MIN_TMP_FREG;
102 int MAX_CODE_INPUT_FREGISTER_VAR = 14-MIN_TMP_FREG; 102 int MAX_CODE_INPUT_FREGISTER_VAR = 14-MIN_TMP_FREG;
691 int 691 int
692 get_input_dregister_var(int i,NMTBL *n,int is_code,int d) 692 get_input_dregister_var(int i,NMTBL *n,int is_code,int d)
693 { 693 {
694 int j; 694 int j;
695 if (d) { 695 if (d) {
696 if (i<0||i>=MAX_INPUT_DREGISTER_VAR) return 0; 696 // if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0;
697 j = get_input_lregister_var(i,n,is_code); 697 j = get_input_lregister_var(i,n,is_code);
698 if (car(j)==LREGISTER) { 698 if (car(j)==LREGISTER) {
699 if (regs[cadr(j)]==INPUT_REG) regs[cadr(j)]=INPUT_DREG; 699 if (regs[cadr(j)]==INPUT_REG) regs[cadr(j)]=INPUT_DREG;
700 car(j) = DREGISTER; 700 car(j) = DREGISTER;
701 } 701 }
1137 } 1137 }
1138 1138
1139 1139
1140 void 1140 void
1141 code_lnot(int creg) { 1141 code_lnot(int creg) {
1142 int dreg = get_register();
1142 use_int(creg); 1143 use_int(creg);
1143 int dreg = get_register(); 1144
1144 printf("\txori %s,%s,0x0\n", 1145 printf("\txori %s,%s,0x0\n",
1145 register_name(dreg),register_name(creg)); 1146 register_name(dreg),register_name(creg));
1146 printf("\tsltu %s,%s,1\n", 1147 printf("\tsltu %s,%s,1\n",
1147 register_name(creg),register_name(dreg)); 1148 register_name(creg),register_name(dreg));
1148 free_register(dreg); 1149 free_register(dreg);
1828 continue; 1829 continue;
1829 } else if (t==LONGLONG||t==ULONGLONG||t==DOUBLE) { 1830 } else if (t==LONGLONG||t==ULONGLONG||t==DOUBLE) {
1830 if (reg_arg>=MAX_INPUT_REGISTER_VAR) { 1831 if (reg_arg>=MAX_INPUT_REGISTER_VAR) {
1831 arg = list2(LVAR,caller_arg_offset_v(nargs)); 1832 arg = list2(LVAR,caller_arg_offset_v(nargs));
1832 } else if (!simple_args(e3) && cadr(e3)) { 1833 } else if (!simple_args(e3) && cadr(e3)) {
1833 arg = get_lregister_var(0); 1834 arg = t==DOUBLE?get_dregister_var(0,1):get_lregister_var(0);
1834 arg_assign = list2( 1835 arg_assign = list2(
1835 assign_expr0(r0= 1836 assign_expr0(r0=
1836 (t==DOUBLE? 1837 (t==DOUBLE?
1837 get_input_dregister_var(reg_arg,0,0,1): 1838 get_input_dregister_var(reg_arg,0,0,1):
1838 get_input_lregister_var(reg_arg,0,0) 1839 get_input_lregister_var(reg_arg,0,0)
1839 ), 1840 ),
1840 arg,t,t), 1841 arg,t,t),
1841 arg_assign); 1842 arg_assign);
1842 use_input_reg(cadr(r0),1); 1843 use_input_reg(cadr(r0),1);
1843 } else { 1844 } else {
1844 if (t==DOUBLE) 1845 arg = t==DOUBLE?get_input_dregister_var(reg_arg,0,0,1):
1845 arg=get_input_dregister_var(reg_arg,0,0,1); 1846 get_input_lregister_var(reg_arg,0,0);
1846 else
1847 arg=get_input_lregister_var(reg_arg,0,0);
1848 use_input_reg(cadr(arg),1); 1847 use_input_reg(cadr(arg),1);
1849 } 1848 }
1850 reg_arg_list = list2(arg,reg_arg_list); 1849 reg_arg_list = list2(arg,reg_arg_list);
1851 g_expr_u(assign_expr0(arg,e4,t,t)); 1850 g_expr_u(assign_expr0(arg,e4,t,t));
1852 nargs ++ ; reg_arg++; 1851 nargs ++ ; reg_arg++;
1854 continue; 1853 continue;
1855 } else if (t==FLOAT) { 1854 } else if (t==FLOAT) {
1856 if (freg_arg>=MAX_INPUT_FREGISTER_VAR) { 1855 if (freg_arg>=MAX_INPUT_FREGISTER_VAR) {
1857 arg = list2(LVAR,caller_arg_offset_v(nargs)); 1856 arg = list2(LVAR,caller_arg_offset_v(nargs));
1858 } else if (!simple_args(e3) && cadr(e3)) { 1857 } else if (!simple_args(e3) && cadr(e3)) {
1859 arg = get_dregister_var(0,1); 1858 arg = get_dregister_var(0,0);
1860 if (freg_arg<2) { 1859 if (freg_arg<2) {
1861 arg_assign = list2( 1860 arg_assign = list2(
1862 list3(FASS_INPUT, 1861 list3(FASS_INPUT,
1863 get_input_dregister_var(freg_arg,0,0,1),arg), 1862 get_input_dregister_var(freg_arg,0,0,0),arg),
1864 arg_assign); 1863 arg_assign);
1865 } else { 1864 } else {
1866 arg_assign = list2( 1865 arg_assign = list2(
1867 assign_expr0(get_input_dregister_var(freg_arg,0,0,1), 1866 assign_expr0(get_input_dregister_var(freg_arg,0,0,0),
1868 arg,t,t), 1867 arg,t,t),
1869 arg_assign); 1868 arg_assign);
1870 } 1869 }
1871 } else { 1870 } else {
1872 arg = get_input_dregister_var(freg_arg,0,0,1); 1871 arg = get_input_dregister_var(freg_arg,0,0,0);
1873 } 1872 }
1874 reg_arg_list = list2(arg,reg_arg_list); 1873 reg_arg_list = list2(arg,reg_arg_list);
1875 if (car(arg)==FREGISTER) { 1874 if (car(arg)==FREGISTER) {
1876 use_input_reg(cadr(arg),1);/* protect from input register free */ 1875 use_input_reg(cadr(arg),1);/* protect from input register free */
1877 g_expr_u(assign_expr0(arg,e4,t,t)); /* XXX */ 1876 g_expr_u(assign_expr0(arg,e4,t,t)); /* XXX */
3283 char *crn; 3282 char *crn;
3284 char *frn; 3283 char *frn;
3285 int edx,edx0; 3284 int edx,edx0;
3286 3285
3287 if (!d) { 3286 if (!d) {
3288 int xreg=emit_dpop(d); 3287 xreg=emit_dpop(d);
3289 crn=register_name(ireg); 3288 crn=register_name(ireg);
3290 use_float(d,reg); 3289 use_float(d,reg);
3291 frn =fregister_name(reg); 3290 frn =fregister_name(reg);
3292 3291
3293 printf("\tl.s %s,0(%s)\n",frn,crn); 3292 printf("\tl.s %s,0(%s)\n",frn,crn);