]> git.sur5r.net Git - cc65/commitdiff
New --register-space option
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 26 Nov 2002 18:27:09 +0000 (18:27 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 26 Nov 2002 18:27:09 +0000 (18:27 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1653 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/cc65/function.c
src/cc65/global.c
src/cc65/global.h
src/cc65/main.c

index edf795b8d6bb514bf314b995d8fdee5859f02597..09ed488e7ac25d6736aa3e9056c96ead0a2d79d8 100644 (file)
@@ -60,9 +60,6 @@
 
 
 
-/* Maximum register variable size */
-#define MAX_REG_SPACE   6
-
 /* Structure that holds all data needed for function activation */
 struct Function {
     struct SymEntry*           FuncEntry;      /* Symbol table entry */
@@ -98,7 +95,7 @@ static Function* NewFunction (struct SymEntry* Sym)
     F->Reserved          = 0;
     F->RetLab    = GetLocalLabel ();
     F->TopLevelSP = 0;
-    F->RegOffs    = MAX_REG_SPACE;
+    F->RegOffs    = RegisterSpace;
 
     /* Return the new structure */
     return F;
@@ -260,7 +257,7 @@ static void F_RestoreRegVars (Function* F)
     const SymEntry* Sym;
 
     /* If we don't have register variables in this function, bail out early */
-    if (F->RegOffs == MAX_REG_SPACE) {
+    if (F->RegOffs == RegisterSpace) {
                return;
     }
 
index 2a762f9223ea2ed83ab7361fc5bef170ac49bd67..798c8569fac625cb3afc216fb785946383b75050 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2001 Ullrich von Bassewitz                                       */
+/* (C) 1998-2002 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
 /* EMail:        uz@cc65.org                                                 */
@@ -52,6 +52,7 @@ unsigned char FavourSize      = 1;    /* Favour size over speed */
 unsigned      CodeSizeFactor   = 100;  /* Size factor for generated code */
 unsigned char InlineStdFuncs   = 0;    /* Inline some known functions */
 unsigned char EnableRegVars    = 0;    /* Enable register variables */
+unsigned      RegisterSpace     = 6;    /* Space available for register vars */
 unsigned char AllowRegVarAddr  = 0;    /* Allow taking addresses of register vars */
 unsigned char RegVarsToCallStack= 0;           /* Save reg variables on call stack */
 unsigned char StaticLocals     = 0;    /* Make local variables static */
index 27e83955821a4cdfc96c176c5a198aaf479c457a..b7cc5a5dc1589705bcdf952ae8a7d02f94661427 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2001 Ullrich von Bassewitz                                       */
+/* (C) 1998-2002 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
 /* EMail:        uz@cc65.org                                                 */
@@ -53,6 +53,7 @@ extern unsigned char  FavourSize;             /* Favour size over speed */
 extern unsigned                CodeSizeFactor;         /* Size factor for generated code */
 extern unsigned char    InlineStdFuncs;                /* Inline some known functions */
 extern unsigned char   EnableRegVars;          /* Enable register variables */
+extern unsigned         RegisterSpace;          /* Space available for register vars */
 extern unsigned char   AllowRegVarAddr;        /* Allow taking addresses of register vars */
 extern unsigned char   RegVarsToCallStack;     /* Save reg variables on call stack */
 extern unsigned char           StaticLocals;           /* Make local variables static */
index c79f52acf325d09102b4c7b28e0712dd99032f45..28ba50dd830b3e0550be2f296ae62e0a11b26390 100644 (file)
@@ -113,6 +113,7 @@ static void Usage (void)
             "  --help\t\tHelp (this text)\n"
                     "  --include-dir dir\tSet an include directory search path\n"
             "  --list-opt-steps\tList all optimizer steps and exit\n"
+             "  --register-space b\tSet space available for register variables\n"
              "  --register-vars\tEnable register variables\n"
                     "  --rodata-name seg\tSet the name of the RODATA segment\n"
                     "  --signed-chars\tDefault characters are signed\n"
@@ -530,7 +531,18 @@ static void OptListOptSteps (const char* Opt attribute ((unused)),
 
 
 
-static void OptRegisterVars (const char* Opt attribute ((unused)), 
+static void OptRegisterSpace (const char* Opt, const char* Arg)
+/* Handle the --register-space option */
+{
+    /* Numeric argument expected */
+    if (sscanf (Arg, "%u", &RegisterSpace) != 1 || RegisterSpace > 256) {
+               AbEnd ("Argument for option %s is invalid", Opt);
+    }
+}
+
+
+
+static void OptRegisterVars (const char* Opt attribute ((unused)),
                              const char* Arg attribute ((unused)))
 /* Handle the --register-vars option */
 {
@@ -618,6 +630,7 @@ int main (int argc, char* argv[])
        { "--help",             0,      OptHelp                 },
        { "--include-dir",      1,      OptIncludeDir           },
        { "--list-opt-steps",   0,      OptListOptSteps         },
+        { "--register-space",   1,      OptRegisterSpace        },
         { "--register-vars",    0,      OptRegisterVars         },
        { "--rodata-name",      1,      OptRodataName           },
        { "--signed-chars",     0,      OptSignedChars          },