Merge pull request #2237 from acqn/CGType

[cc65] Renamed type facility functions for deciding code generation type flags
This commit is contained in:
Bob Andrews
2023-10-26 19:50:10 +02:00
committed by GitHub
11 changed files with 82 additions and 82 deletions

View File

@@ -90,7 +90,7 @@ static void CopyStruct (ExprDesc* LExpr, ExprDesc* RExpr)
/* Check if the value of the rhs is not in the primary yet */ /* Check if the value of the rhs is not in the primary yet */
if (!ED_IsLocPrimary (RExpr)) { if (!ED_IsLocPrimary (RExpr)) {
/* Just load the value into the primary as the replacement type. */ /* Just load the value into the primary as the replacement type. */
LoadExpr (TypeOf (stype) | CF_FORCECHAR, RExpr); LoadExpr (CG_TypeOf (stype) | CF_FORCECHAR, RExpr);
} }
/* Store it into the location referred in the primary */ /* Store it into the location referred in the primary */
@@ -145,8 +145,8 @@ void DoIncDecBitField (ExprDesc* Expr, long Val, unsigned KeepResult)
ChunkType = GetBitFieldChunkType (Expr->Type); ChunkType = GetBitFieldChunkType (Expr->Type);
/* Determine code generator flags */ /* Determine code generator flags */
Flags = TypeOf (Expr->Type) | CF_FORCECHAR; Flags = CG_TypeOf (Expr->Type) | CF_FORCECHAR;
ChunkFlags = TypeOf (ChunkType); ChunkFlags = CG_TypeOf (ChunkType);
if ((ChunkFlags & CF_TYPEMASK) == CF_CHAR) { if ((ChunkFlags & CF_TYPEMASK) == CF_CHAR) {
ChunkFlags |= CF_FORCECHAR; ChunkFlags |= CF_FORCECHAR;
} }
@@ -232,8 +232,8 @@ static void OpAssignBitField (const GenDesc* Gen, ExprDesc* Expr, const char* Op
ChunkType = GetBitFieldChunkType (Expr->Type); ChunkType = GetBitFieldChunkType (Expr->Type);
/* Determine code generator flags */ /* Determine code generator flags */
Flags = TypeOf (Expr->Type) | CF_FORCECHAR; Flags = CG_TypeOf (Expr->Type) | CF_FORCECHAR;
ChunkFlags = TypeOf (ChunkType); ChunkFlags = CG_TypeOf (ChunkType);
if ((ChunkFlags & CF_TYPEMASK) == CF_CHAR) { if ((ChunkFlags & CF_TYPEMASK) == CF_CHAR) {
ChunkFlags |= CF_FORCECHAR; ChunkFlags |= CF_FORCECHAR;
} }
@@ -358,7 +358,7 @@ static void OpAssignBitField (const GenDesc* Gen, ExprDesc* Expr, const char* Op
unsigned AdjustedFlags = Flags; unsigned AdjustedFlags = Flags;
if (Expr->Type->A.B.Width < INT_BITS || IsSignSigned (Expr->Type)) { if (Expr->Type->A.B.Width < INT_BITS || IsSignSigned (Expr->Type)) {
AdjustedFlags = (Flags & ~CF_UNSIGNED) | CF_CONST; AdjustedFlags = (Flags & ~CF_UNSIGNED) | CF_CONST;
AdjustedFlags = g_typeadjust (AdjustedFlags, TypeOf (Expr2.Type) | CF_CONST); AdjustedFlags = g_typeadjust (AdjustedFlags, CG_TypeOf (Expr2.Type) | CF_CONST);
} }
Gen->Func (g_typeadjust (Flags, AdjustedFlags) | CF_CONST, Expr2.IVal); Gen->Func (g_typeadjust (Flags, AdjustedFlags) | CF_CONST, Expr2.IVal);
} else { } else {
@@ -381,11 +381,11 @@ static void OpAssignBitField (const GenDesc* Gen, ExprDesc* Expr, const char* Op
unsigned AdjustedFlags = Flags; unsigned AdjustedFlags = Flags;
if (Expr->Type->A.B.Width < INT_BITS || IsSignSigned (Expr->Type)) { if (Expr->Type->A.B.Width < INT_BITS || IsSignSigned (Expr->Type)) {
AdjustedFlags = (Flags & ~CF_UNSIGNED) | CF_CONST; AdjustedFlags = (Flags & ~CF_UNSIGNED) | CF_CONST;
AdjustedFlags = g_typeadjust (AdjustedFlags, TypeOf (Expr2.Type) | CF_CONST); AdjustedFlags = g_typeadjust (AdjustedFlags, CG_TypeOf (Expr2.Type) | CF_CONST);
} }
Gen->Func (g_typeadjust (Flags, AdjustedFlags), 0); Gen->Func (g_typeadjust (Flags, AdjustedFlags), 0);
} else { } else {
Gen->Func (g_typeadjust (Flags, TypeOf (Expr2.Type)), 0); Gen->Func (g_typeadjust (Flags, CG_TypeOf (Expr2.Type)), 0);
} }
} else { } else {
@@ -452,7 +452,7 @@ static void OpAssignArithmetic (const GenDesc* Gen, ExprDesc* Expr, const char*
Expr2.Flags |= Expr->Flags & E_MASK_KEEP_SUBEXPR; Expr2.Flags |= Expr->Flags & E_MASK_KEEP_SUBEXPR;
/* Determine code generator flags */ /* Determine code generator flags */
Flags = TypeOf (Expr->Type); Flags = CG_TypeOf (Expr->Type);
/* Determine the type of the lhs */ /* Determine the type of the lhs */
MustScale = Gen != 0 && (Gen->Func == g_add || Gen->Func == g_sub) && MustScale = Gen != 0 && (Gen->Func == g_add || Gen->Func == g_sub) &&
@@ -572,7 +572,7 @@ static void OpAssignArithmetic (const GenDesc* Gen, ExprDesc* Expr, const char*
if (MustScale) { if (MustScale) {
/* lhs is a pointer, scale rhs */ /* lhs is a pointer, scale rhs */
g_scale (TypeOf (Expr2.Type), CheckedSizeOf (Expr->Type+1)); g_scale (CG_TypeOf (Expr2.Type), CheckedSizeOf (Expr->Type+1));
} }
/* If the lhs is character sized, the operation may be later done /* If the lhs is character sized, the operation may be later done
@@ -583,7 +583,7 @@ static void OpAssignArithmetic (const GenDesc* Gen, ExprDesc* Expr, const char*
} }
/* Adjust the types of the operands if needed */ /* Adjust the types of the operands if needed */
Gen->Func (g_typeadjust (Flags, TypeOf (Expr2.Type)), 0); Gen->Func (g_typeadjust (Flags, CG_TypeOf (Expr2.Type)), 0);
} }
} }
@@ -715,8 +715,8 @@ void OpAddSubAssign (const GenDesc* Gen, ExprDesc *Expr, const char* Op)
} }
/* Setup the code generator flags */ /* Setup the code generator flags */
lflags |= TypeOf (Expr->Type) | GlobalModeFlags (Expr) | CF_FORCECHAR; lflags |= CG_TypeOf (Expr->Type) | CG_AddrModeFlags (Expr) | CF_FORCECHAR;
rflags |= TypeOf (Expr2.Type) | CF_FORCECHAR; rflags |= CG_TypeOf (Expr2.Type) | CF_FORCECHAR;
if (ED_IsConstAbs (&Expr2)) { if (ED_IsConstAbs (&Expr2)) {
/* The resulting value is a constant */ /* The resulting value is a constant */
@@ -736,7 +736,7 @@ void OpAddSubAssign (const GenDesc* Gen, ExprDesc *Expr, const char* Op)
if (MustScale) { if (MustScale) {
/* lhs is a pointer, scale rhs */ /* lhs is a pointer, scale rhs */
g_scale (TypeOf (Expr2.Type), CheckedSizeOf (Indirect (Expr->Type))); g_scale (CG_TypeOf (Expr2.Type), CheckedSizeOf (Indirect (Expr->Type)));
} }
} }

