From c1b6680a92b6e9d3d3e87d8dcd6ae6f11ead8cf5 Mon Sep 17 00:00:00 2001 From: cuz Date: Mon, 21 May 2001 06:43:46 +0000 Subject: [PATCH] Working git-svn-id: svn://svn.cc65.org/cc65/trunk@737 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/asmcode.c | 8 -------- src/cc65/asmcode.h | 3 --- src/cc65/codegen.c | 39 ++++++++++++++++++++++++++++++++++----- src/cc65/codegen.h | 5 ++++- src/cc65/codeinfo.c | 11 +++++++---- src/cc65/expr.c | 7 ------- src/cc65/main.c | 3 --- src/cc65/pragma.c | 25 ++++++++++++++----------- src/cc65/stmt.c | 3 --- 9 files changed, 59 insertions(+), 45 deletions(-) diff --git a/src/cc65/asmcode.c b/src/cc65/asmcode.c index b139af1c8..dda8ed81b 100644 --- a/src/cc65/asmcode.c +++ b/src/cc65/asmcode.c @@ -52,14 +52,6 @@ -void AddCodeHint (const char* Hint) -/* Add an optimizer hint */ -{ - /* ### AddCodeLine ("+%s", Hint); */ -} - - - CodeMark GetCodePos (void) /* Get a marker pointing to the current output position */ { diff --git a/src/cc65/asmcode.h b/src/cc65/asmcode.h index a7845191d..47ea65586 100644 --- a/src/cc65/asmcode.h +++ b/src/cc65/asmcode.h @@ -62,9 +62,6 @@ typedef unsigned CodeMark; -void AddCodeHint (const char* Hint); -/* Add an optimizer hint */ - CodeMark GetCodePos (void); /* Get a marker pointing to the current output position */ diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index 1cafa0c28..49afa5b60 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -203,8 +203,41 @@ void g_usebss (void) +static void OutputDataLine (DataSeg* S, const char* Format, ...) +/* Add a line to the current data segment */ +{ + va_list ap; + va_start (ap, Format); + AddDataEntry (S, Format, ap); + va_end (ap); +} + + + +void g_segname (segment_t Seg, const char* Name) +/* Set the name of a segment */ +{ + DataSeg* S; + + /* Remember the new name */ + NewSegName (Seg, Name); + + /* Emit a segment directive for the data style segments */ + switch (Seg) { + case SEG_RODATA: S = CS->ROData; break; + case SEG_DATA: S = CS->Data; break; + case SEG_BSS: S = CS->BSS; break; + default: S = 0; break; + } + if (S) { + OutputDataLine (S, ".segment\t\"%s\"", Name); + } +} + + + /*****************************************************************************/ -/* Code */ +/* Code */ /*****************************************************************************/ @@ -3207,8 +3240,6 @@ void g_inc (unsigned flags, unsigned long val) AddCodeLine ("clc"); if ((val & 0xFF) != 0) { AddCodeLine ("adc #$%02X", (unsigned char) val); - /* Tell the optimizer that the X register may be invalid */ - AddCodeHint ("x:!"); } AddCodeLine ("pha"); AddCodeLine ("txa"); @@ -3294,8 +3325,6 @@ void g_dec (unsigned flags, unsigned long val) AddCodeLine ("sec"); if ((val & 0xFF) != 0) { AddCodeLine ("sbc #$%02X", (unsigned char) val); - /* Tell the optimizer that the X register may be invalid */ - AddCodeHint ("x:!"); } AddCodeLine ("pha"); AddCodeLine ("txa"); diff --git a/src/cc65/codegen.h b/src/cc65/codegen.h index 7a37c98d3..a82534580 100644 --- a/src/cc65/codegen.h +++ b/src/cc65/codegen.h @@ -112,10 +112,13 @@ void g_usedata (void); void g_usebss (void); /* Switch to the bss segment */ +void g_segname (segment_t Seg, const char* Name); +/* Set the name of a segment */ + /*****************************************************************************/ -/* Functions handling local labels */ +/* Functions handling local labels */ /*****************************************************************************/ diff --git a/src/cc65/codeinfo.c b/src/cc65/codeinfo.c index 0bbeffad1..c99ee491c 100644 --- a/src/cc65/codeinfo.c +++ b/src/cc65/codeinfo.c @@ -148,9 +148,10 @@ void GetFuncInfo (const char* Name, unsigned char* Use, unsigned char* Chg) if (E && E->Owner->PrevTab == 0 && IsTypeFunc (E->Type)) { /* A function may use the A or A/X registers if it is a fastcall - * function. Otherwise it does not use any registers passed by - * the caller. However, we assume that any function will destroy - * all registers. + * function. If it is not a fastcall function but a variadic one, + * it will use the Y register (the parameter size is passed here). + * In all other cases, no registers are used. However, we assume + * that any function will destroy all registers. */ FuncDesc* D = E->V.F.Func; if ((D->Flags & FD_FASTCALL) != 0 && D->ParamCount > 0) { @@ -161,7 +162,9 @@ void GetFuncInfo (const char* Name, unsigned char* Use, unsigned char* Chg) } else { *Use = REG_AX; } - } else { + } else if ((D->Flags & FD_VARIADIC) != 0) { + *Use = REG_Y; + } else { /* Will not use any registers */ *Use = REG_NONE; } diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 5e3f1f93c..b5441dfd6 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -502,7 +502,6 @@ void exprhs (unsigned flags, int k, struct expent *lval) } if (lval->e_test & E_FORCETEST) { /* we testing this value? */ /* debug... */ - AddCodeHint ("forcetest"); flags |= TypeOf (lval->e_tptr); g_test (flags); /* yes, force a test */ lval->e_test &= ~E_FORCETEST; @@ -569,9 +568,6 @@ static unsigned FunctionParamList (FuncDesc* Func) unsigned CFlags; unsigned Flags; - /* Add a hint for the optimizer */ - AddCodeHint ("param:start"); - /* Count arguments */ ++ParamCount; @@ -659,9 +655,6 @@ static unsigned FunctionParamList (FuncDesc* Func) ParamSize += ArgSize; } - /* Add an optimizer hint */ - AddCodeHint ("param:end"); - /* Check for end of argument list */ if (curtok != TOK_COMMA) { break; diff --git a/src/cc65/main.c b/src/cc65/main.c index 874e9b4b1..28ed29066 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -646,9 +646,6 @@ int main (int argc, char* argv[]) OutputFile = MakeFilename (InputFile, ".s"); } - - - /* Go! */ Compile (); diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 4f51995d6..ba3815d96 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -37,6 +37,7 @@ #include /* cc65 */ +#include "codegen.h" #include "error.h" #include "expr.h" #include "global.h" @@ -49,7 +50,7 @@ /*****************************************************************************/ -/* data */ +/* data */ /*****************************************************************************/ @@ -150,7 +151,7 @@ static void SegNamePragma (segment_t Seg) if (ValidSegName (Name)) { /* Set the new name */ - NewSegName (Seg, Name); + g_segname (Seg, Name); } else { @@ -196,19 +197,21 @@ void DoPragma (void) return; } - /* Do we know this pragma? */ + /* Search for the name, then skip the identifier */ Pragma = FindPragma (CurTok.Ident); + NextToken (); + + /* Do we know this pragma? */ if (Pragma == PR_ILLEGAL) { - /* According to the ANSI standard, we're not allowed to generate errors - * for unknown pragmas, however, we're allowed to warn - and we will - * do so. Otherwise one typo may give you hours of bug hunting... - */ - Warning ("Unknown #pragma `%s'", CurTok.Ident); - return; + /* According to the ANSI standard, we're not allowed to generate errors + * for unknown pragmas, however, we're allowed to warn - and we will + * do so. Otherwise one typo may give you hours of bug hunting... + */ + Warning ("Unknown #pragma `%s'", CurTok.Ident); + return; } - /* Skip the identifier and check for an open paren */ - NextToken (); + /* Check for an open paren */ ConsumeLParen (); /* Switch for the different pragmas */ diff --git a/src/cc65/stmt.c b/src/cc65/stmt.c index cad1f866d..2e1c05b98 100644 --- a/src/cc65/stmt.c +++ b/src/cc65/stmt.c @@ -523,7 +523,6 @@ static void tableswitch (struct expent* eval) g_defdata (CF_INT | CF_CONST, -((int)lcount)-1, 0); /* Create the case selector table */ - AddCodeHint ("casetable"); p = swtab; while (lcount) { g_case (Flags, p->sw_lab, p->sw_const); /* Create one label */ @@ -734,9 +733,7 @@ int Statement (void) break; default: - AddCodeHint ("stmt:start"); expression (&lval); - AddCodeHint ("stmt:end"); ConsumeSemi (); } } -- 2.39.5