view mc.h @ 523:009289571b54

*** empty log message ***
author kono
date Tue, 27 Dec 2005 17:57:24 +0900
parents e58848f6ebc1
children 9ff5cd7afe2f
line wrap: on
line source

/* Micro-C header file */

#define FLOAT_CODE 1
#define LONGLONG_CODE 1
#define CASE_CODE 1
#define ASM_CODE 1
#define BIT_FIELD_CODE 1

/* reserved word start */

/* type ( keyword ) */

#define INT     (-1)
#define UNSIGNED        (-2)
#define CHAR    (-3)
#define UCHAR   (-4)
#define POINTER (-5)
#define ARRAY   (-6)
#define STRUCT  (-7)
#define UNION   (-8)
#define FUNCTION        (-9)

#define SIGNED  (-10)
#define LONG    (-11)
#define SHORT   (-12)
#define USHORT  (-13)
#define VOID    (-14)
#define CODE    (-15)
#define ENUM    (-16)

#define FLOAT   (-17)
#define DOUBLE  (-18)
#define LONGLONG        (-19)
#define ULONGLONG       (-20)

/* type qualifier */

#define KONST   (-21)
#define STATIC  (-22)
#define EXTRN   (-23)
#define EXTRN1  (-24)
#define VOLATILE        (-25)
#define RESTRICT        (-26)
#define INLINE  (-27)
#define REGISTER        (-28)
#define FREGISTER       (-29)
#define DREGISTER       (-30)
#define LREGISTER       (-31)

#define DOTS    (-32)

/* keyword */

#define GOTO    (-33)
#define RETURN  (-34)
#define BREAK   (-35)
#define CONTINUE        (-36)
#define IF      (-37)
#define ELSE    (-38)
#define FOR     (-39)
#define DO      (-40)
#define WHILE   (-41)
#define SWITCH  (-42)
#define CASE    (-43)
#define DEFAULT (-44)
#define RESERVE (-45)
#define TAG     (-46)
#define FIELD   (-47)
#define IDENT   (-48)
#define MACRO   (-49)
#define BLABEL  (-50)
#define FLABEL  (-51)
#define TYPEDEF (-52)
#define SIZEOF  (-53)
#define TYPE    (-54)
#define DEFINED (-55)

#define ENVIRONMENT     (-56)

#define FMACRO  (-57)
#define LMACRO  (-58)

#define TYPEOF  (-59)
#define ASM     (-60)

/* reserved word end */

#define EMPTY   (-99)

/* mode start */
#define TOP     0
#define GDECL   1
#define GSDECL  2
#define GUDECL  3
#define ADECL   4
#define LDECL   5
#define LSDECL  6
#define LUDECL  7
#define STADECL 8
#define STAT    9
#define GTDECL  10
#define LTDECL  11
#define IFDEF   12
#define MDECL   13
#define GEDECL  14
#define LEDECL  15
#define LLDECL  16
#define SFDINIT 17
/* mode end */

#define US      1
#define AS      10000
#define SOP     200
#define COP     400
#define DOP     600
#define FOP     800
#define LOP     1000

/* tree node tags start */

#define LIST_ARGS(i) (i==FUNCTION||i==CODE||i==ASM)

/* nullary  argments */

#define GVAR   	1
#define RGVAR  	2
#define URGVAR 	3
#define LVAR   	4
#define RLVAR  	5
#define URLVAR 	6
#define CRGVAR  (COP+RGVAR)
#define CURGVAR (COP+URGVAR)
#define CRLVAR  (COP+RLVAR)
#define CURLVAR (COP+URLVAR)
#define FRGVAR  (FOP+RGVAR)
#define FRLVAR  (FOP+RLVAR)
#define DRGVAR  (DOP+RGVAR)
#define DRLVAR  (DOP+RLVAR)
#define SRGVAR  (SOP+RGVAR)
#define SURGVAR (SOP+URGVAR)
#define SRLVAR  (SOP+RLVAR)
#define SURLVAR (SOP+URLVAR)
#define LRGVAR  (LOP+RGVAR)
#define LURGVAR (LOP+URGVAR)
#define LRLVAR  (LOP+RLVAR)
#define LURLVAR (LOP+URLVAR)

