xref: /csrg-svn/old/pcc/c2.vax/c2.h (revision 24398)
1*24398Smckusick /*	c2.h	4.10	85/08/22	*/
214573Ssam 
31494Sbill /*
41494Sbill  * Header for object code improver
51494Sbill  */
61494Sbill 
71494Sbill #define	JBR	1
81494Sbill #define	CBR	2
91494Sbill #define	JMP	3
101494Sbill #define	LABEL	4
111494Sbill #define	DLABEL	5
121494Sbill #define	EROU	7
131494Sbill #define	JSW	9
141494Sbill #define	MOV	10
151494Sbill #define	CLR	11
161494Sbill #define	INC	12
171494Sbill #define	DEC	13
181494Sbill #define	TST	14
191494Sbill #define	PUSH	15
201494Sbill #define CVT 16
211494Sbill #define	CMP	17
221494Sbill #define	ADD	18
231494Sbill #define	SUB	19
241494Sbill #define	BIT	20
251494Sbill #define	BIC	21
261494Sbill #define	BIS	22
271494Sbill #define	XOR	23
281494Sbill #define	COM	24
291494Sbill #define	NEG	25
301494Sbill #define	MUL	26
311494Sbill #define	DIV	27
321494Sbill #define	ASH	28
331494Sbill #define EXTV	29
341494Sbill #define EXTZV	30
351494Sbill #define INSV	31
361494Sbill #define	CALLS	32
371494Sbill #define RET	33
381494Sbill #define	CASE	34
391494Sbill #define	SOB	35
401494Sbill #define	TEXT	36
411494Sbill #define	DATA	37
421494Sbill #define	BSS	38
431494Sbill #define	ALIGN	39
441494Sbill #define	END	40
451494Sbill #define MOVZ 41
461494Sbill #define WGEN 42
471494Sbill #define SOBGEQ 43
481494Sbill #define SOBGTR 44
491494Sbill #define AOBLEQ 45
501494Sbill #define AOBLSS 46
511494Sbill #define ACB 47
521494Sbill #define MOVA 48
531494Sbill #define PUSHA 49
541494Sbill #define LGEN 50
551494Sbill #define SET 51
561494Sbill #define MOVC3 52
571494Sbill #define RSB 53
581494Sbill #define JSB 54
591494Sbill #define MFPR 55
601494Sbill #define MTPR 56
611494Sbill #define PROBER 57
621494Sbill #define PROBEW 58
631507Sbill #define	LCOMM 59
641507Sbill #define	COMM 60
651494Sbill 
661494Sbill #define	JEQ	0
671494Sbill #define	JNE	1
681494Sbill #define	JLE	2
691494Sbill #define	JGE	3
701494Sbill #define	JLT	4
711494Sbill #define	JGT	5
721494Sbill /* rearranged for unsigned branches so that jxxu = jxx + 6 */
731494Sbill #define	JLOS	8
741494Sbill #define	JHIS	9
751494Sbill #define	JLO	10
761494Sbill #define	JHI	11
771494Sbill 
781494Sbill #define JBC 12
791494Sbill #define JBS 13
801494Sbill #define JLBC 14
811494Sbill #define JLBS 15
821494Sbill #define JBCC 16
831494Sbill #define JBSC 17
841494Sbill #define JBCS 18
851494Sbill #define JBSS 19
861494Sbill 
8717719Sralph #define	JCC 20
8817719Sralph #define	JCS 21
8917719Sralph #define	JVC 22
9017719Sralph #define	JVS 23
9117719Sralph 
925794Sroot /*
935794Sroot  *	When the new opcodes were added, the relative
945794Sroot  *	ordering of the first 3 (those that are not float)
955794Sroot  *	had to be retained, so that other parts of the program
965794Sroot  *	were not broken.
975794Sroot  *
985794Sroot  *	In addition, the distance between OP3 and OP2 must be preserved.
995794Sroot  *	The order of definitions above OP2 must not be changed.
1005794Sroot  *
1015794Sroot  *	Note that these definitions DO NOT correspond to
1025794Sroot  *	those definitions used in as, adb and sdb.
1035794Sroot  */
1041494Sbill #define	BYTE	1
1051494Sbill #define	WORD	2
1061494Sbill #define LONG	3
1075794Sroot #define	FFLOAT	4
1085794Sroot #define	DFLOAT	5
1096955Srrh #define QUAD	6
1106955Srrh #define OP2	7
1116955Srrh #define OP3	8
1126955Srrh #define OPB	9
1136955Srrh #define OPX	10
1146955Srrh #define	GFLOAT	11
1156955Srrh #define	HFLOAT	12
1166955Srrh #define OCTA	13
1171494Sbill 
1181494Sbill #define T(a,b) (a|((b)<<8))
1191494Sbill #define U(a,b) (a|((b)<<4))
1201494Sbill 
1212844Stoy #define C2_ASIZE 128
1222829Stoy 
1231494Sbill struct optab {
1241494Sbill 	char	opstring[7];
1251494Sbill 	short	opcode;
1261494Sbill } optab[];
1271494Sbill 
1281494Sbill struct node {
12918380Sralph 	union {
13018380Sralph 		struct {
13118380Sralph 			char op_op;
13218380Sralph 			char op_subop;
13318380Sralph 		} un_op;
13418380Sralph 		short	un_combop;
13518380Sralph 	} op_un;
1361494Sbill 	short	refc;
1371494Sbill 	struct	node	*forw;
1381494Sbill 	struct	node	*back;
1391494Sbill 	struct	node	*ref;
1401494Sbill 	char	*code;
1411494Sbill 	struct	optab	*pop;
1421507Sbill 	long	labno;
1431494Sbill 	short	seq;
1441494Sbill };
1451494Sbill 
14618380Sralph #define op op_un.un_op.op_op
14718380Sralph #define subop op_un.un_op.op_subop
14818380Sralph #define combop op_un.un_combop
1491494Sbill 
1501494Sbill char	line[512];
1511494Sbill struct	node	first;
1521494Sbill char	*curlp;
1531494Sbill int	nbrbr;
1541494Sbill int	nsaddr;
1551494Sbill int	redunm;
1561494Sbill int	iaftbr;
1571494Sbill int	njp1;
1581494Sbill int	nrlab;
1591494Sbill int	nxjump;
1601494Sbill int	ncmot;
1611494Sbill int	nrevbr;
1621494Sbill int	loopiv;
1631494Sbill int	nredunj;
1641494Sbill int	nskip;
1651494Sbill int	ncomj;
1661494Sbill int	nsob;
1671494Sbill int	nrtst;
1681494Sbill int nbj;
1691494Sbill int nfield;
1701494Sbill 
1711494Sbill int	nchange;
17218380Sralph long	isn;
1731494Sbill int	debug;
1741494Sbill char	revbr[];
1751494Sbill #define	NREG	12
1761494Sbill char	*regs[NREG+5]; /* 0-11, 4 for operands, 1 for running off end */
1772829Stoy char	conloc[C2_ASIZE];
1782829Stoy char	conval[C2_ASIZE];
1792829Stoy char	ccloc[C2_ASIZE];
1801494Sbill 
1811494Sbill #define	RT1	12
1821494Sbill #define	RT2	13
1831494Sbill #define RT3 14
1841494Sbill #define RT4 15
1851494Sbill #define	LABHS	127
1861494Sbill 
1871494Sbill char *copy();
1881494Sbill long getnum();
1891494Sbill struct node *codemove();
1901494Sbill struct node *insertl();
1911494Sbill struct node *nonlab();
19218380Sralph 
19318380Sralph #ifdef notdef
19418380Sralph #define decref(p) \
19518380Sralph 	((p) && --(p)->refc <= 0 ? nrlab++, delnode(p) : 0)
19618380Sralph #define delnode(p) \
19718380Sralph 	((p)->back->forw = (p)->forw, (p)->forw->back = (p)->back)
19818380Sralph #endif notdef
199*24398Smckusick 
200*24398Smckusick char *xalloc();
201*24398Smckusick extern char *newa;
202*24398Smckusick extern char *lasta;
203*24398Smckusick extern char *lastr;
204*24398Smckusick #define	XALIGN(n) \
205*24398Smckusick 		(((n)+(sizeof (char *) - 1)) & ~(sizeof (char *) - 1))
206*24398Smckusick #define	alloc(n) \
207*24398Smckusick 		((struct node *) \
208*24398Smckusick 		 ((newa = lasta) + (n) > lastr ? \
209*24398Smckusick 			xalloc(n) : \
210*24398Smckusick 			(lasta += XALIGN(n), newa)))
211