comparison mc-code-powerpc.c @ 305:117baacd1ed0

stdarg powerpc passed except long long (macro problem)
author kono
date Wed, 09 Jun 2004 15:18:32 +0900
parents 9df8aa0497ea
children fda28752d301
comparison
equal deleted inserted replaced
304:9df8aa0497ea 305:117baacd1ed0
228 static int code_l1(long long ll); 228 static int code_l1(long long ll);
229 static int code_l2(long long ll); 229 static int code_l2(long long ll);
230 #endif 230 #endif
231 231
232 static void code_save_stacks(); 232 static void code_save_stacks();
233 static void code_save_input_registers(); 233 static void code_save_input_registers(int dots);
234 static void clear_ptr_cache_reg(int r); 234 static void clear_ptr_cache_reg(int r);
235 static void set_ireg(int,int); 235 static void set_ireg(int,int);
236 static void set_freg(int,int); 236 static void set_freg(int,int);
237 static void set_lreg(int,int); 237 static void set_lreg(int,int);
238 static void jcond(int l, char cond); 238 static void jcond(int l, char cond);
394 char *init_src = "\ 394 char *init_src = "\
395 #define __ppc__ 1\n\ 395 #define __ppc__ 1\n\
396 #define __BIG_ENDIAN__ 1\n\ 396 #define __BIG_ENDIAN__ 1\n\
397 #define __STDC__ 1\n\ 397 #define __STDC__ 1\n\
398 #define __builtin_va_list int\n\ 398 #define __builtin_va_list int\n\
399 #define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
400 #define __builtin_va_arg(ap,type) (*((type *)ap)++)\n\
399 "; 401 ";
400 402
401 void 403 void
402 code_init(void) 404 code_init(void)
403 { 405 {
451 int freg_var = 0; 453 int freg_var = 0;
452 int type; 454 int type;
453 int reg; 455 int reg;
454 int i; 456 int i;
455 int is_code0 = is_code(fnptr); 457 int is_code0 = is_code(fnptr);
456 458 int dots;
459
460 function_type(fnptr->ty,&dots);
457 while (args) { 461 while (args) {
458 /* process in reverse order */ 462 /* process in reverse order */
459 n = (NMTBL*)caddr(args); 463 n = (NMTBL*)caddr(args);
460 type = n->ty; 464 type = n->ty;
461 if (scalar(type)) { 465 if (scalar(type)) {
494 } 498 }
495 } 499 }
496 args = cadr(args); 500 args = cadr(args);
497 } 501 }
498 if (is_function(fnptr)) 502 if (is_function(fnptr))
499 code_save_input_registers(); 503 code_save_input_registers(dots);
500 } 504 }
501 505
502 506
503 int 507 int
504 get_register(void) 508 get_register(void)
1711 regs[regv_h(arg)]=USING_REG; 1715 regs[regv_h(arg)]=USING_REG;
1712 } 1716 }
1713 } 1717 }
1714 1718
1715 void 1719 void
1716 code_save_input_registers() 1720 code_save_input_registers(int dots)
1717 { 1721 {
1718 int args; 1722 int args;
1719 NMTBL *n; 1723 NMTBL *n;
1720 int reg; 1724 int reg;
1721 int tag; 1725 int tag;
1722 int lvar; 1726 int lvar;
1723 int t; 1727 int t;
1724 /* fnptr->dsp=list4(type,fnptr->dsp,(int)n,0); */ 1728 /* fnptr->dsp=list4(type,fnptr->dsp,(int)n,0); */
1725 int reg_offset = 0; 1729 int reg_offset = 0;
1726 int offset = 0; 1730 int offset = 0;
1731 int reg_var = 0;
1727 1732
1728 for(args = fnptr->dsp;args;args = cadr(args)) { 1733 for(args = fnptr->dsp;args;args = cadr(args)) {
1729 n = (NMTBL *)caddr(args); 1734 n = (NMTBL *)caddr(args);
1730 tag = n->sc; 1735 tag = n->sc;
1731 reg = n->dsp; 1736 reg = n->dsp;
1734 /* regs[reg]==INPUT_REG case should be considered */ 1739 /* regs[reg]==INPUT_REG case should be considered */
1735 n->dsp = offset; 1740 n->dsp = offset;
1736 offset+=SIZE_OF_INT; 1741 offset+=SIZE_OF_INT;
1737 t = INT; 1742 t = INT;
1738 reg += reg_offset; /* for duplicated floating point argument */ 1743 reg += reg_offset; /* for duplicated floating point argument */
1744 reg_var++;
1739 } else if (tag==DREGISTER) { 1745 } else if (tag==DREGISTER) {
1740 /* regs[reg]==INPUT_REG case should be considered */ 1746 /* regs[reg]==INPUT_REG case should be considered */
1741 n->dsp = offset; 1747 n->dsp = offset;
1742 t = n->ty; 1748 t = n->ty;
1743 if(t==FLOAT) { offset+=SIZE_OF_FLOAT; reg_offset+=1; } 1749 if(t==FLOAT) { offset+=SIZE_OF_FLOAT; reg_offset+=1; }
1744 else if(t==DOUBLE) { offset+=SIZE_OF_DOUBLE; reg_offset+=2; } 1750 else if(t==DOUBLE) { offset+=SIZE_OF_DOUBLE; reg_offset+=2; }
1745 else error(-1); 1751 else error(-1);
1752 reg_var += 2;
1746 } else if (tag==LREGISTER) { 1753 } else if (tag==LREGISTER) {
1747 /* regs[reg]==INPUT_REG case should be considered */ 1754 /* regs[reg]==INPUT_REG case should be considered */
1748 n->dsp = offset; 1755 n->dsp = offset;
1749 t = n->ty; 1756 t = n->ty;
1750 offset+=SIZE_OF_LONGLONG; reg_offset+=2; 1757 offset+=SIZE_OF_LONGLONG; reg_offset+=2;
1758 reg_var += 2;
1751 } else { 1759 } else {
1752 offset += size(n->ty); 1760 offset += size(n->ty);
1753 continue; 1761 continue;
1754 } 1762 }
1755 n->sc = LVAR; 1763 n->sc = LVAR;
1756 lvar = list2(LVAR,n->dsp); 1764 lvar = list2(LVAR,n->dsp);
1757 g_expr_u(assign_expr0(list2(LVAR,n->dsp),list3(tag,reg,(int)n),n->ty,t)); 1765 g_expr_u(assign_expr0(
1766 list2(LVAR,n->dsp),list3(tag,reg,(int)n),n->ty,t));
1758 if (tag==REGISTER||tag==DREGISTER||tag==FREGISTER||tag==LREGISTER) { 1767 if (tag==REGISTER||tag==DREGISTER||tag==FREGISTER||tag==LREGISTER) {
1759 free_register(reg); 1768 free_register(reg);
1769 }
1770 }
1771 if (dots) {
1772 while ((reg = get_input_register_var(reg_var,0,0))) {
1773 g_expr_u(assign_expr0(
1774 list2(LVAR,offset),reg,INT,INT));
1775 offset+=SIZE_OF_INT;
1776 reg_var++;
1760 } 1777 }
1761 } 1778 }
1762 my_func_args = offset; 1779 my_func_args = offset;
1763 } 1780 }
1764 1781
1916 int complex_; 1933 int complex_;
1917 int pnargs,preg_arg,pfreg_arg; 1934 int pnargs,preg_arg,pfreg_arg;
1918 int stargs; 1935 int stargs;
1919 1936
1920 special_lvar = -1; 1937 special_lvar = -1;
1938 #if 0
1921 ret_type = cadr(cadddr(e1)); 1939 ret_type = cadr(cadddr(e1));
1922 if (ret_type==CHAR) ret_type=INT; 1940 if (ret_type==CHAR) ret_type=INT;
1923 1941
1924 /* check argments type is DOTS? */ 1942 /* check argments type is DOTS? */
1925 t = caddr(cadddr(e1)); 1943 t = caddr(cadddr(e1));
1928 dots = 0; 1946 dots = 0;
1929 for(t = caddr(cadddr(e1));t;t = cadr(t)) { 1947 for(t = caddr(cadddr(e1));t;t = cadr(t)) {
1930 if (car(t)==DOTS) dots = 1; 1948 if (car(t)==DOTS) dots = 1;
1931 } 1949 }
1932 } 1950 }
1951 #else
1952 ret_type = function_type(cadddr(e1),&dots);
1953 #endif
1933 1954
1934 arg_assign = 0; 1955 arg_assign = 0;
1935 e2 = cadr(e1); 1956 e2 = cadr(e1);
1936 if (car(e2) == FNAME) { 1957 if (car(e2) == FNAME) {
1937 fn=(NMTBL *)cadr(e2); 1958 fn=(NMTBL *)cadr(e2);