#define CONST  	7
#define DCONST  (DOP+CONST)
#define FCONST  (FOP+CONST)
#define LCONST  (LOP+CONST)
#define STRING 	8
#define FNAME  	9
#define LCALL  	10
#define COMMENT  	11
#define DECL  	12
#define COMP  	13
#define LABEL  	14
#define IVAR  	15

#define NULLARY_ARGS(i) (i==RETURN||i==ENVIRONMENT||i==LCALL||i==REGISTER||i==DREGISTER||i==FREGISTER||i==LREGISTER||(GVAR<=(i%SOP)&&(i%SOP)<=LABEL))

/* unary  argments */

#define ADDRESS	16
#define MINUS  	17
#define LNOT   	18
#define BNOT   	19
#define INC    	20
#define POSTINC	21
#define UPOSTINC       	22
#define PREINC 	23
#define UPREINC	24
#define POSTDEC	25
#define UPOSTDEC       	26
#define PREDEC 	27
#define UPREDEC	28
#define DEC    	29
#define CPOSTINC (COP+POSTINC)
#define CUPOSTINC (COP+UPOSTINC)
#define CPREINC (COP+PREINC)
#define CUPREINC (COP+UPREINC)
#define CPOSTDEC (COP+POSTDEC)
#define CUPOSTDEC (COP+UPOSTDEC)
#define CPREDEC (COP+CPREDEC)
#define CUPREDEC (COP+UPREDEC)
#define SPOSTINC (SOP+POSTINC)
#define SUPOSTINC (SOP+UPOSTINC)
#define SPREINC (SOP+PREINC)
#define SUPREINC (SOP+UPREINC)
#define SPOSTDEC (SOP+POSTDEC)
#define SUPOSTDEC (SOP+UPOSTDEC)
#define SPREDEC (SOP+PREDEC)
#define SUPREDEC (SOP+UPREDEC)
#define FPOSTINC        (FOP+POSTINC)
#define FPREINC (FOP+PREINC)
#define DPOSTINC        (DOP+POSTINC)
#define DPREINC (DOP+PREINC)
#define LPOSTINC        (LOP+POSTINC)
#define LPREINC (LOP+PREINC)
#define LUPOSTINC       (LOP+UPOSTINC)
#define LUPREINC        (LOP+UPREINC)
#define INDIRECT       	30
#define RINDIRECT      	31
#define URINDIRECT     	32
#define CRINDIRECT      (COP+RINDIRECT)
#define CURINDIRECT     (COP+URINDIRECT)
#define SRINDIRECT      (SOP+RINDIRECT)
#define SURINDIRECT     (SOP+URINDIRECT)
#define FRINDIRECT      (FOP+RINDIRECT)
#define DRINDIRECT      (DOP+RINDIRECT)
#define LRINDIRECT      (LOP+RINDIRECT)
#define LURINDIRECT     (LOP+URINDIRECT)
#define RSTRUCT	33
#define ALLOCA 	34
#define BUILTINP 	35
#define BUILTIN_EXPECT 	36
#define ATTRIBUTE 	37
#define BIT_FIELD 	38
#define RBIT_FIELD 	39
#define BPREINC 	40
#define BPOSTINC 	41
#define CONV   	42

#define UNARY_ARGS(i) (ADDRESS<=(i%SOP)&&(i%SOP)<=CONV)

/* binary  argments */

#define MUL    	43
#define UMUL   	44
#define DIV    	45
#define UDIV   	46
#define MOD    	47
#define UMOD   	48
#define ADD    	49
#define SUB    	50
#define CMP    	51      
#define RSHIFT 	52
#define URSHIFT	53
#define LSHIFT 	54
#define ULSHIFT	55
#define GT     	56
#define UGT    	57
#define GE     	58
#define UGE    	59
#define LT     	60
#define ULT    	61
#define LE     	62
#define ULE    	63
#define EQ     	64
#define NEQ    	65
#define BAND   	66
#define EOR    	67
#define BOR    	68
#define LAND   	69
#define LOR    	70
#define ASS    	71
#define UCMP   	72
#define UCMPGE 	73
#define CMPGE  	74
#define CMPEQ  	75
#define CMPNEQ 	76
#define ASSOP  	77
#define COMMA  	78

#define CASS   	79
#define CASSOP 	80
#define CUASSOP	81

#define SASS    (SOP+CASS)
#define SASSOP (SOP+CASSOP)
#define SUASSOP (SOP+CUASSOP)

