Add _naked modifier
authorkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 30 May 2001 20:40:56 +0000 (20:40 +0000)
committerkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 30 May 2001 20:40:56 +0000 (20:40 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@863 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCC.lex
src/SDCC.y
src/SDCCsymt.c
src/SDCCsymt.h
src/ds390/gen.c
src/ds390/main.c
src/mcs51/gen.c
src/mcs51/main.c

index b6ff35a6c0d77eed72505ce71b3d22ded639ece6..23ee5a102f2bdba229f7acf7b93a1c03a0ba1100 100644 (file)
@@ -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); }
index d4ae56a960022a004268493f8669250936429500..c617e3d982d8de18f2000934924830f13c6215a5 100644 (file)
@@ -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 <yyinline> 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;
index 29a16ea4175021512b5c3403a279f5a2f145be87..bc4aebc0573ea430661bd4f49b6bfd44d3606af2 100644 (file)
@@ -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);
index 72a7c6ca4d2fb1e35daf50ffead9a41e727b421b..87fcbcb224887b556ecc23daef9079ccb5279d41 100644 (file)
@@ -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
index 79dfc23c6f3131fb5e90c81738d165d22b2f5e0b..4affec9a231441511e23431cf907eac220dd3718 100644 (file)
@@ -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;
index c1a2e477642967bd85011b6e7cd9466fd1a40f03..3ec508892699618900211cb5a70750faf8a94a0d 100644 (file)
@@ -39,6 +39,7 @@ static char *_ds390_keywords[] =
   "_xdata",
   "_pdata",
   "_idata",
+  "_naked",
   NULL
 };
 
index 2d70a6af55b5b93cd6599ed7bfdd0ad03dd065b3..b98844efb531338826c8e169c4792405d734672f 100644 (file)
@@ -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;
index 9b8e3ec1ae8e4ce8afe0b354782a37c7a612acc2..8da7d39d651c5fb0014a664c5eb3083ffee2cfd7 100644 (file)
@@ -39,6 +39,7 @@ static char *_mcs51_keywords[] =
   "_xdata",
   "_pdata",
   "_idata",
+  "_naked",
   NULL
 };