From e9bad063b03367c816abbb8840e0b86a1b477e22 Mon Sep 17 00:00:00 2001 From: johanknol Date: Sun, 17 Jun 2001 12:30:39 +0000 Subject: [PATCH] Now _naked should work for function calls too. In fact it more or less makes calleesaves and "#pragma EXCLUDE" obsolete. Note however that you have to ret or reti yourself! git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@900 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCsymt.c | 9 ++++++--- src/ds390/gen.c | 17 +++++------------ src/ds390/ralloc.c | 2 +- src/mcs51/gen.c | 17 +++++------------ 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index b70f3af3..34fe08a3 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1488,7 +1488,7 @@ checkType (sym_link * dest, sym_link * src) } /*------------------------------------------------------------------*/ -/* inCalleeSaveList - return 1 if found in calle save list */ +/* inCalleeSaveList - return 1 if found in callee save list */ /*------------------------------------------------------------------*/ bool inCalleeSaveList (char *s) @@ -1649,13 +1649,16 @@ checkFunction (symbol * sym) if (SPEC_INTRTN (csym->etype) != SPEC_INTRTN (sym->etype)) { werror (E_PREV_DEF_CONFLICT, csym->name, "interrupt"); - return 0; } if (SPEC_BANK (csym->etype) != SPEC_BANK (sym->etype)) { werror (E_PREV_DEF_CONFLICT, csym->name, "using"); - return 0; + } + + if (SPEC_NAKED (csym->etype) != SPEC_NAKED (sym->etype)) + { + werror (E_PREV_DEF_CONFLICT, csym->name, "_naked"); } /* compare expected agrs with actual args */ diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 4affec9a..60f2df10 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -1758,7 +1758,8 @@ saveRegisters (iCode * lic) /* if the registers have been saved already then do nothing */ - if (ic->regsSaved || (OP_SYMBOL (IC_LEFT (ic))->calleeSave)) + if (ic->regsSaved || (OP_SYMBOL (IC_LEFT (ic))->calleeSave) || + SPEC_NAKED(OP_SYM_ETYPE(IC_LEFT(ic)))) return; /* find the registers in use at this time @@ -1796,16 +1797,8 @@ saveRegisters (iCode * lic) } detype = getSpec (operandType (IC_LEFT (ic))); - -#if 0 // why should we do this here??? jwk20011105 - if (detype && - (SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)) && - IS_ISR (currFunc->etype) && - !ic->bankSaved) - saveRBank (SPEC_BANK (detype), ic, TRUE); -#endif - } + /*-----------------------------------------------------------------*/ /* unsaveRegisters - pop the pushed registers */ /*-----------------------------------------------------------------*/ @@ -2183,11 +2176,11 @@ genCall (iCode * ic) D (emitcode (";", "genCall ");); - /* if we are calling a function that is not using + /* if we are calling a not _naked function that is not using the same register bank then we need to save the destination registers on the stack */ detype = getSpec (operandType (IC_LEFT (ic))); - if (detype && + if (detype && !SPEC_NAKED(detype) && (SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)) && IS_ISR (currFunc->etype)) { diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index cdffd002..b2aa0866 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -2210,7 +2210,7 @@ packForPush (iCode * ic, eBBlock * ebp) /* make sure the right side does not have any definitions inbetween */ dbv = OP_DEFS(IC_RIGHT(dic)); - for (lic = ic; lic != dic ; lic = lic->prev) { + for (lic = ic; lic && lic != dic ; lic = lic->prev) { if (bitVectBitValue(dbv,lic->key)) return ; } /* make sure they have the same type */ diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 8a97a2ec..94f8ad07 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -1443,9 +1443,10 @@ saveRegisters (iCode * lic) return; } - /* if the registers have been saved already then + /* if the registers have been saved already or don't need to be then do nothing */ - if (ic->regsSaved || (OP_SYMBOL (IC_LEFT (ic))->calleeSave)) + if (ic->regsSaved || (OP_SYMBOL (IC_LEFT (ic))->calleeSave) || + SPEC_NAKED(OP_SYM_ETYPE(IC_LEFT (ic)))) return; /* find the registers in use at this time @@ -1484,14 +1485,6 @@ saveRegisters (iCode * lic) detype = getSpec (operandType (IC_LEFT (ic))); -#if 0 // why should we do this here??? jwk20011105 - if (detype && - (SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)) && - IS_ISR (currFunc->etype) && - !ic->bankSaved) - saveRBank (SPEC_BANK (detype), ic, TRUE); -#endif - } /*-----------------------------------------------------------------*/ /* unsaveRegisters - pop the pushed registers */ @@ -1872,11 +1865,11 @@ genCall (iCode * ic) _G.sendSet = NULL; } - /* if we are calling a function that is not using + /* if we are calling a not _naked function that is not using the same register bank then we need to save the destination registers on the stack */ detype = getSpec (operandType (IC_LEFT (ic))); - if (detype && + if (detype && !SPEC_NAKED(detype) && (SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)) && IS_ISR (currFunc->etype)) { -- 2.47.2