#define DASS    (DOP+ASS)
#define DCMPGE  (DOP+CMPGE)
#define DCMPEQ  (DOP+CMPEQ)
#define DCMPNEQ (DOP+CMPNEQ)
#define DASSOP  (DOP+ASSOP)
#define DCMP    (DOP+CMP)
#define DMINUS  (DOP+MINUS)
#define DMUL    (DOP+MUL)
#define DDIV    (DOP+DIV)
#define DADD    (DOP+ADD)
#define DSUB    (DOP+SUB)

#define FASS    (FOP+ASS)
#define FCMPGE  (FOP+CMPGE)
#define FCMPEQ  (FOP+CMPEQ)
#define FCMPNEQ (FOP+CMPNEQ)
#define FASSOP  (FOP+ASSOP)
#define FCMP    (FOP+CMP)
#define FMINUS  (FOP+MINUS)
#define FMUL    (FOP+MUL)
#define FDIV    (FOP+DIV)
#define FADD    (FOP+ADD)
#define FSUB    (FOP+SUB)

#define LASS    (LOP+CASS)
#define LCMPGE  (LOP+CMPGE)
#define LCMPEQ  (LOP+CMPEQ)
#define LCMPNEQ (LOP+CMPNEQ)
#define LASSOP  (LOP+CASSOP)
#define LUASSOP (LOP+CUASSOP)
#define LCMP    (LOP+CMP)
#define LMINUS  (LOP+MINUS)
#define LMUL    (LOP+MUL)
#define LDIV    (LOP+DIV)
#define LUMUL   (LOP+UMUL)
#define LUDIV   (LOP+UDIV)
#define LADD    (LOP+ADD)
#define LSUB    (LOP+SUB)


#define LMOD    (LOP+MOD)
#define LUMOD   (LOP+UMOD)
#define LLSHIFT (LOP+LSHIFT)
#define LULSHIFT        (LOP+ULSHIFT)
#define LRSHIFT (LOP+RSHIFT)
#define LURSHIFT        (LOP+URSHIFT)
#define LBAND   (LOP+BAND)
#define LEOR    (LOP+EOR)
#define LBOR    (LOP+BOR)

#define BASS   	82
#define BASSOP 	83
#define BFD_REPL 	84

#define STASS  	85


#define BINARY_ARGS(i) (MUL<=(i%SOP)&&(i%SOP)<=STASS)

/* tarnary  argments */

#define COND   	86
#define UCOND  	87
#define SCOND   (SOP+COND)
#define SUCOND   (SOP+UCOND)
#define DCOND   (DOP+COND)
#define FCOND   (FOP+COND)
#define LCOND   (LOP+COND)
#define LUCOND  (LOP+UCOND)

#define TARNARY_ARGS(i) (COND==(i%SOP)||UCOND==(i%SOP))

/* not appeared as tags */

#define LPAR   	88
#define RPAR   	89
#define LBRA   	90
#define RBRA   	91
#define LC     	92
#define RC     	93
#define COLON  	94
#define SM     	95
#define PERIOD 	96
#define ARROW  	97
#define CNAME  	98

#define I2C  	99
#define I2S  	100
#define I2I    	101
#define I2U    	102
#define I2D    	103
#define I2F    	104
#define I2LL   	105
#define I2ULL  	106

#define U2UC  	107
#define U2US  	108
#define U2I    	109
#define U2U    	110
#define U2D    	111
#define U2F    	112
#define U2LL   	113
#define U2ULL  	114


#define D2I     (DOP+I2I)
#define D2U     (DOP+I2U)
#define D2D     (DOP+I2D)
#define D2F     (DOP+I2F)
#define D2LL    (DOP+I2LL)
#define D2ULL   (DOP+I2ULL)

#define F2I     (FOP+I2I)
#define F2U     (FOP+I2U)
#define F2D     (FOP+I2D)
#define F2F     (FOP+I2F)
#define F2LL    (FOP+I2LL)
#define F2ULL   (FOP+I2ULL)

#define LL2I    (LOP+I2I)
#define LL2U    (LOP+I2U)
#define LL2D    (LOP+I2D)
#define LL2F    (LOP+I2F)
#define LL2LL   (LOP+I2LL)
#define LL2ULL  (LOP+I2ULL)

