* doc/Makefile,
[fw/sdcc] / src / SDCCsymt.h
index d13e58edad648c42c9121a237b43b4d0757f8894..68992145a7fe1c95eaaa00055ffa9f3fc7e8c3a2 100644 (file)
 #include "SDCChasht.h"
 #include "SDCCglobl.h"
 
+#define INTNO_MAX 255                  /* maximum allowed interrupt number */
+#define INTNO_UNSPEC (INTNO_MAX+1)     /* interrupt number unspecified */
+
+#define BITVAR_PAD -1
+
 enum {
     TYPEOF_INT=1,
     TYPEOF_SHORT,
@@ -37,6 +42,7 @@ enum {
     TYPEOF_LONG,
     TYPEOF_FLOAT,
     TYPEOF_BIT,
+    TYPEOF_BITFIELD,
     TYPEOF_SBIT,
     TYPEOF_SFR,
     TYPEOF_VOID,
@@ -80,6 +86,7 @@ typedef struct structdef
     unsigned char level;       /* Nesting level         */
     struct symbol *fields;     /* pointer to fields     */
     unsigned size;             /* sizeof the table in bytes  */
+    int type;                  /* STRUCT or UNION */
   }
 structdef;
 
@@ -93,6 +100,7 @@ typedef enum
     V_STRUCT,
     V_LABEL,
     V_BIT,
+    V_BITFIELD,
     V_SBIT,
     V_DOUBLE
   }
@@ -216,7 +224,7 @@ typedef struct sym_link
       unsigned intrtn:1;       /* this is an interrupt routin */
       unsigned rbank:1;                /* seperate register bank     */
       unsigned intno;          /* 1=Interrupt svc routine    */
-      unsigned regbank;                /* register bank 2b used      */
+      short    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 */
@@ -289,6 +297,8 @@ typedef struct symbol
     struct iCode *fuse;                /* furthest use */
     struct iCode *rematiCode;  /* rematerialse with which instruction */
     struct operand *reqv;      /* register equivalent of a local variable */
+    struct symbol *prereqv;    /* symbol before register equiv. substituion */
+    struct symbol *psbase;     /* if pseudo symbol, the symbol it is based on */
     union
       {
        struct symbol *spillLoc;        /* register spil location */
@@ -299,6 +309,7 @@ typedef struct symbol
     unsigned offset;           /* offset from top if struct */
 
     int lineDef;               /* defined line number        */
+    char *fileDef;             /* defined filename           */
     int lastLine;              /* for functions the last line */
     struct sym_link *type;     /* 1st link to declator chain */
     struct sym_link *etype;    /* last link to declarator chn */
@@ -364,8 +375,6 @@ extern sym_link *validateLink(sym_link      *l,
 #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) && \
   (options.model == MODEL_LARGE || \
    options.model == MODEL_MEDIUM || \
@@ -373,6 +382,7 @@ extern sym_link *validateLink(sym_link      *l,
 
 #define SPEC_NOUN(x) validateLink(x, "SPEC_NOUN", #x, SPECIFIER, __FILE__, __LINE__)->select.s.noun
 #define SPEC_LONG(x) validateLink(x, "SPEC_LONG", #x, SPECIFIER, __FILE__, __LINE__)->select.s._long
+#define SPEC_SHORT(x) validateLink(x, "SPEC_LONG", #x, SPECIFIER, __FILE__, __LINE__)->select.s._short
 #define SPEC_USIGN(x) validateLink(x, "SPEC_USIGN", #x, SPECIFIER, __FILE__, __LINE__)->select.s._unsigned
 #define SPEC_SCLS(x) validateLink(x, "SPEC_SCLS", #x, SPECIFIER, __FILE__, __LINE__)->select.s.sclass
 #define SPEC_ENUM(x) validateLink(x, "SPEC_ENUM", #x, SPECIFIER, __FILE__, __LINE__)->select.s._isenum
@@ -441,11 +451,15 @@ extern sym_link *validateLink(sym_link    *l,
                           x->select.d.ptr_volatile)
 #define IS_INTEGRAL(x) (IS_SPEC(x) && (x->select.s.noun == V_INT ||  \
                                        x->select.s.noun == V_CHAR || \
+                                       x->select.s.noun == V_BITFIELD || \
                                        x->select.s.noun == V_BIT ||  \
                                        x->select.s.noun == V_SBIT ))
-#define IS_BITFIELD(x) (IS_SPEC(x) && (x->select.s.noun == V_BIT))
-#define IS_BITVAR(x) (IS_SPEC(x) && (x->select.s.noun  == V_BIT ||   \
+#define IS_BITFIELD(x) (IS_SPEC(x) && (x->select.s.noun == V_BITFIELD))
+#define IS_BITVAR(x) (IS_SPEC(x) && (x->select.s.noun == V_BITFIELD || \
+                                     x->select.s.noun  == V_BIT ||   \
                                      x->select.s.noun == V_SBIT ))
