1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-27 00:29:31 +00:00

Made __fastcall__ be the default calling convention for non-variadic functions.

This commit is contained in:
Greg King 2015-03-10 05:53:52 -04:00
parent 6230b6a813
commit a798b1d648
10 changed files with 72 additions and 73 deletions

View File

@ -2,14 +2,14 @@
/* */
/* ace.h */
/* */
/* ACE system specific definitions */
/* ACE system-specific definitions */
/* */
/* */
/* */
/* (C) 1998-2001 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 1998-2015, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -61,9 +61,9 @@ struct aceDirentBuf {
char ad_name [17]; /* Name itself, ASCIIZ */
};
int aceDirOpen (char* dir);
int aceDirClose (int handle);
int aceDirRead (int handle, struct aceDirentBuf* buf);
int __cdecl__ aceDirOpen (char* dir);
int __cdecl__ aceDirClose (int handle);
int __cdecl__ aceDirRead (int handle, struct aceDirentBuf* buf);
/* Type of an ACE key. Key in low byte, shift mask in high byte */
typedef unsigned int aceKey;
@ -92,23 +92,23 @@ typedef unsigned int aceKey;
#define aceOP_RPTRATE 11 /* Key repeat rate */
/* Console functions */
void aceConWrite (char* buf, size_t count);
void aceConPutLit (int c);
void aceConPos (unsigned x, unsigned y);
void aceConGetPos (unsigned* x, unsigned* y);
void __cdecl__ aceConWrite (char* buf, size_t count);
void __cdecl__ aceConPutLit (int c);
void __cdecl__ aceConPos (unsigned x, unsigned y);
void __cdecl__ aceConGetPos (unsigned* x, unsigned* y);
unsigned aceConGetX (void);
unsigned aceConGetY (void);
char* aceConInput (char* buf, unsigned initial);
char __cdecl__* aceConInput (char* buf, unsigned initial);
int aceConStopKey (void);
aceKey aceConGetKey (void);
int aceConKeyAvail (aceKey* key);
void aceConKeyMat (char* matrix);
void aceConSetOpt (unsigned char opt, unsigned char val);
int aceConGetOpt (unsigned char opt);
int __cdecl__ aceConKeyAvail (aceKey* key);
void __cdecl__ aceConKeyMat (char* matrix);
void __cdecl__ aceConSetOpt (unsigned char opt, unsigned char val);
int __cdecl__ aceConGetOpt (unsigned char opt);
/* Misc stuff */
int aceMiscIoPeek (unsigned addr);
void aceMiscIoPoke (unsigned addr, unsigned char val);
int __cdecl__ aceMiscIoPeek (unsigned addr);
void __cdecl__ aceMiscIoPoke (unsigned addr, unsigned char val);

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998-2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 1998-2000, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -42,7 +42,7 @@
#ifdef NDEBUG
# define assert(expr)
#else
extern void _afailed (const char*, unsigned);
extern void __cdecl__ _afailed (const char*, unsigned);
# define assert(expr) ((expr)? (void)0 : _afailed(__FILE__, __LINE__))
#endif

View File

@ -6,7 +6,7 @@
/* */
/* */
/* */
/* (C) 1998-2012, Ullrich von Bassewitz */
/* (C) 1998-2015, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
@ -222,7 +222,7 @@ void cbm_k_unlsn (void);
unsigned int cbm_load (const char* name, unsigned char device, void* data);
unsigned int __cdecl__ cbm_load (const char* name, unsigned char device, void* data);
/* Loads file "name", from given device, to given address -- or, to the load
** address of the file if "data" is the null pointer (like load"name",8,1
** in BASIC).

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998-2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 1998-2000, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -88,7 +88,7 @@ unsigned __fastcall__ DbgDisAsmLen (unsigned Addr);
int __fastcall__ DbgIsRAM (unsigned Addr);
/* Return true if we can read and write the given address */
char* DbgMemDump (unsigned Addr, char* Buf, unsigned char Len);
char* __cdecl__ DbgMemDump (unsigned Addr, char* Buf, unsigned char Len);
/* Create a line of a memory dump in the given buffer. The buffer contains
** the starting address (4 digits hex), then Len bytes in this format:
** "AAAA__XX_YY_ZZ_...". The passed char buffer must hold Len*3+5 bytes

View File

@ -2,7 +2,7 @@
/* */
/* lynx.h */
/* */
/* Lynx system specific definitions */
/* Lynx system-specific definitions */
/* */
/* */
/* */
@ -109,25 +109,25 @@ extern void lynx_160_102_16_tgi[]; /* Referred to by tgi_static_stddrv[] */
/* Sound support */
/*****************************************************************************/
void lynx_snd_init ();
void lynx_snd_init (void);
/* Initialize the sound driver */
void lynx_snd_pause ();
void lynx_snd_pause (void);
/* Pause sound */
void lynx_snd_continue ();
void lynx_snd_continue (void);
/* Continue sound after pause */
void __fastcall__ lynx_snd_play (unsigned char channel, unsigned char *music);
/* Play tune on channel */
void lynx_snd_stop ();
void lynx_snd_stop (void);
/* Stop sound on all channels */
void __fastcall__ lynx_snd_stop_channel (unsigned char channel);
/* Stop sound on all channels */
unsigned char lynx_snd_active();
unsigned char lynx_snd_active(void);
/* Show which channels are active */
/*****************************************************************************/

View File