View File

@@ -81,7 +81,7 @@ static void PostDec (ExprDesc* Expr);
unsigned GlobalModeFlags (const ExprDesc* Expr) unsigned CG_AddrModeFlags (const ExprDesc* Expr)
/* Return the addressing mode flags for the given expression */ /* Return the addressing mode flags for the given expression */
{ {
switch (ED_GetLoc (Expr)) { switch (ED_GetLoc (Expr)) {
@@ -96,7 +96,7 @@ unsigned GlobalModeFlags (const ExprDesc* Expr)
case E_LOC_LITERAL: return CF_LITERAL; case E_LOC_LITERAL: return CF_LITERAL;
case E_LOC_CODE: return CF_CODE; case E_LOC_CODE: return CF_CODE;
default: default:
Internal ("GlobalModeFlags: Invalid location flags value: 0x%04X", Expr->Flags); Internal ("CG_AddrModeFlags: Invalid location flags value: 0x%04X", Expr->Flags);
/* NOTREACHED */ /* NOTREACHED */
return 0; return 0;
} }
@@ -104,30 +104,30 @@ unsigned GlobalModeFlags (const ExprDesc* Expr)
static unsigned TypeOfBySize (unsigned Size) static unsigned CG_TypeOfBySize (unsigned Size)
/* Get the code generator replacement type of the object by its size */ /* Get the code generator replacement type of the object by its size */
{ {
unsigned NewType; unsigned CG_Type;
/* If the size is less than or equal to that of a a long, we will copy /* If the size is less than or equal to that of a a long, we will copy
** the struct using the primary register, otherwise we use memcpy. ** the struct using the primary register, otherwise we use memcpy.
*/ */
switch (Size) { switch (Size) {
case 1: NewType = CF_CHAR; break; case 1: CG_Type = CF_CHAR; break;
case 2: NewType = CF_INT; break; case 2: CG_Type = CF_INT; break;
case 3: /* FALLTHROUGH */ case 3: /* FALLTHROUGH */
case 4: NewType = CF_LONG; break; case 4: CG_Type = CF_LONG; break;
default: NewType = CF_NONE; break; default: CG_Type = CF_NONE; break;
} }
return NewType; return CG_Type;
} }
unsigned TypeOf (const Type* T) unsigned CG_TypeOf (const Type* T)
/* Get the code generator base type of the object */ /* Get the code generator base type of the object */
{ {
unsigned NewType; unsigned CG_Type;
switch (GetUnqualTypeCode (T)) { switch (GetUnqualTypeCode (T)) {
@@ -164,9 +164,9 @@ unsigned TypeOf (const Type* T)
case T_STRUCT: case T_STRUCT:
case T_UNION: case T_UNION:
NewType = TypeOfBySize (SizeOf (T)); CG_Type = CG_TypeOfBySize (SizeOf (T));
if (NewType != CF_NONE) { if (CG_Type != CF_NONE) {
return NewType; return CG_Type;
} }
/* Address of ... */ /* Address of ... */
return CF_INT | CF_UNSIGNED; return CF_INT | CF_UNSIGNED;
@@ -185,8 +185,8 @@ unsigned TypeOf (const Type* T)
unsigned FuncTypeOf (const Type* T) unsigned CG_CallFlags (const Type* T)
/* Get the code generator flag for calling the function */ /* Get the code generator flags for calling the function */
{ {
if (GetUnqualTypeCode (T) == T_FUNC) { if (GetUnqualTypeCode (T) == T_FUNC) {
return (T->A.F->Flags & FD_VARIADIC) ? 0 : CF_FIXARGC; return (T->A.F->Flags & FD_VARIADIC) ? 0 : CF_FIXARGC;
@@ -255,7 +255,7 @@ static unsigned typeadjust (ExprDesc* lhs, const ExprDesc* rhs, int NoPush)
const Type* rhst = rhs->Type; const Type* rhst = rhs->Type;
/* Generate type adjustment code if needed */ /* Generate type adjustment code if needed */
ltype = TypeOf (lhst); ltype = CG_TypeOf (lhst);
if (ED_IsConstAbsInt (lhs) && ltype == CF_INT && lhs->IVal >= 0 && lhs->IVal < 256) { if (ED_IsConstAbsInt (lhs) && ltype == CF_INT && lhs->IVal >= 0 && lhs->IVal < 256) {
/* If the lhs is a int constant that fits in an unsigned char, use unsigned char. /* If the lhs is a int constant that fits in an unsigned char, use unsigned char.
** g_typeadjust will either promote this to int or unsigned int as appropriate ** g_typeadjust will either promote this to int or unsigned int as appropriate
@@ -270,7 +270,7 @@ static unsigned typeadjust (ExprDesc* lhs, const ExprDesc* rhs, int NoPush)
/* Value is in primary register*/ /* Value is in primary register*/
ltype |= CF_PRIMARY; ltype |= CF_PRIMARY;
} }
rtype = TypeOf (rhst); rtype = CG_TypeOf (rhst);
if (ED_IsConstAbsInt (rhs) && rtype == CF_INT && rhs->IVal >= 0 && rhs->IVal < 256) { if (ED_IsConstAbsInt (rhs) && rtype == CF_INT && rhs->IVal >= 0 && rhs->IVal < 256) {
rtype = CF_CHAR | CF_UNSIGNED; rtype = CF_CHAR | CF_UNSIGNED;
} }
@@ -494,7 +494,7 @@ static void DoInc (ExprDesc* Expr, unsigned KeepResult)
} }
/* Get the flags */ /* Get the flags */
Flags = TypeOf (Expr->Type) | GlobalModeFlags (Expr) | CF_FORCECHAR | CF_CONST; Flags = CG_TypeOf (Expr->Type) | CG_AddrModeFlags (Expr) | CF_FORCECHAR | CF_CONST;
if (KeepResult != OA_NEED_NEW) { if (KeepResult != OA_NEED_NEW) {
/* No need to get the result */ /* No need to get the result */
Flags |= CF_NOKEEP; Flags |= CF_NOKEEP;
@@ -581,7 +581,7 @@ static void DoDec (ExprDesc* Expr, unsigned KeepResult)
} }
/* Get the flags */ /* Get the flags */
Flags = TypeOf (Expr->Type) | GlobalModeFlags (Expr) | CF_FORCECHAR | CF_CONST; Flags = CG_TypeOf (Expr->Type) | CG_AddrModeFlags (Expr) | CF_FORCECHAR | CF_CONST;
if (KeepResult != OA_NEED_NEW) { if (KeepResult != OA_NEED_NEW) {
/* No need to get the result */ /* No need to get the result */
Flags |= CF_NOKEEP; Flags |= CF_NOKEEP;
@@ -886,7 +886,7 @@ static unsigned FunctionArgList (FuncDesc* Func, int IsFastcall, ExprDesc* ED)
/* Handle struct/union specially */ /* Handle struct/union specially */
if (IsClassStruct (Expr.Type)) { if (IsClassStruct (Expr.Type)) {
/* Use the replacement type */ /* Use the replacement type */
Flags |= TypeOf (GetStructReplacementType (Expr.Type)); Flags |= CG_TypeOf (GetStructReplacementType (Expr.Type));
/* Load the value into the primary if it is not already there */ /* Load the value into the primary if it is not already there */
LoadExpr (Flags, &Expr); LoadExpr (Flags, &Expr);
@@ -895,7 +895,7 @@ static unsigned FunctionArgList (FuncDesc* Func, int IsFastcall, ExprDesc* ED)
LoadExpr (CF_NONE, &Expr); LoadExpr (CF_NONE, &Expr);
/* Use the type of the argument for the push */ /* Use the type of the argument for the push */
Flags |= TypeOf (Expr.Type); Flags |= CG_TypeOf (Expr.Type);
} }
/* If this is a fastcall function, don't push the last argument */ /* If this is a fastcall function, don't push the last argument */
@@ -1086,7 +1086,7 @@ static void FunctionCall (ExprDesc* Expr)
} }
/* Call the function */ /* Call the function */
g_callind (FuncTypeOf (Expr->Type+1), ArgSize, PtrOffs); g_callind (CG_CallFlags (Expr->Type+1), ArgSize, PtrOffs);
} else { } else {
@@ -1154,9 +1154,9 @@ static void FunctionCall (ExprDesc* Expr)
SB_Done (&S); SB_Done (&S);
g_call (FuncTypeOf (Expr->Type), Func->WrappedCall->Name, ArgSize); g_call (CG_CallFlags (Expr->Type), Func->WrappedCall->Name, ArgSize);
} else { } else {
g_call (FuncTypeOf (Expr->Type), (const char*) Expr->Name, ArgSize); g_call (CG_CallFlags (Expr->Type), (const char*) Expr->Name, ArgSize);
} }
} }
@@ -1683,7 +1683,7 @@ void Store (ExprDesc* Expr, const Type* StoreType)
} }
/* Prepare the code generator flags */ /* Prepare the code generator flags */
Flags = TypeOf (StoreType) | GlobalModeFlags (Expr); Flags = CG_TypeOf (StoreType) | CG_AddrModeFlags (Expr);
/* Do the store depending on the location */ /* Do the store depending on the location */
switch (ED_GetLoc (Expr)) { switch (ED_GetLoc (Expr)) {
@@ -1811,7 +1811,7 @@ static void PostInc (ExprDesc* Expr)
} }
/* Get the data type */ /* Get the data type */
Flags = TypeOf (Expr->Type); Flags = CG_TypeOf (Expr->Type);
/* We are allowed by the C standard to defer the inc operation until after /* We are allowed by the C standard to defer the inc operation until after
** the expression is used, so that we don't need to save and reload ** the expression is used, so that we don't need to save and reload
@@ -1872,7 +1872,7 @@ static void PostDec (ExprDesc* Expr)
} }
/* Get the data type */ /* Get the data type */
Flags = TypeOf (Expr->Type); Flags = CG_TypeOf (Expr->Type);
/* Emit smaller code if a char variable is at a constant location */ /* Emit smaller code if a char variable is at a constant location */
if ((Flags & CF_TYPEMASK) == CF_CHAR && ED_IsLocConst (Expr) && !IsTypeBitField (Expr->Type)) { if ((Flags & CF_TYPEMASK) == CF_CHAR && ED_IsLocConst (Expr) && !IsTypeBitField (Expr->Type)) {
@@ -1967,7 +1967,7 @@ static void UnaryOp (ExprDesc* Expr)
TypeConversion (Expr, Expr->Type); TypeConversion (Expr, Expr->Type);
/* Get code generation flags */ /* Get code generation flags */
Flags = TypeOf (Expr->Type); Flags = CG_TypeOf (Expr->Type);
/* Handle the operation */ /* Handle the operation */
switch (Tok) { switch (Tok) {
@@ -2017,7 +2017,7 @@ void hie10 (ExprDesc* Expr)
} else { } else {
/* Not constant, load into the primary */ /* Not constant, load into the primary */
LoadExpr (CF_NONE, Expr); LoadExpr (CF_NONE, Expr);
g_bneg (TypeOf (Expr->Type)); g_bneg (CG_TypeOf (Expr->Type));
ED_FinalizeRValLoad (Expr); ED_FinalizeRValLoad (Expr);
ED_TestDone (Expr); /* bneg will set cc */ ED_TestDone (Expr); /* bneg will set cc */
} }
@@ -2174,7 +2174,7 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */
/* Get the lhs on stack */ /* Get the lhs on stack */
GetCodePos (&Mark1); GetCodePos (&Mark1);
ltype = TypeOf (Expr->Type); ltype = CG_TypeOf (Expr->Type);
lconst = ED_IsConstAbs (Expr); lconst = ED_IsConstAbs (Expr);
if (lconst) { if (lconst) {
/* Constant value */ /* Constant value */
@@ -2288,7 +2288,7 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */
** operation because this allows for better code. ** operation because this allows for better code.
*/ */
unsigned rtype = ltype | CF_CONST; unsigned rtype = ltype | CF_CONST;
ltype = TypeOf (Expr2.Type); /* Expr2 is now left */ ltype = CG_TypeOf (Expr2.Type); /* Expr2 is now left */
type = CF_CONST; type = CF_CONST;
if ((Gen->Flags & GEN_NOPUSH) == 0) { if ((Gen->Flags & GEN_NOPUSH) == 0) {
g_push (ltype, 0); g_push (ltype, 0);
@@ -2312,7 +2312,7 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */
** expects the lhs in the primary, remove the push of the primary ** expects the lhs in the primary, remove the push of the primary
** now. ** now.
*/ */
unsigned rtype = TypeOf (Expr2.Type); unsigned rtype = CG_TypeOf (Expr2.Type);
type = 0; type = 0;
if (rconst) { if (rconst) {
/* As above, but for the RHS. */ /* As above, but for the RHS. */
@@ -2388,7 +2388,7 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */
/* Get the lhs on stack */ /* Get the lhs on stack */
GetCodePos (&Mark1); GetCodePos (&Mark1);
ltype = TypeOf (Expr->Type); ltype = CG_TypeOf (Expr->Type);
if (ED_IsConstAbs (Expr)) { if (ED_IsConstAbs (Expr)) {
/* Numeric constant value */ /* Numeric constant value */
GetCodePos (&Mark2); GetCodePos (&Mark2);
@@ -2700,7 +2700,7 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */
} }
} else { } else {
unsigned rtype = TypeOf (Expr2.Type) | (flags & CF_CONST); unsigned rtype = CG_TypeOf (Expr2.Type) | (flags & CF_CONST);
flags |= g_typeadjust (ltype, rtype); flags |= g_typeadjust (ltype, rtype);
} }
@@ -2920,7 +2920,7 @@ static void parseadd (ExprDesc* Expr, int DoArrayRef)
g_addaddr_local (flags, Expr->IVal); g_addaddr_local (flags, Expr->IVal);
} else { } else {
/* Static address */ /* Static address */
g_addaddr_static (flags | GlobalModeFlags (Expr), Expr->Name, Expr->IVal); g_addaddr_static (flags | CG_AddrModeFlags (Expr), Expr->Name, Expr->IVal);
} }
} else { } else {
/* Lhs is not numeric. Load it. */ /* Lhs is not numeric. Load it. */
@@ -2938,7 +2938,7 @@ static void parseadd (ExprDesc* Expr, int DoArrayRef)
g_addaddr_local (flags, Expr2.IVal); g_addaddr_local (flags, Expr2.IVal);
} else { } else {
/* Static address */ /* Static address */
g_addaddr_static (flags | GlobalModeFlags (&Expr2), Expr2.Name, Expr2.IVal); g_addaddr_static (flags | CG_AddrModeFlags (&Expr2), Expr2.Name, Expr2.IVal);
} }
} }
@@ -2965,7 +2965,7 @@ static void parseadd (ExprDesc* Expr, int DoArrayRef)
flags |= CF_CONST; flags |= CF_CONST;
} else { } else {
/* Constant address label */ /* Constant address label */
flags |= GlobalModeFlags (Expr); flags |= CG_AddrModeFlags (Expr);
} }
/* Check for pointer arithmetic */ /* Check for pointer arithmetic */
@@ -3010,7 +3010,7 @@ static void parseadd (ExprDesc* Expr, int DoArrayRef)
/* Load lhs */ /* Load lhs */
LoadExpr (CF_NONE, Expr); LoadExpr (CF_NONE, Expr);
/* Use new flags */ /* Use new flags */
flags = CF_CHAR | GlobalModeFlags (&Expr2); flags = CF_CHAR | CG_AddrModeFlags (&Expr2);
/* Add the variable */ /* Add the variable */
if (ED_IsLocStack (&Expr2)) { if (ED_IsLocStack (&Expr2)) {
g_addlocal (flags, Expr2.IVal); g_addlocal (flags, Expr2.IVal);
@@ -3032,7 +3032,7 @@ static void parseadd (ExprDesc* Expr, int DoArrayRef)
** not a numeric constant, and the scale factor is not one ** not a numeric constant, and the scale factor is not one
** (no scaling), we must take the long way over the stack. ** (no scaling), we must take the long way over the stack.
*/ */
g_push (TypeOf (Expr2.Type), 0); /* rhs --> stack */ g_push (CG_TypeOf (Expr2.Type), 0); /* rhs --> stack */
LoadExpr (CF_NONE, Expr); LoadExpr (CF_NONE, Expr);
g_scale (CF_PTR, lscale); g_scale (CF_PTR, lscale);
g_add (CF_PTR, 0); g_add (CF_PTR, 0);
@@ -3048,7 +3048,7 @@ static void parseadd (ExprDesc* Expr, int DoArrayRef)
/* Left hand side is not constant. Get the value onto the stack. */ /* Left hand side is not constant. Get the value onto the stack. */
LoadExpr (CF_NONE, Expr); /* --> primary register */ LoadExpr (CF_NONE, Expr); /* --> primary register */
GetCodePos (&Mark); GetCodePos (&Mark);
flags = TypeOf (Expr->Type); /* default codegen type */ flags = CG_TypeOf (Expr->Type); /* default codegen type */
g_push (flags, 0); /* --> stack */ g_push (flags, 0); /* --> stack */
/* Evaluate the rhs */ /* Evaluate the rhs */
@@ -3112,7 +3112,7 @@ static void parseadd (ExprDesc* Expr, int DoArrayRef)
g_push (CF_PTR, 0); /* --> stack */ g_push (CF_PTR, 0); /* --> stack */
LoadExpr (CF_NONE, &Expr2); /* Load rhs into primary register */ LoadExpr (CF_NONE, &Expr2); /* Load rhs into primary register */
} else { } else {
g_tosint (TypeOf (lhst)); /* Make sure TOS is int */ g_tosint (CG_TypeOf (lhst)); /* Make sure TOS is int */
LoadExpr (CF_NONE, &Expr2); /* Load rhs into primary register */ LoadExpr (CF_NONE, &Expr2); /* Load rhs into primary register */
if (lscale != 1) { if (lscale != 1) {
g_swap (CF_INT); /* Swap TOS and primary */ g_swap (CF_INT); /* Swap TOS and primary */
@@ -3233,9 +3233,9 @@ static void parsesub (ExprDesc* Expr)
/* Remember the output queue position, then bring the value onto the stack */ /* Remember the output queue position, then bring the value onto the stack */
GetCodePos (&Mark1); GetCodePos (&Mark1);
LoadExpr (CF_NONE, Expr); /* --> primary register */ LoadExpr (CF_NONE, Expr); /* --> primary register */
GetCodePos (&Mark2); GetCodePos (&Mark2);
g_push (TypeOf (lhst), 0); /* --> stack */ g_push (CG_TypeOf (lhst), 0); /* --> stack */
/* Parse the right hand side */ /* Parse the right hand side */
MarkedExprWithCheck (hie9, &Expr2); MarkedExprWithCheck (hie9, &Expr2);
@@ -3392,7 +3392,7 @@ static void parsesub (ExprDesc* Expr)
} }
/* Load rhs into the primary */ /* Load rhs into the primary */
LoadExpr (CF_NONE, &Expr2); LoadExpr (CF_NONE, &Expr2);
g_scale (TypeOf (rhst), rscale); g_scale (CG_TypeOf (rhst), rscale);
/* Generate code for the sub (the & is a hack here) */ /* Generate code for the sub (the & is a hack here) */
g_sub (flags & ~CF_CONST, 0); g_sub (flags & ~CF_CONST, 0);
} }
@@ -3429,7 +3429,7 @@ static void parsesub (ExprDesc* Expr)
} }
/* Load rhs into the primary */ /* Load rhs into the primary */
LoadExpr (CF_NONE, &Expr2); LoadExpr (CF_NONE, &Expr2);
g_scale (TypeOf (rhst), rscale); g_scale (CG_TypeOf (rhst), rscale);
/* Generate code for the sub (the & is a hack here) */ /* Generate code for the sub (the & is a hack here) */
g_sub (flags & ~CF_CONST, 0); g_sub (flags & ~CF_CONST, 0);
} }