+#define IS_BIT(x) (IS_SPEC(x) && (x->select.s.noun  == V_BIT ||   \
+                                  x->select.s.noun == V_SBIT ))
 #define IS_FLOAT(x)  (IS_SPEC(x) && x->select.s.noun == V_FLOAT)
 #define IS_ARITHMETIC(x) (IS_INTEGRAL(x) || IS_FLOAT(x))
 #define IS_AGGREGATE(x) (IS_ARRAY(x) || IS_STRUCT(x))
@@ -453,6 +467,9 @@ extern sym_link *validateLink(sym_link      *l,
 #define IS_CODE(x)      (IS_SPEC(x)  && SPEC_SCLS(x) == S_CODE)
 #define IS_REGPARM(x)   (IS_SPEC(x) && SPEC_REGPARM(x))
 
+/* symbol check macros */
+#define IS_AUTO(x) (x->level && !IS_STATIC(x->etype) && !IS_EXTERN(x->etype))
+
 /* forward declaration for the global vars */
 extern bucket *SymbolTab[];
 extern bucket *StructTab[];
@@ -491,6 +508,17 @@ extern sym_link *floatType;
 
 #include "SDCCval.h"
 
+typedef enum
+{
+  RESULT_TYPE_NONE = 0,        /* operands will be promoted to int */
+  RESULT_CHECK = 0, /* TODO: replace all occurences with the appropriate type and remove me */
+  RESULT_TYPE_BIT,
+  RESULT_TYPE_CHAR,
+  RESULT_TYPE_INT,
+  RESULT_TYPE_OTHER,   /* operands will be promoted to int */
+  RESULT_TYPE_IFX,
+} RESULT_TYPE;
+
 /* forward definitions for the symbol table related functions */
 void initSymt ();
 symbol *newSymbol (char *, int);
@@ -517,11 +545,13 @@ value *checkStructIval (symbol *, value *);
 value *checkArrayIval (sym_link *, value *);
 value *checkIval (sym_link *, value *);
 unsigned int getSize (sym_link *);
+unsigned int getAllocSize (sym_link *);
 unsigned int bitsForType (sym_link *);
 sym_link *newIntLink ();
 sym_link *newCharLink ();
 sym_link *newLongLink ();
 int compareType (sym_link *, sym_link *);
+int compareTypeExact (sym_link *, sym_link *, int);
 int checkFunction (symbol *, symbol *);
 void cleanUpLevel (bucket **, int);
 void cleanUpBlock (bucket **, int);
@@ -529,17 +559,16 @@ int funcInChain (sym_link *);
 void addSymChain (symbol *);
 sym_link *structElemType (sym_link *, value *);
 symbol *getStructElement (structdef *, symbol *);
-sym_link *computeType (sym_link *, sym_link *);
+sym_link *computeType (sym_link *, sym_link *, RESULT_TYPE, int);
 void processFuncArgs (symbol *);
 int isSymbolEqual (symbol *, symbol *);
-int powof2 (unsigned long);
+int powof2 (TYPE_UDWORD);
 void printTypeChain (sym_link *, FILE *);
+void printTypeChainRaw (sym_link *, FILE *);
 void initCSupport ();
 void initBuiltIns ();
 void pointerTypes (sym_link *, sym_link *);
-void cdbTypeInfo (sym_link *, FILE *);
-void cdbSymbol (symbol *, FILE *, int, int);
-void cdbStructBlock (int, FILE *);
+void cdbStructBlock (int);
 void initHashT ();
 bucket *newBucket ();
 void addSym (bucket **, void *, char *, int, int, int checkType);
@@ -547,9 +576,12 @@ void deleteSym (bucket **, void *, char *);
 void *findSym (bucket **, void *, const char *);
 void *findSymWithLevel (bucket **, struct symbol *);
 void *findSymWithBlock (bucket **, struct symbol *, int);
-void changePointer (symbol * sym);
+void changePointer (sym_link * p);
 void checkTypeSanity(sym_link *etype, char *name);
 sym_link *typeFromStr (char *) ;
+STORAGE_CLASS sclsFromPtr(sym_link *ptr);
+sym_link *newEnumType (symbol *);
+void  promoteAnonStructs (int, structdef *);
 
 
 extern char *nounName(sym_link *); /* noun strings */