#define SDCC_SYMNAME_MAX 64
#define SDCC_NAME_MAX 3*SDCC_SYMNAME_MAX // big enough for _<func>_<var>_etc
#include "SDCChasht.h"
+#include "SDCCglobl.h"
enum {
TYPEOF_INT=1,
TYPEOF_EEPPOINTER
};
+// values for first byte of generic pointer.
+#define GPTYPE_NEAR 0
+#define GPTYPE_FAR 1
+#define GPTYPE_CODE 2
+#define GPTYPE_XSTACK 3
+#define GPTYPE_GPTR 4 // Never used?
+#define GPTYPE_IDATA 5
+
#define HASHTAB_SIZE 256
/* hash table bucket */
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 */
- char *v_char; /* character string */
- unsigned short v_uint; /* unsigned int const value */
- long v_long; /* long constant value */
- unsigned long v_ulong; /* unsigned long constant val */
- double v_float; /* floating point constant value */
+ TYPE_WORD v_int; /* 2 bytes: int and char values */
+ char *v_char; /* character string */
+ TYPE_UWORD v_uint; /* 2 bytes: unsigned int const value */
+ TYPE_DWORD v_long; /* 4 bytes: long constant value */
+ TYPE_UDWORD v_ulong; /* 4 bytes: unsigned long constant val */
+ double v_float; /* floating point constant value */
struct symbol *v_enum; /* ptr 2 enum_list if enum==1 */
}
const_val;
{
DECLARATOR_TYPE dcl_type; /* POINTER,ARRAY or FUNCTION */
unsigned int num_elem; /* # of elems if type==array */
- short ptr_const:1; /* pointer is constant */
- short ptr_volatile:1; /* pointer is volatile */
+ unsigned ptr_const:1; /* pointer is constant */
+ unsigned ptr_volatile:1; /* pointer is volatile */
struct sym_link *tspec; /* pointer type specifier */
}
declarator;
unsigned hasVargs:1; /* functions has varargs */
unsigned calleeSaves:1; /* functions uses callee save */
unsigned hasbody:1; /* function body defined */
- //unsigned ret:1; /* return statement for a function */
unsigned hasFcall:1; /* does it call other functions */
unsigned reent:1; /* function is reentrant */
unsigned naked:1; /* naked function */
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 */
unsigned isref:1; /* has been referenced */
unsigned isind:1; /* is a induction variable */
unsigned isinvariant:1; /* is a loop invariant */
- unsigned isstrlit:1; /* is a string literal */
unsigned cdef:1; /* compiler defined symbol */
unsigned addrtaken:1; /* address of the symbol was taken */
unsigned isreqv:1; /* is the register quivalent of a symbol */
unsigned spildir:1; /* spilt in direct space */
unsigned ptrreg:1; /* this symbol assigned to a ptr reg */
unsigned noSpilLoc:1; /* cannot be assigned a spil location */
+ unsigned isstrlit; /* is a string literal and it's usage count */
unsigned accuse; /* can be left in the accumulator
On the Z80 accuse is devided into
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 */
#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))
#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) && \
#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 )
#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_CONSTANT(x) (!x ? 0 : \
+ IS_SPEC(x) ? \
+ x->select.s._const == 1 : \
+ x->select.d.ptr_const)
#define IS_STRUCT(x) (IS_SPEC(x) && x->select.s.noun == V_STRUCT)
#define IS_ABSOLUTE(x) (IS_SPEC(x) && x->select.s._absadr )
#define IS_REGISTER(x) (IS_SPEC(x) && SPEC_SCLS(x) == S_REGISTER)
#define IS_VOID(x) (IS_SPEC(x) && x->select.s.noun == V_VOID)
#define IS_CHAR(x) (IS_SPEC(x) && x->select.s.noun == V_CHAR)
#define IS_EXTERN(x) (IS_SPEC(x) && x->select.s._extern)
-#define IS_VOLATILE(x) (IS_SPEC(x) && x->select.s._volatile )
+#define IS_VOLATILE(x) (!x ? 0 : \
+ IS_SPEC(x) ? \
+ x->select.s._volatile : \
+ 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_BIT || \
#define IS_ARITHMETIC(x) (IS_INTEGRAL(x) || IS_FLOAT(x))
#define IS_AGGREGATE(x) (IS_ARRAY(x) || IS_STRUCT(x))
#define IS_LITERAL(x) (IS_SPEC(x) && x->select.s.sclass == S_LITERAL)
+#define IS_CODE(x) (IS_SPEC(x) && SPEC_SCLS(x) == S_CODE)
#define IS_REGPARM(x) (IS_SPEC(x) && SPEC_REGPARM(x))
/* forward declaration for the global vars */
structdef *newStruct (char *);
void addDecl (symbol *, int, sym_link *);
sym_link *mergeSpec (sym_link *, sym_link *, char *name);
-sym_link *cloneSpec (sym_link *);
symbol *reverseSyms (symbol *);
sym_link *reverseLink (sym_link *);
symbol *copySymbol (symbol *);