xref: /csrg-svn/old/pcc/c2.tahoe/c2.h (revision 29775)
1*29775Ssam /*	c2.h	1.3	86/08/14	*/
226439Ssam 
326439Ssam /*
426439Ssam  * Header for object code improver
526439Ssam  */
626439Ssam 
726439Ssam /* tokens */
8*29775Ssam typedef	enum {
9*29775Ssam 	NIL,
10*29775Ssam 	JBR, CBR, JMP, LABEL, DLABEL, EROU, JSW,
11*29775Ssam 	MOV, CLR, INC, DEC, TST, PUSH, CVT, MOVZ,
12*29775Ssam 	CMP, ADD, SUB, BIT, AND, OR, XOR, COM,
13*29775Ssam 	NEG, EMUL, MUL, DIV, EDIV, SHAL, SHAR,
14*29775Ssam 	SHL, SHR, CALLF, CALLS, CASE, ADDA, SUBA,
15*29775Ssam 	AOBLEQ, AOBLSS, MOVA, PUSHA, LDF, LNF, STF,
16*29775Ssam 	CMPF, CMPF2, TSTF, PUSHD, CVLF, CVFL, LDFD,
17*29775Ssam 	CVDF, NEGF, ADDF, SUBF, MULF, DIVF, SINF,
18*29775Ssam 	COSF, ATANF, LOGF, SQRTF, EXPF, MOVBLK,
19*29775Ssam 	MFPR, MTPR, PROBE, MOVO, TEXT, DATA, BSS,
20*29775Ssam 	ALIGN, END, LGEN, WGEN, SET, LCOMM, COMM
21*29775Ssam } OpCode;
2226439Ssam 
23*29775Ssam #define	ord(e)	((int)(e))
24*29775Ssam 
2526439Ssam #define	JEQ	0
2626439Ssam #define	JNE	1
2726439Ssam #define	JLE	2
2826439Ssam #define	JGE	3
2926439Ssam #define	JLT	4
3026439Ssam #define	JGT	5
3126439Ssam /* rearranged for unsigned branches so that jxxu = jxx + 6 */
3226439Ssam #define	JLOS	8
3326439Ssam #define	JHIS	9
3426439Ssam #define	JLO	10
3526439Ssam #define	JHI	11
3626439Ssam 
37*29775Ssam #define	JBC	12
38*29775Ssam #define	JBS	13
39*29775Ssam #define	RET	14
4026439Ssam 
4126439Ssam #define	BYTE	1
4226439Ssam #define	WORD	2
4326439Ssam #define LONG	3
4426439Ssam #define QUAD	4
4526439Ssam #define FLOAT	5
4626439Ssam #define DOUBLE	6
4726439Ssam #define OP2	7
4826439Ssam #define OP3	8
4926439Ssam #define OPB	9
5026439Ssam #define OPX	10
5126439Ssam 
52*29775Ssam #define	has2ops(p)	(((p)->subop>>4) == OP2)
53*29775Ssam #define	has3ops(p)	(((p)->subop>>4) == OP3)
54*29775Ssam 
5526439Ssam /* #define T(a,b) (a|((b)<<8)) NUXI problems */
5626439Ssam #define U(a,b) (a|((b)<<4))
5726439Ssam 
5826439Ssam #define C2_ASIZE 128
5926439Ssam 
6026439Ssam struct optab {
6126439Ssam 	char	opstring[7];
62*29775Ssam 	OpCode	opcod;
6326439Ssam 	unsigned char	subopcod;
6426439Ssam } optab[];
6526439Ssam 
6626439Ssam struct node {
67*29775Ssam 	OpCode	op;
6826439Ssam 	unsigned char	subop;
6926439Ssam 	short	refc;
7026439Ssam 	struct	node	*forw;
7126439Ssam 	struct	node	*back;
7226439Ssam 	struct	node	*ref;
7326439Ssam 	char	*code;
7426439Ssam 	struct	optab	*pop;
7526439Ssam 	long	labno;
7626439Ssam 	short	seq;
7726439Ssam };
7826439Ssam 
7929670Ssam struct intleavetab  {
80*29775Ssam 	OpCode		op;
8129670Ssam 	unsigned char	subop;
8229670Ssam 	int		intleavect;
8329670Ssam } intltab[];
8429670Ssam 
8526439Ssam /* struct { NUXI problems
8626439Ssam 	short	combop;
8726439Ssam }; */
8826439Ssam 
8926439Ssam char	line[512];
9026439Ssam struct	node	first;
9126439Ssam char	*curlp;
9226439Ssam int	nbrbr;
9326439Ssam int	nsaddr;
9426439Ssam int	redunm;
9526439Ssam int	iaftbr;
9626439Ssam int	njp1;
9726439Ssam int	nrlab;
9826439Ssam int	nxjump;
9926439Ssam int	ncmot;
10026439Ssam int	nrevbr;
10126439Ssam int	loopiv;
10226439Ssam int	nredunj;
10326439Ssam int	nskip;
10426439Ssam int	ncomj;
10526439Ssam int	naob;
10626439Ssam int	nrtst;
10726439Ssam int	nbj;
10826439Ssam int	nst;
10926439Ssam int	nld;
11026439Ssam 
11126439Ssam int	nchange;
11226439Ssam int	isn;
11326439Ssam int	debug;
11426439Ssam int	fortflg;
11529670Ssam int 	aobflag;
11626439Ssam char	*lasta;
11726439Ssam char	*lastr;
11826439Ssam char	*firstr;
11926439Ssam char	revbr[];
12026439Ssam #define	NREG	13
12126439Ssam /* 0-12, f.p. accumulator, 4 for operands, 1 for running off end */
12226439Ssam char	*regs[NREG+6];
12326439Ssam char	conloc[C2_ASIZE];
12426439Ssam char	conval[C2_ASIZE];
12526439Ssam char	ccloc[C2_ASIZE];
12626439Ssam 
12726439Ssam #define	ACC	NREG
12826439Ssam #define	RT1	NREG+1
12926439Ssam #define	RT2	NREG+2
13026439Ssam #define RT3	NREG+3
13126439Ssam #define RT4	NREG+4
13226439Ssam #define	LABHS	127
13326439Ssam 
13429670Ssam #define MAXAOBDISP	5000
13529670Ssam 
13626439Ssam #define NUSE 6
137*29775Ssam #define	tempreg(s,r)	((unsigned)((r)=isreg(s)) < NUSE)
138*29775Ssam 
13929670Ssam struct node *uses[NUSE + 7]; /* for backwards flow analysis */
14026439Ssam struct node *useacc; /* same for acc */
14126439Ssam char *lastrand; /* last operand of instruction */
14226439Ssam struct node *bflow();
14326439Ssam char *copy();
14426439Ssam long getnum();
14526439Ssam struct node *codemove();
14626439Ssam struct node *insertl();
14726439Ssam struct node *nonlab();
14826439Ssam struct node *alloc();
14926439Ssam char *findcon();
15026439Ssam char *byondrd();
15126439Ssam #define equstr !strcmp
15226439Ssam #define COPYCODE
153