diff mc-codegen.c @ 103:f849af4b5ea9

*** empty log message ***
author kono
date Mon, 17 Mar 2003 14:26:22 +0900
parents 3cf2f8c120b9
children c21aeb12b78b
line wrap: on
line diff
--- a/mc-codegen.c	Sat Mar 15 21:55:14 2003 +0900
+++ b/mc-codegen.c	Mon Mar 17 14:26:22 2003 +0900
@@ -446,7 +446,47 @@
 void
 arg_register(NMTBL *fnptr)
 {
-    code_arg_register(fnptr->dsp);
+    int args = fnptr->dsp;
+    NMTBL *n;
+    int reg_var = 0;
+    int freg_var = 0;
+    int type;
+    int max_input_register_var;
+    int max_input_fregister_var;
+
+    if (is_function(fnptr)) {
+	max_input_register_var = MAX_INPUT_REGISTER_VAR;
+	max_input_fregister_var = MAX_INPUT_DREGISTER_VAR;
+    } else {
+	max_input_register_var = MAX_CODE_INPUT_REGISTER_VAR;
+	max_input_fregister_var = MAX_CODE_INPUT_DREGISTER_VAR;
+    }
+
+    while (args) {
+	/* process in reverse order */
+        n = (NMTBL*)caddr(args);
+	type = n->ty;
+        if (scalar(type)) {
+            if(reg_var<max_input_register_var) {
+                n->sc = REGISTER;
+		if ((n->dsp = get_input_register_var(reg_var++)) <0) {
+		    error(-1); return;
+		}
+                reg_var++;
+                cadddr(fnptr->dsp)=size_of_int;
+            }
+        } else if ((type==FLOAT||type==DOUBLE)&&stmode==REGISTER) {
+            if(freg_var<max_input_fregister_var) {
+                n->sc = DREGISTER;
+		if ((n->dsp = get_input_fregister_var(freg_var++)) <0) {
+		    error(-1); return;
+		}
+                freg_var++;
+                cadddr(fnptr->dsp)=size_of_double;
+            }
+        }
+	args = cadr(args);
+    }
 }
 
 /* goto arguments list                                      */
@@ -673,10 +713,12 @@
     fregs = 0;
     for (e3 = reverse0(caddr(e1)); e3; e3 = cadr(e3)) {	
 	e2 = car(e3); sz = size(ty=caddr(e3)); 
-	if (scalar(ty) && regs < max_input_register_var&&sz==size_of_int) {
+	if (scalar(ty) && 
+		regs < MAX_CODE_INPUT_REGISTER_VAR) {
 	    target=list4(list2(REGISTER,get_input_register_var(regs++)), 
 		    target,ty,e2);
-	} else if ((ty==DOUBLE||ty==FLOAT) && fregs < max_input_fregister_var) {
+	} else if ((ty==DOUBLE||ty==FLOAT) && 
+		fregs < MAX_CODE_INPUT_DREGISTER_VAR) {
 	    target=list4(list2(DREGISTER,get_input_fregister_var(fregs++)), 
 		    target,ty,e2);
 	} else {
@@ -851,11 +893,11 @@
     switch(car(e2)) {
     case GVAR:      /*   i=3 */
             g_expr(e4);
-	    code_assign_gvar(e2,byte);
+	    code_assign_gvar(e2,creg,byte);
             return;
     case LVAR:
             g_expr(e4);
-	    code_assign_lvar(lvar(cadr(e2)),byte);
+	    code_assign_lvar(lvar(cadr(e2)),creg,byte);
             return;
     case REGISTER:
             g_expr(e4);
@@ -886,18 +928,18 @@
     switch(car(e2)) {
     case GVAR:
             g_expr(e4);
-	    code_dassign_gvar(e2,d);
+	    code_dassign_gvar(e2,freg,d);
             return;
     case LVAR:
             g_expr(e4);
-	    code_dassign_lvar(lvar(cadr(e2)),d);
+	    code_dassign_lvar(lvar(cadr(e2)),freg,d);
             return;
     }
     g_expr(e2);
     emit_push();
     g_expr(e4);
     e2 = emit_pop(0);
-    code_dassign(e2,d);
+    code_dassign(e2,freg,d);
     emit_pop_free(e2);
     return;
 }