View File

@@ -43,14 +43,14 @@ typedef struct GenDesc {
unsigned GlobalModeFlags (const ExprDesc* Expr); unsigned CG_AddrModeFlags (const ExprDesc* Expr);
/* Return the addressing mode flags for the given expression */ /* Return the addressing mode flags for the given expression */
unsigned TypeOf (const Type* T); unsigned CG_TypeOf (const Type* T);
/* Get the code generator base type of the object */ /* Get the code generator base type of the object */
unsigned FuncTypeOf (const Type* T); unsigned CG_CallFlags (const Type* T);
/* Get the code generator flag for calling the function */ /* Get the code generator flags for calling the function */
void ExprWithCheck (void (*Func) (ExprDesc*), ExprDesc* Expr); void ExprWithCheck (void (*Func) (ExprDesc*), ExprDesc* Expr);
/* Call an expression function with checks. */ /* Call an expression function with checks. */

View File

@@ -565,15 +565,15 @@ void NewFunc (SymEntry* Func, FuncDesc* D)
/* Generate the push */ /* Generate the push */
/* Handle struct/union specially */ /* Handle struct/union specially */
if (IsClassStruct (D->LastParam->Type)) { if (IsClassStruct (D->LastParam->Type)) {
Flags = TypeOf (GetStructReplacementType (D->LastParam->Type)) | CF_FORCECHAR; Flags = CG_TypeOf (GetStructReplacementType (D->LastParam->Type)) | CF_FORCECHAR;
} else { } else {
Flags = TypeOf (D->LastParam->Type) | CF_FORCECHAR; Flags = CG_TypeOf (D->LastParam->Type) | CF_FORCECHAR;
} }
g_push (Flags, 0); g_push (Flags, 0);
} }
/* Generate function entry code if needed */ /* Generate function entry code if needed */
g_enter (FuncTypeOf (Func->Type), F_GetParamSize (CurrentFunc)); g_enter (CG_CallFlags (Func->Type), F_GetParamSize (CurrentFunc));
/* If stack checking code is requested, emit a call to the helper routine */ /* If stack checking code is requested, emit a call to the helper routine */
if (IS_Get (&CheckStack)) { if (IS_Get (&CheckStack)) {

View File

@@ -169,12 +169,12 @@ static void DefineData (ExprDesc* Expr)
case E_LOC_NONE: case E_LOC_NONE:
/* Immediate numeric value with no storage */ /* Immediate numeric value with no storage */
g_defdata (CF_IMM | TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0); g_defdata (CF_IMM | CG_TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0);
break; break;
case E_LOC_ABS: case E_LOC_ABS:
/* Absolute numeric address */ /* Absolute numeric address */
g_defdata (CF_ABSOLUTE | TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0); g_defdata (CF_ABSOLUTE | CG_TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0);
break; break;
case E_LOC_GLOBAL: case E_LOC_GLOBAL:

View File

@@ -133,10 +133,10 @@ void LoadExpr (unsigned Flags, struct ExprDesc* Expr)
AdjustBitField = 1; AdjustBitField = 1;
/* Flags we need operate on the whole bit-field, without CF_FORCECHAR. */ /* Flags we need operate on the whole bit-field, without CF_FORCECHAR. */
BitFieldFullWidthFlags = Flags | TypeOf (Expr->Type); BitFieldFullWidthFlags = Flags | CG_TypeOf (Expr->Type);
/* Flags we need operate on the whole chunk containing the bit-field. */ /* Flags we need operate on the whole chunk containing the bit-field. */
Flags |= TypeOf (GetBitFieldChunkType (Expr->Type)); Flags |= CG_TypeOf (GetBitFieldChunkType (Expr->Type));
/* If we're adjusting, then only load a char (not an int) and do only char ops; /* If we're adjusting, then only load a char (not an int) and do only char ops;
** We will clear the high byte in the adjustment. CF_FORCECHAR does nothing if ** We will clear the high byte in the adjustment. CF_FORCECHAR does nothing if
@@ -151,7 +151,7 @@ void LoadExpr (unsigned Flags, struct ExprDesc* Expr)
if (IsIncompleteESUType (Expr->Type)) { if (IsIncompleteESUType (Expr->Type)) {
return; return;
} }
Flags |= TypeOf (Expr->Type); Flags |= CG_TypeOf (Expr->Type);
} }
} }
@@ -175,7 +175,7 @@ void LoadExpr (unsigned Flags, struct ExprDesc* Expr)
case E_LOC_NONE: case E_LOC_NONE:
/* Immediate number constant */ /* Immediate number constant */
g_getimmed (Flags | CF_IMM | TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0); g_getimmed (Flags | CF_IMM | CG_TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0);
break; break;
case E_LOC_ABS: case E_LOC_ABS:

View File

@@ -165,7 +165,7 @@ static void ParseRegisterDecl (Declarator* Decl, int Reg)
LoadExpr (CF_NONE, &Expr); LoadExpr (CF_NONE, &Expr);
/* Store the value into the variable */ /* Store the value into the variable */
g_putstatic (CF_REGVAR | TypeOf (Sym->Type), Reg, 0); g_putstatic (CF_REGVAR | CG_TypeOf (Sym->Type), Reg, 0);
/* This has to be done at sequence point */ /* This has to be done at sequence point */
DoDeferred (SQP_KEEP_NONE, &Expr); DoDeferred (SQP_KEEP_NONE, &Expr);
@@ -275,7 +275,7 @@ static void ParseAutoDecl (Declarator* Decl)
} }
/* Push the value */ /* Push the value */
g_push (Flags | TypeOf (Sym->Type), Expr.IVal); g_push (Flags | CG_TypeOf (Sym->Type), Expr.IVal);
/* This has to be done at sequence point */ /* This has to be done at sequence point */
DoDeferred (SQP_KEEP_NONE, &Expr); DoDeferred (SQP_KEEP_NONE, &Expr);
@@ -354,7 +354,7 @@ static void ParseAutoDecl (Declarator* Decl)
LoadExpr (CF_NONE, &Expr); LoadExpr (CF_NONE, &Expr);
/* Store the value into the variable */ /* Store the value into the variable */
g_putstatic (CF_STATIC | TypeOf (Sym->Type), DataLabel, 0); g_putstatic (CF_STATIC | CG_TypeOf (Sym->Type), DataLabel, 0);
/* This has to be done at sequence point */ /* This has to be done at sequence point */
DoDeferred (SQP_KEEP_NONE, &Expr); DoDeferred (SQP_KEEP_NONE, &Expr);

