Added support for gsinit packing.
[fw/sdcc] / src / z80 / main.c
index b73194467e77411bc03e57bf862bcc99681d105f..f60636d7503425672f70761478c0fe0d3f1d60a3 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;
@@ -273,7 +284,47 @@ _setDefaultOptions (void)
   optimize.label3 = 1;
   optimize.label4 = 1;
   optimize.loopInvariant = 1;
-  optimize.loopInduction = 0;
+  optimize.loopInduction = 1;
+}
+
+/* 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 *
@@ -472,6 +523,7 @@ PORT z80_port =
   _reset_regparm,
   _reg_parm,
   _process_pragma,
+  _mangleSupportFunctionName,
   TRUE,
   0,                           /* leave lt */
   0,                           /* leave gt */
@@ -479,6 +531,7 @@ PORT z80_port =
   1,                           /* transform >= to ! < */
   1,                           /* transform != to !(a == b) */
   0,                           /* leave == */
+  TRUE,                         /* Array initializer support. */       
   PORT_MAGIC
 };
 
@@ -549,6 +602,7 @@ PORT gbz80_port =
   _reset_regparm,
   _reg_parm,
   _process_pragma,
+  NULL,
   TRUE,
   0,                           /* leave lt */
   0,                           /* leave gt */
@@ -556,5 +610,6 @@ PORT gbz80_port =
   1,                           /* transform >= to ! < */
   1,                           /* transform != to !(a == b) */
   0,                           /* leave == */
+  FALSE,                        /* No array initializer support. */
   PORT_MAGIC
 };