view mc.h @ 117:2d5a203cc3a6

lvar reuse
author kono
date Fri, 21 Mar 2003 15:18:51 +0900
parents ebac635814dc
children b815fcd57b9d
line wrap: on
line source

/* Micro-C header file */

#define DEBUG	error(-1)

/*#include "CCLIB.TXT" */
#ifdef __micro_c__
#include "stdio.h"
#else
#include <stdio.h> 
#endif

#define SIZE_INT   4

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

#define STATIC	(-10)
#define GOTO	(-11)
#define RETURN	(-12)
#define BREAK	(-13)
#define CONTINUE	(-14)
#define IF	(-15)
#define ELSE	(-16)
#define FOR	(-17)
#define DO	(-18)
#define WHILE	(-19)
#define SWITCH	(-20)
#define CASE	(-21)
#define DEFAULT (-22)
#define RESERVE (-23)
#define TAG	(-24)
#define FIELD	(-25)
#define IDENT	(-26)
#define STRING	(-27)
#define MACRO	(-28)
#define BLABEL	(-29)
#define FLABEL	(-30)
#define TYPEDEF (-31)
#define SIZEOF	(-32)
#define TYPE	(-33)
#define LONG	(-34)
#define SHORT	(-35)
#define EXTRN	(-36)
#define EXTRN1	(-37)
#define VOID	(-38)
#define REGISTER	(-39)
#define CODE	(-40)
#define ENVIRONMENT	(-41)
#define DEFINED	(-42)
#define KONST	(-43)
#define FMACRO	(-44)
#define LMACRO	(-45)
#define DOTS	(-46)

#define FLOAT	(-47)
#define DOUBLE	(-48)
#define DREGISTER       (-49)
#define LONGLONG	(-50)

#define EMPTY	(-99)

#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 GVAR	1
#define RGVAR	2
#define CRGVAR	3
#define LVAR	4
#define RLVAR	5
#define CRLVAR	6
#define CONST	7
#define FNAME	8
#define INDIRECT	9
#define RINDIRECT	10
#define CRINDIRECT	11
#define ADDRESS 12
#define MINUS	13
#define LNOT	14
#define BNOT	15
#define INC	16
#define POSTINC 17
#define PREINC	18
#define CPOSTINC	19
#define CPREINC 20
#define DEC	21
#define CPOSTDEC	22
#define CPREDEC 23
#define MUL	24
#define UMUL	25
#define DIV	26
#define UDIV	27
#define MOD	28
#define UMOD	29
#define ADD	30
#define SUB	31
#define CMP     32	
#define RSHIFT	33
#define URSHIFT 34
#define LSHIFT	35
#define ULSHIFT 36
#define GT	37
#define UGT	38
#define GE	39
#define UGE	40
#define LT	41
#define ULT	42
#define LE	43
#define ULE	44
#define EQ	45
#define NEQ	46
#define BAND	47
#define EOR	48
#define BOR	49
#define LAND	50
#define LOR	51
#define COND	52
#define ASS	53
#define CASS	54
#define ASSOP	55
#define CASSOP	56
#define COMMA	57
#define LPAR	58
#define RPAR	59
#define LBRA	60
#define RBRA	61
#define LC	62
#define RC	63
#define COLON	64
#define SM	65
#define PERIOD	66
#define ARROW	67
#define CNAME	68
#define SASS	69
#define RSTRUCT	70

#define FASSOP	71
#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 DCMPGE	72
#define LMUL	73
#define LDIV	74
#define LADD	75
#define LSUB	76

#define FRGVAR	82
#define FRLVAR	83
#define FRINDIRECT	84
#define DRGVAR	85
#define DRLVAR	86
#define DRINDIRECT	87
#define LRGVAR	88
#define LRLVAR	89
#define LRINDIRECT	90
#define DCONST	91
#define FCONST	92
#define LCONST	93
#define DASS	94
#define FASS	95
#define LASS	96
#define SHASS	97

#define I2D	98
#define D2I	99
#define U2D	100
#define D2U	101
#define FPOSTINC	102
#define DPOSTINC	103
#define FPREINC	104
#define DPREINC	105
#define DCOND	106
#define CONV	107

#define US	1
#define AS	200
#define DOP	400

