Working
git-svn-id: svn://svn.cc65.org/cc65/trunk@737 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -52,14 +52,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AddCodeHint (const char* Hint)
|
|
||||||
/* Add an optimizer hint */
|
|
||||||
{
|
|
||||||
/* ### AddCodeLine ("+%s", Hint); */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CodeMark GetCodePos (void)
|
CodeMark GetCodePos (void)
|
||||||
/* Get a marker pointing to the current output position */
|
/* Get a marker pointing to the current output position */
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,9 +62,6 @@ typedef unsigned CodeMark;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AddCodeHint (const char* Hint);
|
|
||||||
/* Add an optimizer hint */
|
|
||||||
|
|
||||||
CodeMark GetCodePos (void);
|
CodeMark GetCodePos (void);
|
||||||
/* Get a marker pointing to the current output position */
|
/* Get a marker pointing to the current output position */
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
AddCodeLine ("clc");
|
||||||
if ((val & 0xFF) != 0) {
|
if ((val & 0xFF) != 0) {
|
||||||
AddCodeLine ("adc #$%02X", (unsigned char) val);
|
AddCodeLine ("adc #$%02X", (unsigned char) val);
|
||||||
/* Tell the optimizer that the X register may be invalid */
|
|
||||||
AddCodeHint ("x:!");
|
|
||||||
}
|
}
|
||||||
AddCodeLine ("pha");
|
AddCodeLine ("pha");
|
||||||
AddCodeLine ("txa");
|
AddCodeLine ("txa");
|
||||||
@@ -3294,8 +3325,6 @@ void g_dec (unsigned flags, unsigned long val)
|
|||||||
AddCodeLine ("sec");
|
AddCodeLine ("sec");
|
||||||
if ((val & 0xFF) != 0) {
|
if ((val & 0xFF) != 0) {
|
||||||
AddCodeLine ("sbc #$%02X", (unsigned char) val);
|
AddCodeLine ("sbc #$%02X", (unsigned char) val);
|
||||||
/* Tell the optimizer that the X register may be invalid */
|
|
||||||
AddCodeHint ("x:!");
|
|
||||||
}
|
}
|
||||||
AddCodeLine ("pha");
|
AddCodeLine ("pha");
|
||||||
AddCodeLine ("txa");
|
AddCodeLine ("txa");
|
||||||
|
|||||||
@@ -112,10 +112,13 @@ void g_usedata (void);
|
|||||||
void g_usebss (void);
|
void g_usebss (void);
|
||||||
/* Switch to the bss segment */
|
/* 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 */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -148,9 +148,10 @@ void GetFuncInfo (const char* Name, unsigned char* Use, unsigned char* Chg)
|
|||||||
if (E && E->Owner->PrevTab == 0 && IsTypeFunc (E->Type)) {
|
if (E && E->Owner->PrevTab == 0 && IsTypeFunc (E->Type)) {
|
||||||
|
|
||||||
/* A function may use the A or A/X registers if it is a fastcall
|
/* 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
|
* function. If it is not a fastcall function but a variadic one,
|
||||||
* the caller. However, we assume that any function will destroy
|
* it will use the Y register (the parameter size is passed here).
|
||||||
* all registers.
|
* In all other cases, no registers are used. However, we assume
|
||||||
|
* that any function will destroy all registers.
|
||||||
*/
|
*/
|
||||||
FuncDesc* D = E->V.F.Func;
|
FuncDesc* D = E->V.F.Func;
|
||||||
if ((D->Flags & FD_FASTCALL) != 0 && D->ParamCount > 0) {
|
if ((D->Flags & FD_FASTCALL) != 0 && D->ParamCount > 0) {
|
||||||
@@ -161,6 +162,8 @@ void GetFuncInfo (const char* Name, unsigned char* Use, unsigned char* Chg)
|
|||||||
} else {
|
} else {
|
||||||
*Use = REG_AX;
|
*Use = REG_AX;
|
||||||
}
|
}
|
||||||
|
} else if ((D->Flags & FD_VARIADIC) != 0) {
|
||||||
|
*Use = REG_Y;
|
||||||
} else {
|
} else {
|
||||||
/* Will not use any registers */
|
/* Will not use any registers */
|
||||||
*Use = REG_NONE;
|
*Use = REG_NONE;
|
||||||
|
|||||||
@@ -502,7 +502,6 @@ void exprhs (unsigned flags, int k, struct expent *lval)
|
|||||||
}
|
}
|
||||||
if (lval->e_test & E_FORCETEST) { /* we testing this value? */
|
if (lval->e_test & E_FORCETEST) { /* we testing this value? */
|
||||||
/* debug... */
|
/* debug... */
|
||||||
AddCodeHint ("forcetest");
|
|
||||||
flags |= TypeOf (lval->e_tptr);
|
flags |= TypeOf (lval->e_tptr);
|
||||||
g_test (flags); /* yes, force a test */
|
g_test (flags); /* yes, force a test */
|
||||||
lval->e_test &= ~E_FORCETEST;
|
lval->e_test &= ~E_FORCETEST;
|
||||||
@@ -569,9 +568,6 @@ static unsigned FunctionParamList (FuncDesc* Func)
|
|||||||
unsigned CFlags;
|
unsigned CFlags;
|
||||||
unsigned Flags;
|
unsigned Flags;
|
||||||
|
|
||||||
/* Add a hint for the optimizer */
|
|
||||||
AddCodeHint ("param:start");
|
|
||||||
|
|
||||||
/* Count arguments */
|
/* Count arguments */
|
||||||
++ParamCount;
|
++ParamCount;
|
||||||
|
|
||||||
@@ -659,9 +655,6 @@ static unsigned FunctionParamList (FuncDesc* Func)
|
|||||||
ParamSize += ArgSize;
|
ParamSize += ArgSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add an optimizer hint */
|
|
||||||
AddCodeHint ("param:end");
|
|
||||||
|
|
||||||
/* Check for end of argument list */
|
/* Check for end of argument list */
|
||||||
if (curtok != TOK_COMMA) {
|
if (curtok != TOK_COMMA) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -646,9 +646,6 @@ int main (int argc, char* argv[])
|
|||||||
OutputFile = MakeFilename (InputFile, ".s");
|
OutputFile = MakeFilename (InputFile, ".s");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Go! */
|
/* Go! */
|
||||||
Compile ();
|
Compile ();
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* cc65 */
|
/* cc65 */
|
||||||
|
#include "codegen.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
@@ -49,7 +50,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* data */
|
/* data */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
@@ -150,7 +151,7 @@ static void SegNamePragma (segment_t Seg)
|
|||||||
if (ValidSegName (Name)) {
|
if (ValidSegName (Name)) {
|
||||||
|
|
||||||
/* Set the new name */
|
/* Set the new name */
|
||||||
NewSegName (Seg, Name);
|
g_segname (Seg, Name);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -196,19 +197,21 @@ void DoPragma (void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do we know this pragma? */
|
/* Search for the name, then skip the identifier */
|
||||||
Pragma = FindPragma (CurTok.Ident);
|
Pragma = FindPragma (CurTok.Ident);
|
||||||
|
NextToken ();
|
||||||
|
|
||||||
|
/* Do we know this pragma? */
|
||||||
if (Pragma == PR_ILLEGAL) {
|
if (Pragma == PR_ILLEGAL) {
|
||||||
/* According to the ANSI standard, we're not allowed to generate errors
|
/* According to the ANSI standard, we're not allowed to generate errors
|
||||||
* for unknown pragmas, however, we're allowed to warn - and we will
|
* for unknown pragmas, however, we're allowed to warn - and we will
|
||||||
* do so. Otherwise one typo may give you hours of bug hunting...
|
* do so. Otherwise one typo may give you hours of bug hunting...
|
||||||
*/
|
*/
|
||||||
Warning ("Unknown #pragma `%s'", CurTok.Ident);
|
Warning ("Unknown #pragma `%s'", CurTok.Ident);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip the identifier and check for an open paren */
|
/* Check for an open paren */
|
||||||
NextToken ();
|
|
||||||
ConsumeLParen ();
|
ConsumeLParen ();
|
||||||
|
|
||||||
/* Switch for the different pragmas */
|
/* Switch for the different pragmas */
|
||||||
|
|||||||
@@ -523,7 +523,6 @@ static void tableswitch (struct expent* eval)
|
|||||||
g_defdata (CF_INT | CF_CONST, -((int)lcount)-1, 0);
|
g_defdata (CF_INT | CF_CONST, -((int)lcount)-1, 0);
|
||||||
|
|
||||||
/* Create the case selector table */
|
/* Create the case selector table */
|
||||||
AddCodeHint ("casetable");
|
|
||||||
p = swtab;
|
p = swtab;
|
||||||
while (lcount) {
|
while (lcount) {
|
||||||
g_case (Flags, p->sw_lab, p->sw_const); /* Create one label */
|
g_case (Flags, p->sw_lab, p->sw_const); /* Create one label */
|
||||||
@@ -734,9 +733,7 @@ int Statement (void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
AddCodeHint ("stmt:start");
|
|
||||||
expression (&lval);
|
expression (&lval);
|
||||||
AddCodeHint ("stmt:end");
|
|
||||||
ConsumeSemi ();
|
ConsumeSemi ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user