]> git.gag.com Git - fw/sdcc/blobdiff - src/z80/main.c
* Optimised many of the library functions
[fw/sdcc] / src / z80 / main.c
index b73194467e77411bc03e57bf862bcc99681d105f..f27157b28e7b6d9f1f8a26d2e7c7f0a060585c0a 100644 (file)
@@ -68,11 +68,22 @@ _reset_regparm ()
 static int
 _reg_parm (sym_link * l)
 {
-  if (regParmFlg == 2)
-    return 0;
-
-  regParmFlg++;
-  return 1;
+  if (options.noRegParams) 
+    {
+      return FALSE;
+    }
+  else 
+    {
+      if (regParmFlg == 2)
+        {
+          return FALSE;
+        }
+      else
+        {
+          regParmFlg++;
+          return TRUE;
+        }
+    }
 }
 
 static bool
@@ -262,7 +273,7 @@ _setDefaultOptions (void)
   options.mainreturn = 1;
   /* first the options part */
   options.intlong_rent = 1;
-
+  options.noRegParams = 1;
   /* Default code and data locations. */
   options.code_loc = 0x200;
   options.data_loc = 0x8000;
@@ -276,6 +287,46 @@ _setDefaultOptions (void)
   optimize.loopInduction = 0;
 }
 
+/* Mangaling format:
+    _fun_policy_params
+    where:
+      policy is the function policy
+      params is the parameter format
+
+   policy format:
+    rsp
+    where:
+      r is 'r' for reentrant, 's' for static functions
+      s is 'c' for callee saves, 'r' for caller saves
+      p is 'p' for profiling on, 'x' for profiling off
+    examples:
+      rr - reentrant, caller saves
+   params format:
+    A combination of register short names and s to signify stack variables.
+    examples:
+      bds - first two args appear in BC and DE, the rest on the stack
+      s - all arguments are on the stack.
+*/
+static char *
+_mangleSupportFunctionName(char *original)
+{
+  char buffer[128];
+
+  if (TARGET_IS_Z80) 
+    {
+      sprintf(buffer, "%s_rr%s_%s", original,
+              options.profile ? "f" : "x",
+              options.noRegParams ? "s" : "bds"
+              );
+    }
+  else 
+    {
+      strcpy(buffer, original);
+    }
+
+  return gc_strdup(buffer);
+}
+
 static const char *
 _getRegName (struct regs *reg)
 {
@@ -472,6 +523,7 @@ PORT z80_port =
   _reset_regparm,
   _reg_parm,
   _process_pragma,
+  _mangleSupportFunctionName,
   TRUE,
   0,                           /* leave lt */
   0,                           /* leave gt */
@@ -549,6 +601,7 @@ PORT gbz80_port =
   _reset_regparm,
   _reg_parm,
   _process_pragma,
+  NULL,
   TRUE,
   0,                           /* leave lt */
   0,                           /* leave gt */