mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 19:29:37 +00:00
Replaced checking for __fastcall__ aginst AutoCDecl etc. with IsFastcallFunc().
This commit is contained in:
parent
d3cd668585
commit
3755e4a863
@ -493,17 +493,14 @@ fncls_t GetFuncInfo (const char* Name, unsigned int* Use, unsigned int* Chg)
|
||||
** registers.
|
||||
*/
|
||||
*Use = REG_EAXY;
|
||||
} else if ((D->ParamCount > 0 ||
|
||||
(D->Flags & FD_EMPTY) != 0) &&
|
||||
(AutoCDecl ?
|
||||
IsQualFastcall (E->Type) :
|
||||
!IsQualCDecl (E->Type))) {
|
||||
} else if ((D->ParamCount > 0 || (D->Flags & FD_EMPTY) != 0) &&
|
||||
IsFastcallFunc (E->Type)) {
|
||||
/* Will use registers depending on the last param. If the last
|
||||
** param has incomplete type, or if the function has not been
|
||||
** prototyped yet, just assume __EAX__.
|
||||
*/
|
||||
if (D->LastParam != 0) {
|
||||
switch (SizeOf(D->LastParam->Type)) {
|
||||
switch (SizeOf (D->LastParam->Type)) {
|
||||
case 1u:
|
||||
*Use = REG_A;
|
||||
break;
|
||||
|
@ -1085,11 +1085,26 @@ int HasUnknownSize (const Type* T)
|
||||
|
||||
int IsVariadicFunc (const Type* T)
|
||||
/* Return true if this is a function type or pointer to function type with
|
||||
** variable parameter list
|
||||
** variable parameter list.
|
||||
** Check fails if the type is not a function or a pointer to function.
|
||||
*/
|
||||
{
|
||||
FuncDesc* F = GetFuncDesc (T);
|
||||
return (F->Flags & FD_VARIADIC) != 0;
|
||||
return (GetFuncDesc (T)->Flags & FD_VARIADIC) != 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int IsFastcallFunc (const Type* T)
|
||||
/* Return true if this is a function type or pointer to function type by
|
||||
** __fastcall__ calling convention.
|
||||
** Check fails if the type is not a function or a pointer to function.
|
||||
*/
|
||||
{
|
||||
if (UnqualifiedType (T->C) == T_PTR) {
|
||||
/* Pointer to function */
|
||||
++T;
|
||||
}
|
||||
return !IsVariadicFunc (T) && (AutoCDecl ? IsQualFastcall (T) : !IsQualCDecl (T));
|
||||
}
|
||||
|
||||
|
||||
|
@ -825,7 +825,14 @@ INLINE int IsQualCConv (const Type* T)
|
||||
|
||||
int IsVariadicFunc (const Type* T) attribute ((const));
|
||||
/* Return true if this is a function type or pointer to function type with
|
||||
** variable parameter list
|
||||
** variable parameter list.
|
||||
** Check fails if the type is not a function or a pointer to function.
|
||||
*/
|
||||
|
||||
int IsFastcallFunc (const Type* T) attribute ((const));
|
||||
/* Return true if this is a function type or pointer to function type by
|
||||
** __fastcall__ calling convention.
|
||||
** Check fails if the type is not a function or a pointer to function.
|
||||
*/
|
||||
|
||||
FuncDesc* GetFuncDesc (const Type* T) attribute ((const));
|
||||
|
@ -863,7 +863,7 @@ static void FunctionCall (ExprDesc* Expr)
|
||||
unsigned ParamSize; /* Number of parameter bytes */
|
||||
CodeMark Mark;
|
||||
int PtrOffs = 0; /* Offset of function pointer on stack */
|
||||
int IsFastcall = 0; /* True if it's a fast-call function */
|
||||
int IsFastcall = 0; /* True if we are fast-calling the function */
|
||||
int PtrOnStack = 0; /* True if a pointer copy is on stack */
|
||||
Type* ReturnType;
|
||||
|
||||
@ -882,11 +882,8 @@ static void FunctionCall (ExprDesc* Expr)
|
||||
** parameter count is zero. Handle K & R functions as though there are
|
||||
** parameters.
|
||||
*/
|
||||
IsFastcall = (Func->Flags & FD_VARIADIC) == 0 &&
|
||||
(Func->ParamCount > 0 || (Func->Flags & FD_EMPTY)) &&
|
||||
(AutoCDecl ?
|
||||
IsQualFastcall (Expr->Type + 1) :
|
||||
!IsQualCDecl (Expr->Type + 1));
|
||||
IsFastcall = (Func->ParamCount > 0 || (Func->Flags & FD_EMPTY) != 0) &&
|
||||
IsFastcallFunc (Expr->Type + 1);
|
||||
|
||||
/* Things may be difficult, depending on where the function pointer
|
||||
** resides. If the function pointer is an expression of some sort
|
||||
@ -931,10 +928,7 @@ static void FunctionCall (ExprDesc* Expr)
|
||||
}
|
||||
|
||||
/* If we didn't inline the function, get fastcall info */
|
||||
IsFastcall = (Func->Flags & FD_VARIADIC) == 0 &&
|
||||
(AutoCDecl ?
|
||||
IsQualFastcall (Expr->Type) :
|
||||
!IsQualCDecl (Expr->Type));
|
||||
IsFastcall = IsFastcallFunc (Expr->Type);
|
||||
}
|
||||
|
||||
/* Parse the parameter list */
|
||||
|
@ -558,10 +558,7 @@ void NewFunc (SymEntry* Func, FuncDesc* D)
|
||||
PushLiteralPool (Func);
|
||||
|
||||
/* If this is a fastcall function, push the last parameter onto the stack */
|
||||
if ((D->Flags & FD_VARIADIC) == 0 && D->ParamCount > 0 &&
|
||||
(AutoCDecl ?
|
||||
IsQualFastcall (Func->Type) :
|
||||
!IsQualCDecl (Func->Type))) {
|
||||
if (D->ParamCount > 0 && IsFastcallFunc (Func->Type)) {
|
||||
unsigned Flags;
|
||||
|
||||
/* Generate the push */
|
||||
|
Loading…
Reference in New Issue
Block a user