changes to handle multiple sends & receives
[fw/sdcc] / src / SDCCsymt.h
index 12e76466b49e6be5c17893398f296f0baafbf36c..da96ada5c5d6ed6b1ed15fb56a846e6f920c3847 100644 (file)
 #define SDCC_NAME_MAX  3*SDCC_SYMNAME_MAX // big enough for _<func>_<var>_etc
 #include "SDCChasht.h"
 
+enum {
+    TYPEOF_INT=1,
+    TYPEOF_SHORT,
+    TYPEOF_CHAR,
+    TYPEOF_LONG,
+    TYPEOF_FLOAT,
+    TYPEOF_BIT,
+    TYPEOF_SBIT,
+    TYPEOF_SFR,
+    TYPEOF_VOID,
+    TYPEOF_STRUCT,
+    TYPEOF_ARRAY,
+    TYPEOF_FUNCTION,
+    TYPEOF_POINTER,
+    TYPEOF_FPOINTER,
+    TYPEOF_CPOINTER,
+    TYPEOF_GPOINTER,
+    TYPEOF_PPOINTER,
+    TYPEOF_IPOINTER,
+    TYPEOF_EEPPOINTER
+};
 
 #define HASHTAB_SIZE 256
 
@@ -111,7 +132,7 @@ typedef struct specifier
     unsigned _stack;           /* stack offset for stacked v */
     unsigned _bitStart;                /* bit start position         */
     int _bitLength;            /* bit length                 */
-
+    int argreg;                /* reg no for regparm         */
     union
       {                                /* Values if constant or enum */
        short int v_int;                /* int and char values        */
@@ -185,6 +206,10 @@ typedef struct sym_link
       unsigned rbank:1;                /* seperate register bank     */
       unsigned intno;          /* 1=Interrupt svc routine    */
       unsigned regbank;                /* register bank 2b used      */
+      unsigned builtin;                /* is a builtin function      */
+      unsigned javaNative;     /* is a JavaNative Function (TININative ONLY) */
+      unsigned overlay;        /* force parameters & locals into overlay segment */
+      unsigned hasStackParms;   /* function has parameters on stack */
     } funcAttrs;
 
     struct sym_link *next;     /* next element on the chain  */
@@ -210,7 +235,6 @@ typedef struct symbol
     unsigned isinvariant:1;    /* is a loop invariant  */
     unsigned isstrlit:1;       /* is a string literal  */
     unsigned cdef:1;           /* compiler defined symbol */
-    unsigned allocreq:1;       /* allocation is required for this variable */
     unsigned addrtaken:1;      /* address of the symbol was taken */
     unsigned isreqv:1;         /* is the register quivalent of a symbol */
     unsigned udChked:1;                /* use def checking has been already done */
@@ -220,6 +244,7 @@ typedef struct symbol
        if a better scheme for backend is thought of */
     unsigned isLiveFcall:1;    /* is live at or across a function call */
     unsigned isspilt:1;                /* has to be spilt */
+    unsigned spillA:1;         /* spilt be register allocator */
     unsigned remat:1;          /* can be remateriazed */
     unsigned isptr:1;          /* is a pointer */
     unsigned uptr:1;           /* used as a pointer */
@@ -239,7 +264,10 @@ typedef struct symbol
                                   ACCUSE_A and ACCUSE_HL as the idea
                                   is quite similar.
                                 */
-
+    unsigned dptr;             /* 8051 variants with multiple DPTRS
+                                  currently implemented in DS390 only
+                               */
+    int allocreq ;             /* allocation is required for this variable */
     int stack;                 /* offset on stack      */
     int xstack;                        /* offset on xternal stack */
     short nRegs;               /* number of registers required */
@@ -273,6 +301,7 @@ typedef struct symbol
     int liveTo;                        /* live to sequence number */
     int used;                  /* no. of times this was used */
     int recvSize;              /* size of first argument  */
+    struct bitVect *clashes;    /* overlaps with what other symbols */
   }
 symbol;
 
@@ -296,10 +325,10 @@ symbol;
 #define IFFUNC_CALLEESAVES(x) (IS_FUNC(x) && FUNC_CALLEESAVES(x))
 #define FUNC_ISISR(x) (x->funcAttrs.intrtn)
 #define IFFUNC_ISISR(x) (IS_FUNC(x) && FUNC_ISISR(x))
