Reversed accidentally checked in changes
git-svn-id: svn://svn.cc65.org/cc65/trunk@3613 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -406,12 +406,17 @@ unsigned OptJumpCascades (CodeSeg* S)
|
|||||||
/* Remember, we had changes */
|
/* Remember, we had changes */
|
||||||
++Changes;
|
++Changes;
|
||||||
|
|
||||||
|
/* Done */
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if both are conditional branches, and the condition of
|
/* Check if both are conditional branches, and the condition of
|
||||||
* the second is the inverse of that of the first. In this case,
|
* the second is the inverse of that of the first. In this case,
|
||||||
* the second branch will never be taken, and we may jump directly
|
* the second branch will never be taken, and we may jump directly
|
||||||
* to the instruction behind this one.
|
* to the instruction behind this one.
|
||||||
*/
|
*/
|
||||||
} else if ((E->Info & OF_CBRA) != 0 && (N->Info & OF_CBRA) != 0) {
|
if ((E->Info & OF_CBRA) != 0 && (N->Info & OF_CBRA) != 0) {
|
||||||
|
|
||||||
CodeEntry* X; /* Instruction behind N */
|
CodeEntry* X; /* Instruction behind N */
|
||||||
CodeLabel* LX; /* Label attached to X */
|
CodeLabel* LX; /* Label attached to X */
|
||||||
@@ -443,6 +448,9 @@ unsigned OptJumpCascades (CodeSeg* S)
|
|||||||
/* Remember, we had changes */
|
/* Remember, we had changes */
|
||||||
++Changes;
|
++Changes;
|
||||||
|
|
||||||
|
/* Done */
|
||||||
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
114
src/cc65/expr.c
114
src/cc65/expr.c
@@ -729,9 +729,7 @@ static void Primary (ExprDesc* E)
|
|||||||
strcpy (Ident, CurTok.Ident);
|
strcpy (Ident, CurTok.Ident);
|
||||||
NextToken ();
|
NextToken ();
|
||||||
|
|
||||||
/* The identifier is either an implicitly declared function or an
|
/* IDENT is either an auto-declared function or an undefined variable. */
|
||||||
* undefined variable.
|
|
||||||
*/
|
|
||||||
if (CurTok.Tok == TOK_LPAREN) {
|
if (CurTok.Tok == TOK_LPAREN) {
|
||||||
/* Declare a function returning int. For that purpose, prepare a
|
/* Declare a function returning int. For that purpose, prepare a
|
||||||
* function signature for a function having an empty param list
|
* function signature for a function having an empty param list
|
||||||
@@ -1654,7 +1652,7 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */
|
|||||||
rconst = (evalexpr (CF_NONE, hienext, &Expr2) == 0);
|
rconst = (evalexpr (CF_NONE, hienext, &Expr2) == 0);
|
||||||
|
|
||||||
/* Check the type of the rhs */
|
/* Check the type of the rhs */
|
||||||
if (!IsClassInt (Expr2.Type)) {
|
if (!IsClassInt (Expr2.Type)) {
|
||||||
Error ("Integer expression expected");
|
Error ("Integer expression expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1754,7 +1752,7 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */
|
|||||||
}
|
}
|
||||||
} else if (IsClassPtr (Expr->Type)) {
|
} else if (IsClassPtr (Expr->Type)) {
|
||||||
if (IsClassPtr (Expr2.Type)) {
|
if (IsClassPtr (Expr2.Type)) {
|
||||||
/* Both pointers are allowed in comparison if they point to
|
/* Both pointers are allowed in comparison if they point to
|
||||||
* the same type, or if one of them is a void pointer.
|
* the same type, or if one of them is a void pointer.
|
||||||
*/
|
*/
|
||||||
type* left = Indirect (Expr->Type);
|
type* left = Indirect (Expr->Type);
|
||||||
@@ -1804,7 +1802,7 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */
|
|||||||
flags |= CF_UNSIGNED;
|
flags |= CF_UNSIGNED;
|
||||||
}
|
}
|
||||||
if (rconst) {
|
if (rconst) {
|
||||||
flags |= CF_FORCECHAR;
|
flags |= CF_FORCECHAR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned rtype = TypeOf (Expr2.Type) | (flags & CF_CONST);
|
unsigned rtype = TypeOf (Expr2.Type) | (flags & CF_CONST);
|
||||||
@@ -1828,8 +1826,8 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void hie9 (ExprDesc* Expr)
|
static void hie9 (ExprDesc *Expr)
|
||||||
/* Process *, / and % */
|
/* Process * and / operators. */
|
||||||
{
|
{
|
||||||
static const GenDesc hie9_ops[] = {
|
static const GenDesc hie9_ops[] = {
|
||||||
{ TOK_STAR, GEN_NOPUSH, g_mul },
|
{ TOK_STAR, GEN_NOPUSH, g_mul },
|
||||||
@@ -1840,102 +1838,6 @@ static void hie9 (ExprDesc* Expr)
|
|||||||
int UsedGen;
|
int UsedGen;
|
||||||
|
|
||||||
hie_internal (hie9_ops, Expr, hie10, &UsedGen);
|
hie_internal (hie9_ops, Expr, hie10, &UsedGen);
|
||||||
|
|
||||||
|
|
||||||
ExprDesc Expr2;
|
|
||||||
CodeMark Mark1;
|
|
||||||
CodeMark Mark2;
|
|
||||||
const GenDesc* Gen;
|
|
||||||
token_t Tok; /* The operator token */
|
|
||||||
unsigned ltype, type;
|
|
||||||
int rconst; /* Operand is a constant */
|
|
||||||
|
|
||||||
|
|
||||||
/* Get the left hand side */
|
|
||||||
ExprWithCheck (hie10, Expr);
|
|
||||||
|
|
||||||
/* Check if one of our operators follows */
|
|
||||||
while (CurTok.Tok == TOK_STAR ||
|
|
||||||
CurTok.Tok == TOK_DIV ||
|
|
||||||
CurTok.Tok == TOK_MOD) {
|
|
||||||
|
|
||||||
/* All operators that call this function expect an int on the lhs */
|
|
||||||
if (!IsClassInt (Expr->Type)) {
|
|
||||||
Error ("Integer expression expected");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remember the operator token, then skip it */
|
|
||||||
Tok = CurTok.Tok;
|
|
||||||
NextToken ();
|
|
||||||
|
|
||||||
/* Get the lhs on stack */
|
|
||||||
GetCodePos (&Mark1);
|
|
||||||
ltype = TypeOf (Expr->Type);
|
|
||||||
if (ED_IsConstAbs (Expr)) {
|
|
||||||
/* Constant value */
|
|
||||||
GetCodePos (&Mark2);
|
|
||||||
g_push (ltype | CF_CONST, Expr->IVal);
|
|
||||||
} else {
|
|
||||||
/* Value not constant */
|
|
||||||
LoadExpr (CF_NONE, Expr);
|
|
||||||
GetCodePos (&Mark2);
|
|
||||||
g_push (ltype, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the right hand side */
|
|
||||||
rconst = (evalexpr (CF_NONE, hienext, &Expr2) == 0);
|
|
||||||
|
|
||||||
/* Check the type of the rhs */
|
|
||||||
if (!IsClassInt (Expr2.Type)) {
|
|
||||||
Error ("Integer expression expected");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check for const operands */
|
|
||||||
if (ED_IsConstAbs (Expr) && rconst) {
|
|
||||||
|
|
||||||
/* Both operands are constant, remove the generated code */
|
|
||||||
RemoveCode (&Mark1);
|
|
||||||
|
|
||||||
/* Evaluate the result */
|
|
||||||
Expr->IVal = kcalc (Tok, Expr->IVal, Expr2.IVal);
|
|
||||||
|
|
||||||
/* Get the type of the result */
|
|
||||||
Expr->Type = promoteint (Expr->Type, Expr2.Type);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* If the right hand side is constant, and the generator function
|
|
||||||
* expects the lhs in the primary, remove the push of the primary
|
|
||||||
* now.
|
|
||||||
*/
|
|
||||||
unsigned rtype = TypeOf (Expr2.Type);
|
|
||||||
type = 0;
|
|
||||||
if (rconst) {
|
|
||||||
/* Second value is constant - check for div */
|
|
||||||
type |= CF_CONST;
|
|
||||||
rtype |= CF_CONST;
|
|
||||||
if (Tok == TOK_DIV && Expr2.IVal == 0) {
|
|
||||||
Error ("Division by zero");
|
|
||||||
} else if (Tok == TOK_MOD && Expr2.IVal == 0) {
|
|
||||||
Error ("Modulo operation with zero");
|
|
||||||
}
|
|
||||||
if ((Gen->Flags & GEN_NOPUSH) != 0) {
|
|
||||||
RemoveCode (&Mark2);
|
|
||||||
ltype |= CF_REG; /* Value is in register */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Determine the type of the operation result. */
|
|
||||||
type |= g_typeadjust (ltype, rtype);
|
|
||||||
Expr->Type = promoteint (Expr->Type, Expr2.Type);
|
|
||||||
|
|
||||||
/* Generate code */
|
|
||||||
Gen->Func (type, Expr2.IVal);
|
|
||||||
|
|
||||||
/* We have a rvalue in the primary now */
|
|
||||||
ED_MakeRValExpr (Expr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2052,7 +1954,7 @@ static void parseadd (ExprDesc* Expr)
|
|||||||
/* Constant address that must be scaled */
|
/* Constant address that must be scaled */
|
||||||
g_push (TypeOf (Expr2.Type), 0); /* rhs --> stack */
|
g_push (TypeOf (Expr2.Type), 0); /* rhs --> stack */
|
||||||
g_getimmed (flags, Expr->Name, Expr->IVal);
|
g_getimmed (flags, Expr->Name, Expr->IVal);
|
||||||
g_scale (CF_PTR, ScaleFactor);
|
g_scale (CF_PTR, ScaleFactor);
|
||||||
g_add (CF_PTR, 0);
|
g_add (CF_PTR, 0);
|
||||||
}
|
}
|
||||||
} else if (IsClassInt (lhst) && IsClassInt (rhst)) {
|
} else if (IsClassInt (lhst) && IsClassInt (rhst)) {
|
||||||
@@ -2302,7 +2204,7 @@ static void parsesub (ExprDesc* Expr)
|
|||||||
/* Integer subtraction. If the left hand side descriptor says that
|
/* Integer subtraction. If the left hand side descriptor says that
|
||||||
* the lhs is const, we have to remove this mark, since this is no
|
* the lhs is const, we have to remove this mark, since this is no
|
||||||
* longer true, lhs is on stack instead.
|
* longer true, lhs is on stack instead.
|
||||||
*/
|
*/
|
||||||
if (ED_IsLocAbs (Expr)) {
|
if (ED_IsLocAbs (Expr)) {
|
||||||
ED_MakeRValExpr (Expr);
|
ED_MakeRValExpr (Expr);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user