mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
Working
git-svn-id: svn://svn.cc65.org/cc65/trunk@737 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
4c19a5b699
commit
c1b6680a92
@ -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 */
|
||||
{
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -203,6 +203,39 @@ 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 */
|
||||
/*****************************************************************************/
|
||||
@ -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");
|
||||
|
@ -112,6 +112,9 @@ 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 */
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -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,6 +162,8 @@ void GetFuncInfo (const char* Name, unsigned char* Use, unsigned char* Chg)
|
||||
} else {
|
||||
*Use = REG_AX;
|
||||
}
|
||||
} else if ((D->Flags & FD_VARIADIC) != 0) {
|
||||
*Use = REG_Y;
|
||||
} else {
|
||||
/* Will not use any registers */
|
||||
*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? */
|
||||
/* 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;
|
||||
|
@ -646,9 +646,6 @@ int main (int argc, char* argv[])
|
||||
OutputFile = MakeFilename (InputFile, ".s");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Go! */
|
||||
Compile ();
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <string.h>
|
||||
|
||||
/* cc65 */
|
||||
#include "codegen.h"
|
||||
#include "error.h"
|
||||
#include "expr.h"
|
||||
#include "global.h"
|
||||
@ -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,8 +197,11 @@ 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
|
||||
@ -207,8 +211,7 @@ void DoPragma (void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Skip the identifier and check for an open paren */
|
||||
NextToken ();
|
||||
/* Check for an open paren */
|
||||
ConsumeLParen ();
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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 ();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user