Add tests, fixes for tests, reinstate and type-convert stuff marked "bitrot"
[ccom.git] / c1.h
1 /*
2  * C code generator header
3  */
4
5 #ifndef _C1_H
6 #define _C1_H 1
7
8 #include <setjmp.h>
9 #include "ccom.h"
10
11 #define UNS(x)  ((_UNSIGNED_INT)(x))
12
13 struct  optab {
14         char    tabdeg1;
15         char    tabtyp1;
16         char    tabdeg2;
17         char    tabtyp2;
18         char    *tabstring;
19 };
20
21 struct  table {
22         int     tabop;
23         struct  optab *tabp;
24 };
25
26 struct  instab {
27         int     iop;
28         char    *str1;
29         char    *str2;
30 };
31
32 extern char maprel[];
33 extern char notrel[];
34 extern int nreg;
35 extern int isn1;
36 extern int line;
37 extern int nerror;                      /* number of hard errors */
38 extern struct table cctab[];
39 extern struct table efftab[];
40 extern struct table regtab[];
41 extern struct table sptab[];
42 extern struct table lsptab[1];
43 extern char mov[];
44 extern char clr[];
45 extern char cmp[];
46 extern char tst[];
47 extern char add[];
48 extern char sub[];
49 extern char inc[];
50 extern char dec[];
51 extern char mul[];
52 extern char _div[];
53 extern char asr[];
54 extern char ash[];
55 extern char asl[];
56 extern char bic[];
57 extern char bic1[];
58 extern char bit[];
59 extern char bit1[];
60 extern char bis[];
61 extern char bis1[];
62 extern char xor[];
63 extern char neg[];
64 extern char com[];
65 extern char stdol[];
66 extern char ashc[];
67 extern char slmul[];
68 extern char sldiv[];
69 extern char slrem[];
70 extern char uldiv[];
71 extern char ulrem[];
72 extern char ualdiv[];
73 extern char ualrem[];
74 extern char ultof[];
75 extern char ulsh[];
76 extern char ualsh[];
77 extern char almul[];
78 extern char aldiv[];
79 extern char alrem[];
80 extern char udiv[];
81 extern char urem[];
82 extern char jeq[];
83 extern char jne[];
84 extern char jle[];
85 extern char jgt[];
86 extern char jlt[];
87 extern char jge[];
88 extern char jlos[];
89 extern char jhi[];
90 extern char jlo[];
91 extern char jhis[];
92 extern char nop[];
93 extern char jbr[];
94 extern char jpl[];
95 extern char jmi[];
96 extern char jmijne[];
97 extern char jmijeq[];
98 extern struct instab instab[];
99 extern struct instab branchtab[];
100 extern int opdope1[];
101 extern char *opntab[];
102 extern int nstack;
103 extern int nfloat;
104 extern struct locnnode sfuncr;
105 extern char *funcbase;
106 extern char *curbase;
107 extern char *coremax;
108 extern struct cnode czero, cone;
109 extern long totspace;
110 extern int regpanic;            /* set when SU register alg. fails */
111 extern int panicposs;           /* set when there might be need for regpanic */
112 extern jmp_buf jmpbuf;
113 /*long ftell();*/
114 /*char *sbrk();*/
115 /*struct optab *match();*/
116 /*struct node *optim();*/
117 /*struct node *unoptim();*/
118 /*struct node *pow2();*/
119 /*struct node *tnode();*/
120 /*struct node *sdelay();*/
121 /*struct node *ncopy();*/
122 /*struct node *getblk();*/
123 /*struct node *strfunc();*/
124 /*struct node *isconstant();*/
125 /*struct node *tconst();*/
126 /*struct node *hardlongs();*/
127 /*struct node *lconst();*/
128 /*struct node *acommute();*/
129 /*struct node *lvfield();*/
130 /*struct node *paint();*/
131 /*long ftell();*/
132
133 /*
134  * Some special stuff for long comparisons
135  */
136 extern int xlab1, xlab2, xop, xzero;
137
138 #if 1 /* moved here from c12.c */
139 #define LSTSIZ  20
140 struct acl {
141         int nextl;
142         int nextn;
143         struct tnode *nlist[LSTSIZ];
144         struct node *llist[LSTSIZ+1];
145 };
146 #endif
147
148 #ifndef __P
149 #ifdef __STDC__
150 #define __P(args) args
151 #else
152 #define __P(args) ()
153 #endif
154 #endif
155
156 /* c10.c */
157 int main __P((int argc, char *argv[]));
158 struct optab *match __P((struct node *tree, struct table *table, int nrleft, int nocvt));
159 int rcexpr1 __P((struct node *atree, struct table *atable, int reg));
160 int cexpr __P((register struct node *tree, struct table *table, int areg));
161 int reorder __P((struct node **treep, struct table *table, int reg));
162 int sreorder __P((struct node **treep, struct table *table, int reg, int recurf));
163 int delay __P((struct node **treep, struct table *table, int reg));
164 struct node *sdelay __P((struct node **ap));
165 struct node *paint __P((register struct node *tp, register int type));
166 struct nnode *ncopy __P((register struct nnode *p));
167 int chkleaf __P((register struct node *tree, struct table *table, int reg));
168 int comarg __P((register struct node *tree, int *flagp));
169 struct node *strfunc __P((register struct node *tp));
170 void doinit __P((register int type, register struct node *tree));
171 void movreg __P((int r0, int r1, struct node *tree));
172
173 /* c11.c */
174 int degree __P((register struct node *t));
175 void pname __P((register struct node *p, int flag));
176 void pbase __P((register struct nnode *p));
177 int xdcalc __P((register struct node *p, int nrleft));
178 int dcalc __P((register struct node *p, int nrleft));
179 int notcompat __P((register struct node *p, int ast, int deg, int op));
180 int prins __P((int op, int c, struct instab *itable, int lbl));
181 int collcon __P((register struct node *p));
182 int isfloat __P((register struct node *t));
183 int oddreg __P((register struct node *t, register int reg));
184 int arlength __P((int t));
185 void pswitch1 __P((struct swtab *afp, struct swtab *alp, int deflab));
186 void breq __P((int v, int l));
187 int sort __P((struct swtab *afp, struct swtab *alp));
188 int ispow2 __P((register struct tnode *tree));
189 struct tnode *pow2 __P((register struct tnode *tree));
190 void cbranch1 __P((struct node *atree, register int lbl, int cond, register int reg));
191 void branch1 __P((int lbl, int aop, int c));
192 void longrel __P((struct tnode *atree, int lbl, int cond, int reg));
193 int xlongrel __P((int f));
194 void label1 __P((int l));
195 void popstk __P((int a));
196 void werror1 __P((char *s));
197 void error1 __P((char *s, ...));
198 void psoct __P((int an));
199 void getree __P((void));
200 int geti __P((void));
201 void strasg __P((struct tnode *atp));
202 int decref1 __P((register int t));
203 int incref1 __P((register int t));
204
205 /* c12.c */
206 struct node *optim __P((register struct node *tree));
207 struct node *binoptim __P((register struct node *tree));
208 struct node *unoptim __P((register struct node *tree));
209 struct node *lvfield __P((register struct tnode *t));
210 struct node *acommute __P((register struct node *tree));
211 int sideeffects __P((register struct node *tp));
212 void distrib __P((struct acl *list));
213 void squash __P((struct node **p, struct node **maxp));
214 void _const __P((int op, register _INT *vp, _INT v, int type));
215 struct lnode *lconst __P((int op, register struct node *lp, register struct node *rp));
216 void insert __P((int op, register struct node *tree, register struct acl *list));
217 struct tnode *tnode __P((int op, int type, struct node *tr1, struct node *tr2));
218 struct cnode *tconst __P((int val, int type));
219 struct node *getblk __P((int size));
220 int islong __P((int t));
221 struct cnode *isconstant __P((register struct node *t));
222 struct node *hardlongs __P((register struct node *t));
223 int uns __P((struct node *tp));
224
225 #endif