parameter passing in registers changed to be
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 12 Mar 2000 00:22:58 +0000 (00:22 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 12 Mar 2000 00:22:58 +0000 (00:22 +0000)
port specific. Since AVR will have different
parameter passing ABI.

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@186 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCsymt.c
src/mcs51/main.c
src/port.h
src/z80/main.c

index 0ee7062883b87e3a35c726f78c252dbf9a8378cc..a1965efae840ba43d33259c74ebe2e36e767a36c 100644 (file)
@@ -1379,6 +1379,7 @@ void  processFuncArgs   (symbol *func, int ignoreName)
     value *val ;
     int pNum = 1;   
     
+
     /* if this function has variable argument list */
     /* then make the function a reentrant one     */
     if (func->hasVargs)
@@ -1395,19 +1396,23 @@ void  processFuncArgs   (symbol *func, int ignoreName)
        func->args = NULL ;
        return ;
     }
-    
+
+    /* reset regparm for the port */
+    (*port->reset_regparms)();
     /* if any of the arguments is an aggregate */
     /* change it to pointer to the same type */
     while (val) {
 
        /* mark it as a register parameter if
-          the function does nit have VA_ARG
-          and MAX_REG_PARMS not exceeded &&
+          the function does not have VA_ARG
+          and as port dictates
           not inhibited by command line option or #pragma */
-       if (pNum <= MAX_REG_PARMS && 
+       if (!func->hasVargs       &&        
            !options.noregparms   &&
-           !func->hasVargs)
+           (*port->reg_parm)(val->type)) {
+
            SPEC_REGPARM(val->etype) = 1;
+       }
        
        if ( IS_AGGREGATE(val->type)) {
            /* if this is a structure */
index 80280ccbc07eb0636e6b028f12725888ebad4934..42a8c397d44335c139aca5dedd98ddb86f54eceb 100644 (file)
@@ -44,6 +44,24 @@ static char *_mcs51_keywords[] =     {
 
 void mcs51_assignRegisters (eBBlock **ebbs, int count);
 
+static int regParmFlg = 0; /* determine if we can register a parameter */
+
+static void _mcs51_reset_regparm()
+{
+    regParmFlg = 0;
+}
+
+static int _mcs51_regparm( link *l)
+{
+    /* for this processor it is simple
+       can pass only the first parameter in a register */
+    if (regParmFlg)
+       return 0;
+
+    regParmFlg = 1;
+    return 1;
+}
+
 static bool _mcs51_parseOptions(int *pargc, char **argv, int *i)
 {
     /* TODO: allow port-specific command line options to specify
@@ -220,6 +238,8 @@ PORT mcs51_port = {
     _mcs51_getRegName ,
     _mcs51_keywords,
     _mcs51_genAssemblerPreamble,
-    _mcs51_genIVT
+    _mcs51_genIVT ,
+    _mcs51_reset_regparm,
+    _mcs51_regparm
 };
 
index 8b036313d3c21aee5ce5380a19492c35aa255c84..18fd7660cb91b9701610166e7156d0c522370770 100644 (file)
@@ -126,6 +126,12 @@ typedef struct {
      * will be used. 
      */
     int (*genIVT)(FILE *of, symbol **intTable, int intCount); 
+
+
+    /* parameter passing in register related functions */
+    void (*reset_regparms)();          /* reset the register count */
+    int  (*reg_parm)(struct link *);   /* will return 1 if can be passed in register */
+   
 } PORT;
 
 extern PORT *port;
index b7c4f76b2973d7c6646acbdf6b7f970c23f5f626..e8f4a968b98c938582e108fc6717fa8c2205057d 100644 (file)
@@ -15,6 +15,25 @@ static void _z80_init(void)
     z80_opts.sub = SUB_Z80;
 }
 
+static int regParmFlg = 0; /* determine if we can register a parameter */
+
+static void _z80_reset_regparm()
+{
+    regParmFlg = 0;
+}
+
+static int _z80_reg_parm(link *l)
+{
+        /* for this processor it is simple
+       can pass only the first parameter in a register */
+    if (regParmFlg)
+       return 0;
+
+    regParmFlg = 1;
+    return 1;
+
+}
+
 static bool _z80_parseOptions(int *pargc, char **argv, int *i)
 {
     return FALSE;
@@ -120,5 +139,7 @@ PORT z80_port = {
     _z80_keywords,
     0, /* no assembler preamble */
     0, /* no local IVT generation code */
+    _z80_reset_regparm,
+    _z80_reg_parm
 };