View File

@@ -95,14 +95,14 @@ void ShiftExpr (struct ExprDesc* Expr)
ResultType = IntPromotion (Expr->Type); ResultType = IntPromotion (Expr->Type);
/* Prepare the code generator flags */ /* Prepare the code generator flags */
GenFlags = TypeOf (ResultType); GenFlags = CG_TypeOf (ResultType);
/* Calculate the number of bits the lhs operand has */ /* Calculate the number of bits the lhs operand has */
ExprBits = SizeOf (ResultType) * 8; ExprBits = SizeOf (ResultType) * 8;
/* Get the lhs on stack */ /* Get the lhs on stack */
GetCodePos (&Mark1); GetCodePos (&Mark1);
ltype = TypeOf (Expr->Type); ltype = CG_TypeOf (Expr->Type);
lconst = ED_IsConstAbs (Expr); lconst = ED_IsConstAbs (Expr);
if (lconst) { if (lconst) {
/* Constant value */ /* Constant value */

View File

@@ -185,7 +185,7 @@ static void ParseArg (ArgDesc* Arg, const Type* Type, ExprDesc* Expr)
GetCodePos (&Arg->End); GetCodePos (&Arg->End);
/* Use the type of the argument for the push */ /* Use the type of the argument for the push */
Arg->Flags |= TypeOf (Arg->Expr.Type); Arg->Flags |= CG_TypeOf (Arg->Expr.Type);
/* Propagate from subexpressions */ /* Propagate from subexpressions */
Expr->Flags |= Arg->Expr.Flags & E_MASK_VIRAL; Expr->Flags |= Arg->Expr.Flags & E_MASK_VIRAL;

View File

@@ -346,7 +346,7 @@ static void ReturnStatement (void)
if (ReturnType == Expr.Type) { if (ReturnType == Expr.Type) {
Error ("Returning '%s' of this size by value is not supported", GetFullTypeName (Expr.Type)); Error ("Returning '%s' of this size by value is not supported", GetFullTypeName (Expr.Type));
} }
LoadExpr (TypeOf (ReturnType), &Expr); LoadExpr (CG_TypeOf (ReturnType), &Expr);
} else { } else {
/* Load the value into the primary */ /* Load the value into the primary */

View File

@@ -111,7 +111,7 @@ static void DoConversion (ExprDesc* Expr, const Type* NewType, int Explicit)
LoadExpr (CF_NONE, Expr); LoadExpr (CF_NONE, Expr);
/* Emit typecast code */ /* Emit typecast code */
g_typecast (TypeOf (NewType), TypeOf (OldType)); g_typecast (CG_TypeOf (NewType), CG_TypeOf (OldType));
/* Value is now in primary and an rvalue */ /* Value is now in primary and an rvalue */
ED_FinalizeRValLoad (Expr); ED_FinalizeRValLoad (Expr);
@@ -178,7 +178,7 @@ static void DoConversion (ExprDesc* Expr, const Type* NewType, int Explicit)
LoadExpr (CF_NONE, Expr); LoadExpr (CF_NONE, Expr);
/* Emit typecast code. */ /* Emit typecast code. */
g_typecast (TypeOf (NewType), TypeOf (OldType)); g_typecast (CG_TypeOf (NewType), CG_TypeOf (OldType));
/* Value is now an rvalue in the primary */ /* Value is now an rvalue in the primary */
ED_FinalizeRValLoad (Expr); ED_FinalizeRValLoad (Expr);