diff mc-code-ia32.c @ 137:9fb09db54436

fix powerpc get_fregister_var's regs error.
author kono
date Sun, 04 May 2003 22:08:20 +0900
parents 069960078249
children e6e77af048a1
line wrap: on
line diff
--- a/mc-code-ia32.c	Sun May 04 15:10:41 2003 +0900
+++ b/mc-code-ia32.c	Sun May 04 22:08:20 2003 +0900
@@ -255,14 +255,14 @@
 }
 
 int
-free_register_count(void)
+free_register_count(int d)
 {
     int i,count;
     count = 0;
     for(i=0;i<MAX_REGISTER;i++) {
 	if (! regs[i] && ! regv[i]) count++;
     }
-    return count;    
+    return d?0:count;    
 }
 
 void
@@ -304,8 +304,41 @@
 }
 
 void
-code_arg_register()
+code_arg_register(NMTBL *fnptr)
 {
+    int args = fnptr->dsp;
+    NMTBL *n;
+    int reg_var = 0;
+    int freg_var = 0;
+    int type;
+    int reg;
+    int is_code0 = is_code(fnptr);
+
+    while (args) {
+        /* process in reverse order */
+        n = (NMTBL*)caddr(args);
+        type = n->ty;
+        if (scalar(type)) {
+            if ((reg = get_input_register_var(reg_var,n,is_code0))) {
+                n->sc = REGISTER;
+                n->dsp = cadr(reg);
+                regv[n->dsp]= 1;
+                regs[n->dsp]= INPUT_REG;
+                reg_var++;
+                cadddr(args)=size_of_int; /* why we need this? */
+            }
+        } else if (type==FLOAT||type==DOUBLE) {
+            if ((reg = get_input_fregister_var(freg_var,n,is_code0))) {
+                n->sc = DREGISTER;
+                n->dsp = cadr(reg);
+                fregv[n->dsp]= 1;
+                fregs[n->dsp]= INPUT_REG;
+                freg_var++;
+                cadddr(args)=size(type); /* why we need this? */
+            }
+        }
+        args = cadr(args);
+    }
 }
 
 void 
@@ -384,6 +417,12 @@
     return list2(LVAR,new_lvar(size_of_double));
 }
 
+int
+get_dregister_var(NMTBL *nptr)
+{
+    return get_fregister_var(nptr);
+}
+
 void 
 use_register(int virt, int real, int move)
 {
@@ -943,7 +982,7 @@
 #ifdef SAVE_STACKS
     code_save_stacks();
 #endif
-    if (free_register_count()<1) {
+    if (free_register_count(0)<1) {
         for(save = 0;save==dreg||save==creg;save++);
 	printf("\tpushl %s\n",register_name(save,0));
         saved = 1;
@@ -1211,7 +1250,7 @@
 {
     int edx_save;
     /* make real EDX register empty */
-    if (free_register_count()<1) {
+    if (free_register_count(0)<1) {
         for(edx_save = 0;edx_save==dreg||edx_save==creg;edx_save++);
 	printf("\tpushl %s\n",register_name(edx_save,0));
         edx_stack = list3(edx_save,edx_stack,0);