From 03487391646849f8fb194448043951d6cf591931 Mon Sep 17 00:00:00 2001 From: cuz Date: Tue, 26 Nov 2002 18:27:09 +0000 Subject: [PATCH] New --register-space option git-svn-id: svn://svn.cc65.org/cc65/trunk@1653 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/function.c | 7 ++----- src/cc65/global.c | 3 ++- src/cc65/global.h | 3 ++- src/cc65/main.c | 15 ++++++++++++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/cc65/function.c b/src/cc65/function.c index edf795b8d..09ed488e7 100644 --- a/src/cc65/function.c +++ b/src/cc65/function.c @@ -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; } diff --git a/src/cc65/global.c b/src/cc65/global.c index 2a762f922..798c8569f 100644 --- a/src/cc65/global.c +++ b/src/cc65/global.c @@ -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 */ diff --git a/src/cc65/global.h b/src/cc65/global.h index 27e839558..b7cc5a5dc 100644 --- a/src/cc65/global.h +++ b/src/cc65/global.h @@ -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 */ diff --git a/src/cc65/main.c b/src/cc65/main.c index c79f52acf..28ba50dd8 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -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 },