@ -83,8 +83,8 @@ unsigned __fastcall__ inflatemem (char* dest, const char* source);
*/
int uncompress (char* dest, unsigned* destLen,
const char* source, unsigned sourceLen);
int __cdecl__ uncompress (char* dest, unsigned* destLen,
const char* source, unsigned sourceLen);
/*
Original zlib description:

View File

@ -1,9 +1,9 @@
/*
** Marc 'BlackJack' Rintsch, 06.03.2001
**
** unsigned int cbm_load(const char* name,
** unsigned char device,
** const unsigned char* data);
** unsigned int __cdecl__ cbm_load(const char* name,
** unsigned char device,
** const unsigned char* data);
*/
#include <cbm.h>
@ -11,7 +11,7 @@
/* loads file "name" from given device to given address or to the load address
** of the file if "data" is 0
*/
unsigned int cbm_load(const char* name, unsigned char device, void* data)
unsigned int __cdecl__ cbm_load(const char* name, unsigned char device, void* data)
{
/* LFN is set to 0; but, it's not needed for loading
** (BASIC V2 sets it to the value of the SA for LOAD).

View File

@ -6,7 +6,7 @@
/* */
/* */
/* */
/* (C) 2001-2012, Ullrich von Bassewitz */
/* (C) 2001-2015, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
@ -386,33 +386,32 @@ void GetFuncInfo (const char* Name, unsigned short* Use, unsigned short* Chg)
** Search for it in the list of builtin functions.
*/
if (Name[0] == '_') {
/* Search in the symbol table, skip the leading underscore */
SymEntry* E = FindGlobalSym (Name+1);
/* Did we find it in the top level table? */
/* Did we find it in the top-level table? */
if (E && IsTypeFunc (E->Type)) {
FuncDesc* D = E->V.F.Func;
/* A function may use the A or A/X registers if it is a fastcall
** 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.
/* A variadic function will use the Y register (the parameter list
** size is passed there). A fastcall function will use the A or A/X
** registers. In all other cases, no registers are used. However,
** we assume that any function will destroy all registers.
*/
if (IsQualFastcall (E->Type) && D->ParamCount > 0) {
/* Will use registers depending on the last param */
unsigned LastParamSize = CheckedSizeOf (D->LastParam->Type);
if (LastParamSize == 1) {
*Use = REG_A;
} else if (LastParamSize == 2) {
*Use = REG_AX;
} else {
*Use = REG_EAX;
}
} else if ((D->Flags & FD_VARIADIC) != 0) {
if ((D->Flags & FD_VARIADIC) != 0) {
*Use = REG_Y;
} else if (!IsQualCDecl (E->Type) && D->ParamCount > 0) {
/* Will use registers depending on the last param. */
switch (CheckedSizeOf (D->LastParam->Type)) {
case 1u:
*Use = REG_A;
break;
case 2u:
*Use = REG_AX;
break;
default:
*Use = REG_EAX;
}
} else {
/* Will not use any registers */
*Use = REG_NONE;

View File

@ -1,6 +1,7 @@
/* expr.c
**
** Ullrich von Bassewitz, 21.06.1998
** 1998-06-21, Ullrich von Bassewitz
** 2015-03-10, Greg King
*/
@ -471,8 +472,8 @@ static void FunctionCall (ExprDesc* Expr)
IsFuncPtr = IsTypeFuncPtr (Expr->Type);
if (IsFuncPtr) {
/* Check wether it's a fastcall function that has parameters */
IsFastcall = IsQualFastcall (Expr->Type + 1) && (Func->ParamCount > 0);
/* Check whether it's a fastcall function that has parameters */
IsFastcall = (Func->Flags & FD_VARIADIC) == 0 && !IsQualCDecl (Expr->Type + 1) && (Func->ParamCount > 0);
/* Things may be difficult, depending on where the function pointer
** resides. If the function pointer is an expression of some sort
@ -517,7 +518,7 @@ static void FunctionCall (ExprDesc* Expr)
}
/* If we didn't inline the function, get fastcall info */
IsFastcall = IsQualFastcall (Expr->Type);
IsFastcall = (Func->Flags & FD_VARIADIC) == 0 && !IsQualCDecl (Expr->Type);
}
/* Parse the parameter list */

View File

@ -6,7 +6,7 @@
/* */
/* */
/* */
/* (C) 2000-2012, Ullrich von Bassewitz */
/* (C) 2000-2015, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
@ -460,6 +460,9 @@ void NewFunc (SymEntry* Func)
*/
if (D->ParamCount > 0 || (D->Flags & FD_VARIADIC) != 0) {
g_importmainargs ();
/* The start-up code doesn't fast-call main(). */
Func->Type->C |= T_QUAL_CDECL;
}
/* Determine if this is a main function in a C99 environment that
@ -478,13 +481,9 @@ void NewFunc (SymEntry* Func)
PushLiteralPool (Func);
/* If this is a fastcall function, push the last parameter onto the stack */
if (IsQualFastcall (Func->Type) && D->ParamCount > 0) {
if ((D->Flags & FD_VARIADIC) == 0 && !IsQualCDecl (Func->Type) && D->ParamCount > 0) {
unsigned Flags;
/* Fastcall functions may never have an ellipsis or the compiler is buggy */
CHECK ((D->Flags & FD_VARIADIC) == 0);
/* Generate the push */
if (IsTypeFunc (D->LastParam->Type)) {
/* Pointer to function */