From: kvigor Date: Wed, 30 May 2001 20:40:56 +0000 (+0000) Subject: Add _naked modifier X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=20bae27b1c4b37bba7f4ec5aa92d78fbc23188f4;p=fw%2Fsdcc Add _naked modifier git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@863 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCC.lex b/src/SDCC.lex index b6ff35a6..23ee5a10 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -169,6 +169,7 @@ struct options save_options ; "void" { count(); return(VOID); } "volatile" { count(); return(VOLATILE); } "using" { count(); TKEYWORD(USING); } +"_naked" { count(); TKEYWORD(NAKED); } "while" { count(); return(WHILE); } "xdata" { count(); TKEYWORD(XDATA); } "_data" { count(); TKEYWORD(_NEAR); } diff --git a/src/SDCC.y b/src/SDCC.y index d4ae56a9..c617e3d9 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -82,7 +82,8 @@ value *cenum = NULL ; /* current enumeration type chain*/ %token REENTRANT USING XDATA DATA IDATA PDATA VAR_ARGS CRITICAL NONBANKED BANKED %token CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID BIT %token STRUCT UNION ENUM ELIPSIS RANGE FAR _XDATA _CODE _GENERIC _NEAR _PDATA _IDATA _EEPROM -%token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN +%token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN +%token NAKED %token INLINEASM %token IFX ADDRESS_OF GET_VALUE_AT_ADDRESS SPIL UNSPIL GETHBIT %token BITWISEAND UNARYMINUS IPUSH IPOP PCALL ENDFUNCTION JUMPTABLE @@ -184,6 +185,10 @@ using_reentrant_interrupt $$->class = SPECIFIER ; SPEC_CRTCL($$) = 1; } + | NAKED { $$ = newLink (); + $$->class = SPECIFIER ; + SPEC_NAKED($$) = 1; + } | NONBANKED {$$ = newLink (); $$->class = SPECIFIER ; SPEC_NONBANKED($$) = 1; diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 29a16ea4..bc4aebc0 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -458,6 +458,7 @@ mergeSpec (sym_link * dest, sym_link * src) SPEC_BSTR (dest) |= SPEC_BSTR (src); SPEC_TYPEDEF (dest) |= SPEC_TYPEDEF (src); SPEC_NONBANKED (dest) |= SPEC_NONBANKED (src); + SPEC_NAKED (dest) |= SPEC_NAKED (src); if (IS_STRUCT (dest) && SPEC_STRUCT (dest) == NULL) SPEC_STRUCT (dest) = SPEC_STRUCT (src); diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index 72a7c6ca..87fcbcb2 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -115,6 +115,7 @@ typedef struct specifier unsigned _volatile:1; /* is marked as volatile */ unsigned _const:1; /* is a constant */ unsigned _critical:1; /* critical function */ + unsigned _naked:1; /* naked function */ unsigned _typedef:1; /* is typedefed */ unsigned _isregparm:1; /* is the first parameter */ unsigned _isenum:1; /* is an enumerated type */ @@ -312,6 +313,7 @@ symbol; #define SPEC_BNKF(x) x->select.s._rbank #define SPEC_INTRTN(x) x->select.s._intrtn #define SPEC_CRTCL(x) x->select.s._critical +#define SPEC_NAKED(x) x->select.s._naked #define SPEC_VOLATILE(x) x->select.s._volatile #define SPEC_CONST(x) x->select.s._const #define SPEC_STRUCT(x) x->select.s.v_struct diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 79dfc23c..4affec9a 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -2536,6 +2536,12 @@ genFunction (iCode * ic) emitcode ("", "%s:", sym->rname); fetype = getSpec (operandType (IC_LEFT (ic))); + if (SPEC_NAKED(fetype)) + { + emitcode(";", "naked function: no prologue."); + return; + } + /* if critical function then turn interrupts off */ if (SPEC_CRTCL (fetype)) emitcode ("clr", "ea"); @@ -2805,6 +2811,12 @@ genEndFunction (iCode * ic) D (emitcode (";", "genEndFunction ");); + if (SPEC_NAKED(sym->etype)) + { + emitcode(";", "naked function: no epilogue."); + return; + } + if (IS_RENT (sym->etype) || options.stackAuto) { emitcode ("mov", "%s,_bp", spname); @@ -2938,7 +2950,7 @@ genEndFunction (iCode * ic) emitcode ("setb", "ea"); /* if debug then send end of function */ -/* if (options.debug && currFunc) { */ +/* if (options.debug && currFunc) */ if (currFunc) { _G.debugLine = 1; diff --git a/src/ds390/main.c b/src/ds390/main.c index c1a2e477..3ec50889 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -39,6 +39,7 @@ static char *_ds390_keywords[] = "_xdata", "_pdata", "_idata", + "_naked", NULL }; diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 2d70a6af..b98844ef 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -2131,6 +2131,12 @@ genFunction (iCode * ic) emitcode ("", "%s:", sym->rname); fetype = getSpec (operandType (IC_LEFT (ic))); + if (SPEC_NAKED(fetype)) + { + emitcode(";", "naked function: no prologue."); + return; + } + /* if critical function then turn interrupts off */ if (SPEC_CRTCL (fetype)) emitcode ("clr", "ea"); @@ -2383,6 +2389,12 @@ genEndFunction (iCode * ic) { symbol *sym = OP_SYMBOL (IC_LEFT (ic)); + if (SPEC_NAKED(sym->etype)) + { + emitcode(";", "naked function: no epilogue."); + return; + } + if (IS_RENT (sym->etype) || options.stackAuto) { emitcode ("mov", "%s,_bp", spname); @@ -2504,7 +2516,7 @@ genEndFunction (iCode * ic) emitcode ("setb", "ea"); /* if debug then send end of function */ -/* if (options.debug && currFunc) { */ +/* if (options.debug && currFunc) */ if (currFunc) { _G.debugLine = 1; diff --git a/src/mcs51/main.c b/src/mcs51/main.c index 9b8e3ec1..8da7d39d 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -39,6 +39,7 @@ static char *_mcs51_keywords[] = "_xdata", "_pdata", "_idata", + "_naked", NULL };