-//#define FUNC_RBANK(x) (x->funcAttrs.rbank)
 #define IFFUNC_RBANK(x) (IS_FUNC(x) && FUNC_RBANK(x))
 #define FUNC_INTNO(x) (x->funcAttrs.intno)
 #define FUNC_REGBANK(x) (x->funcAttrs.regbank)
+#define FUNC_HASSTACKPARM(x) (x->funcAttrs.hasStackParms)
 
 #define FUNC_ISREENT(x) (x->funcAttrs.reent)
 #define IFFUNC_ISREENT(x) (IS_FUNC(x) && FUNC_ISREENT(x))
@@ -311,6 +340,13 @@ symbol;
 #define IFFUNC_BANKED(x) (IS_FUNC(x) && FUNC_BANKED(x))
 #define FUNC_ISCRITICAL(x) (x->funcAttrs.critical)
 #define IFFUNC_ISCRITICAL(x) (IS_FUNC(x) && FUNC_ISCRITICAL(x))
+#define FUNC_ISBUILTIN(x) (x->funcAttrs.builtin)
+#define IFFUNC_ISBUILTIN(x) (IS_FUNC(x) && FUNC_ISBUILTIN(x))
+#define FUNC_ISJAVANATIVE(x) (x->funcAttrs.javaNative)
+#define IFFUNC_ISJAVANATIVE(x) (IS_FUNC(x) && FUNC_ISJAVANATIVE(x))
+#define FUNC_ISOVERLAY(x) (x->funcAttrs.overlay)
+#define IFFUNC_ISOVERLAY(x) (IS_FUNC(x) && FUNC_ISOVERLAY(x))
+
 
 // jwk: I am not sure about this
 #define IFFUNC_ISBANKEDCALL(x) (!IFFUNC_NONBANKED(x) && \
@@ -346,6 +382,7 @@ symbol;
 #define SPEC_STRUCT(x) x->select.s.v_struct
 #define SPEC_TYPEDEF(x) x->select.s._typedef
 #define SPEC_REGPARM(x) x->select.s._isregparm
+#define SPEC_ARGREG(x) x->select.s.argreg
 
 /* type check macros */
 #define IS_DECL(x)   ( x && x->class == DECLARATOR     )
@@ -366,6 +403,7 @@ symbol;
 #define IS_GENPTR(x) (IS_DECL(x) && DCL_TYPE(x) == GPOINTER)
 #define IS_FUNC(x)   (IS_DECL(x) && DCL_TYPE(x) == FUNCTION)
 #define IS_LONG(x)   (IS_SPEC(x) && x->select.s._long)
+#define IS_UNSIGNED(x) (IS_SPEC(x) && x->select.s._unsigned)
 #define IS_TYPEDEF(x)(IS_SPEC(x) && x->select.s._typedef)
 #define IS_CONSTANT(x)  (IS_SPEC(x) && ( x->select.s._const == 1))
 #define IS_STRUCT(x) (IS_SPEC(x) && x->select.s.noun == V_STRUCT)
@@ -469,11 +507,12 @@ void addSymChain (symbol *);
 sym_link *structElemType (sym_link *, value *);
 symbol *getStructElement (structdef *, symbol *);
 sym_link *computeType (sym_link *, sym_link *);
-void processFuncArgs (symbol *, int);
+void processFuncArgs (symbol *);
 int isSymbolEqual (symbol *, symbol *);
 int powof2 (unsigned long);
 void printTypeChain (sym_link *, FILE *);
 void initCSupport ();
+void initBuiltIns ();
 void pointerTypes (sym_link *, sym_link *);
 void cdbTypeInfo (sym_link *, FILE *);
 void cdbSymbol (symbol *, FILE *, int, int);
@@ -487,7 +526,10 @@ void *findSymWithLevel (bucket **, struct symbol *);
 void *findSymWithBlock (bucket **, struct symbol *, int);
 void changePointer (symbol * sym);
 void checkTypeSanity(sym_link *etype, char *name);
-/* noun strings */
-extern char *nounName(sym_link *);
+sym_link *typeFromStr (char *) ;
+
+
+extern char *nounName(sym_link *); /* noun strings */
+extern void printFromToType (sym_link *, sym_link *);
 
 #endif