#define ULL2I   (LOP+U2I)
#define ULL2U   (LOP+U2U)
#define ULL2D   (LOP+U2D)
#define ULL2F   (LOP+U2F)
#define ULL2LL  (LOP+U2LL)
#define ULL2ULL (LOP+U2ULL)

/* tree node tags end */

/* statement start */

#define ST_DECL		115
#define ST_IF		116
#define ST_DO		117
#define ST_WHILE	118
#define ST_FOR		119
#define ST_SWITCH	120
#define ST_COMP		121
#define ST_BREAK	122
#define ST_CONTINUE	123
#define ST_CASE		124
#define ST_DEFAULT	125
#define ST_RETURN	126
#define ST_GOTO		127
#define ST_ASM		128
#define ST_LABEL	129
#define ST_COMMENT	130

#define IS_STATEMENT(i) (i==INLINE||(ST_DECL<=i&&i<=ST_COMMENT))

/* statement end */

/* error number start */

#define FILERR  1
#define DCERR   2
#define RDERR   3
#define STERR   4
#define EXERR   5
#define CNERR   6
#define CHERR   7
#define GSERR   8
#define LSERR   9
#define STRERR  10
#define LNERR   11
#define EOFERR  12
#define MCERR   13
#define INCERR  14
#define HPERR   15
#define TYERR   16
#define LVERR   17
#define UDERR   18
#define OPTION  19
#define REG_ERR 20
#define RGERR 21
#define CODE_ERR        22
#define MSERR   23
#define BTERR   24
#define HSERR   25
#define NMERR   26
#define MMERR   27
#define INERR   28
#define AGERR   29
#define ILERR   30

/* error number end */

#define KONST_BIT	1
#define VOLATILE_BIT	2
#define RESTRICT_BIT	4

#define FILES 10
#define MAX_INCLUDE_PATH_COUNT 10
/*
    For this comiler 8192*2 is Ok. Linux kernel requires 8192*4.
 */
#define GSYMS		(8192*4)
#define HEAPSIZE        30000
#define CHEAPSIZE       (sizeof(NMTBL)*8192)
#define LBUFSIZE        4096
#define STRSIZE		4096

typedef struct nametable {
        char *nm;
	struct nametable *next;
        int sc,attr;
	int ty,dsp; } NMTBL;

extern int *heap;                   /* heap area (in cheap ) */
extern NMTBL *global_list;          /* list of all global NMTBL */
extern NMTBL *local_static_list;    /* list of local static variable */

#if FLOAT_CODE
extern int dlist2(int e1, double e2);
#endif
#if LONGLONG_CODE
extern int llist2(int e1, long long e2);
#endif
extern int list2(int e1, int e2);
extern int list3(int e1, int e2, int e3);
extern int list4(int e1, int e2, int e3,int e4);
extern int list5(int e1, int e2, int e3,int e4,int e5);
extern int length(int e1);
extern int getfree(int size);
extern int nth(int n,int e1);
extern int reverse0(int t1);
extern int append4(int p,int a1,int a2,int a3);
extern int append5(int p,int a1,int a2,int a3,int a4);
extern int insert_ascend(int p,int e,int eq());

extern void free_nptr(NMTBL *n);
extern NMTBL *get_nptr();

#if 1
extern int heapsize;
#define CHECK_HEAP(b) ({int _k=(int)(b);if(_k>heapsize||_k<0)error(-1);_k;})
#else
#define CHECK_HEAP(b)  (b)
#endif

#define car(e) (heap[(int)(CHECK_HEAP(e))])

#define cadr(e) (heap[((int)(CHECK_HEAP(e)))+1])

#define caddr(e) (heap[((int)(CHECK_HEAP(e)))+2])

#define cadddr(e) (heap[((int)(CHECK_HEAP(e)))+3])

#define caddddr(e) (heap[((int)(CHECK_HEAP(e)))+4])

#if FLOAT_CODE
#define dcadr(e) (*(double*)&heap[((int)(e))+1])
#define dcaddr(e) (*(double*)&heap[((int)(e))+2])
#endif

#if LONGLONG_CODE
#define lcadr(e) (*(long long*)&heap[((int)(e))+1])
#define lcaddr(e) (*(long long*)&heap[((int)(e))+2])
#endif

/* end */