#define FILERR	1
#define DCERR	2
#define STERR	3
#define EXERR	4
#define CNERR	5
#define CHERR	6
#define GSERR	7
#define LSERR	8
#define STRERR	9
#define LNERR	10
#define EOFERR	11
#define MCERR	12
#define INCERR	13
#define HPERR	14
#define TYERR	15
#define LVERR	16
#define UDERR	17
#define OPTION	18
#define REG_ERR	19
#define CODE_ERR	20
#define MSERR   21

#define GSYMS	9000
#define LSYMS	500
#define MSYMS	3000

#define HEAPSIZE	10000
/* #define CHEAPSIZE	3000 */
#define CHEAPSIZE	256000
#define LBUFSIZE	4096
#define MACROSIZE	16000

#define FILES 10
#define OUTPUT_FILE_NAME "mcout.s"

EXTERN int sym,ch,type,mode,stmode,gfree,lfree,mflag,lineno,glineno;
EXTERN int labelno,gpc,disp,reg_var,debug;
EXTERN int symval,args,init_vars,heap[HEAPSIZE];
EXTERN int blabel,clabel,dlabel,cslabel,ilabel,control,ac,ac2,lsrc,chk,asmf;
EXTERN int MAX_REGISTER_VAR;
EXTERN double dsymval;

EXTERN unsigned hash;

EXTERN int chsave;
EXTERN int chptrsave;
EXTERN char linebuf[LBUFSIZE],namebuf[LBUFSIZE],*chptr;
EXTERN char *name,*cheapp,**av,/*obuf[320],*/*sptr,escape(void);
EXTERN int arg_offset,stat_no,size_of_int,disp_offset,endian,csvalue1;
EXTERN int code_arg_offset;
EXTERN int size_of_double,size_of_float,size_of_longlong;
EXTERN int retlabel,retpending,retcont;
EXTERN int arglist;

EXTERN FILE *obuf;

#if 0
typedef struct nametable {
	char *nm;
	int sc,ty,dsp; } NMTBL;
#else
typedef struct nametable {
	char *nm;
	int sc; int ty; int dsp; } NMTBL;
#endif

EXTERN NMTBL mtable[MSYMS];
EXTERN NMTBL ntable[GSYMS+LSYMS];
EXTERN NMTBL *nptr,*gnptr;
EXTERN NMTBL *fnptr;
EXTERN NMTBL null_nptr;
EXTERN int typedefed,gtypedefed;

EXTERN struct {int fd,ln;char *name0;FILE *fcb;} *filep,filestack[FILES];
EXTERN char cheap[CHEAPSIZE];
EXTERN char *macropp,macro_buf[MACROSIZE];

extern void error(int n);
extern int size(int t);
extern int scalar(int t);
extern int dlist2(int e1, double e2);
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 reverse0(int t1);
extern int assign_data(int e, int t, NMTBL *n,int offset);
extern int assign_expr0(int e1,int e2,int t,int type) ;
extern int assign_expr(int e1,int e2,int t,int type) ;
extern int append4(int p,int a1,int a2,int a3);



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

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

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

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

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

#include "conv/conv.h"
/*
#include "conv/c2cbc.h"
#include "conv/cbc2c.h"
 */

extern Converter *conv;

EXTERN void extern_define(char *s,int dsp,int type);
EXTERN void error(int n);
EXTERN int append4(int p,int a1,int a2,int a3);
EXTERN int assign_expr(int e1,int e2,int t,int type);
EXTERN int assign_expr0(int e1,int e2,int t,int type);
EXTERN int backdef(void);
EXTERN int fwdlabel(void);
EXTERN int glist2(int e1,int e2);
EXTERN int glist3(int e1,int e2,int e3);
EXTERN void free_glist2(int e1);
EXTERN void free_glist3(int e1);
EXTERN int integral(int t);
EXTERN int integral(int t);
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 reverse0(int t1);
EXTERN int rplacad(int e, int n);
EXTERN int rplacadd(int e, int n);
EXTERN int rvalue_t(int e,int type);
EXTERN int scalar(int t);
EXTERN void bexpr(int e1, char cond, int l1);
EXTERN void def_label(int cslabel, int dlabel);
EXTERN void display_ntable(NMTBL *n, char *s);
EXTERN void exit(int l);
EXTERN void fwddef(int l);
EXTERN int new_lvar(int size);

EXTERN void free_lvar(int lvar);
EXTERN void init_free_lvar_list();

/* end */