0
|
1 /* Micro-C header file */
|
|
2
|
|
3 #define DEBUG error(-1)
|
|
4
|
|
5 /*#include "CCLIB.TXT" */
|
19
|
6 #ifdef __micro_c__
|
|
7 #include "stdio.h"
|
|
8 #else
|
|
9 #include <stdio.h>
|
|
10 #endif
|
0
|
11
|
|
12 #define SIZE_INT 4
|
|
13
|
164
|
14 /* reserved word start */
|
|
15
|
0
|
16 #define INT (-1)
|
162
|
17 #define UNSIGNED (-2)
|
|
18 #define CHAR (-3)
|
|
19 #define UCHAR (-4)
|
|
20 #define POINTER (-5)
|
|
21 #define ARRAY (-6)
|
|
22 #define STRUCT (-7)
|
|
23 #define UNION (-8)
|
|
24 #define FUNCTION (-9)
|
0
|
25
|
|
26 #define STATIC (-10)
|
|
27 #define GOTO (-11)
|
|
28 #define RETURN (-12)
|
|
29 #define BREAK (-13)
|
|
30 #define CONTINUE (-14)
|
|
31 #define IF (-15)
|
|
32 #define ELSE (-16)
|
|
33 #define FOR (-17)
|
|
34 #define DO (-18)
|
|
35 #define WHILE (-19)
|
|
36 #define SWITCH (-20)
|
|
37 #define CASE (-21)
|
|
38 #define DEFAULT (-22)
|
|
39 #define RESERVE (-23)
|
|
40 #define TAG (-24)
|
|
41 #define FIELD (-25)
|
|
42 #define IDENT (-26)
|
164
|
43 #define MACRO (-27)
|
|
44 #define BLABEL (-28)
|
|
45 #define FLABEL (-29)
|
|
46 #define TYPEDEF (-30)
|
|
47 #define SIZEOF (-31)
|
|
48 #define TYPE (-32)
|
|
49 #define LONG (-33)
|
178
|
50 #define SHORT (-34)
|
|
51 #define USHORT (-35)
|
|
52 #define EXTRN (-36)
|
|
53 #define EXTRN1 (-37)
|
|
54 #define VOID (-38)
|
|
55 #define INLINE (-39)
|
|
56 #define REGISTER (-40)
|
|
57 #define FREGISTER (-41)
|
|
58 #define DREGISTER (-42)
|
|
59 #define CODE (-43)
|
|
60 #define ENVIRONMENT (-44)
|
|
61 #define DEFINED (-45)
|
|
62 #define ENUM (-46)
|
|
63 #define KONST (-47)
|
|
64 #define FMACRO (-48)
|
|
65 #define LMACRO (-49)
|
182
|
66 #define SIGNED (-50)
|
|
67 #define DOTS (-51)
|
0
|
68
|
182
|
69 #define FLOAT (-52)
|
|
70 #define DOUBLE (-53)
|
|
71 #define LONGLONG (-54)
|
|
72 #define ULONGLONG (-55)
|
|
73 #define VOLATILE (-56)
|
164
|
74
|
|
75 /* reserved word end */
|
78
|
76
|
103
|
77 #define EMPTY (-99)
|
|
78
|
164
|
79 /* mode start */
|
0
|
80 #define TOP 0
|
|
81 #define GDECL 1
|
|
82 #define GSDECL 2
|
|
83 #define GUDECL 3
|
|
84 #define ADECL 4
|
|
85 #define LDECL 5
|
|
86 #define LSDECL 6
|
|
87 #define LUDECL 7
|
|
88 #define STADECL 8
|
|
89 #define STAT 9
|
|
90 #define GTDECL 10
|
|
91 #define LTDECL 11
|
18
|
92 #define IFDEF 12
|
29
|
93 #define MDECL 13
|
176
|
94 #define GEDECL 14
|
|
95 #define LEDECL 15
|
164
|
96 /* mode end */
|
|
97
|
|
98 #define US 1
|
|
99 #define AS 1000
|
|
100 #define SOP 200
|
|
101 #define DOP 400
|
|
102 #define FOP 600
|
|
103 #define LOP 800
|
|
104
|
|
105 /* tree node tags start */
|
|
106
|
|
107 #define LIST_ARGS(i) (i==FUNCTION||i==CODE)
|
|
108
|
|
109 /* nullary argments */
|
0
|
110
|
|
111 #define GVAR 1
|
|
112 #define RGVAR 2
|
|
113 #define CRGVAR 3
|
162
|
114 #define CURGVAR 4
|
|
115 #define LVAR 5
|
|
116 #define RLVAR 6
|
|
117 #define CRLVAR 7
|
|
118 #define CURLVAR 8
|
164
|
119 #define FRGVAR (FOP+RGVAR)
|
|
120 #define FRLVAR (FOP+RLVAR)
|
|
121 #define DRGVAR (DOP+RGVAR)
|
|
122 #define DRLVAR (DOP+RLVAR)
|
165
|
123 #define SRGVAR (SOP+CRGVAR)
|
|
124 #define SRLVAR (SOP+CRLVAR)
|
164
|
125 #define SURGVAR (SOP+CURGVAR)
|
|
126 #define SURLVAR (SOP+CURLVAR)
|
165
|
127 #define LRGVAR (LOP+CRGVAR)
|
|
128 #define LRLVAR (LOP+CRLVAR)
|
164
|
129 #define LURGVAR (LOP+CURGVAR)
|
|
130 #define LURLVAR (LOP+CURLVAR)
|
|
131
|
166
|
132 #define CONST 9
|
164
|
133 #define DCONST (DOP+CONST)
|
|
134 #define FCONST (FOP+CONST)
|
|
135 #define LCONST (LOP+CONST)
|
166
|
136 #define STRING 10
|
|
137 #define FNAME 11
|
164
|
138
|
166
|
139 #define NULLARY_ARGS(i) (i==REGISTER||i==DREGISTER||i==FREGISTER||(GVAR<=(i%SOP)&&(i%SOP)<=FNAME))
|
164
|
140
|
|
141 /* unary argments */
|
|
142
|
166
|
143 #define ADDRESS 12
|
|
144 #define MINUS 13
|
|
145 #define LNOT 14
|
|
146 #define BNOT 15
|
|
147 #define INC 16
|
|
148 #define POSTINC 17
|
168
|
149 #define UPOSTINC 18
|
|
150 #define PREINC 19
|
|
151 #define UPREINC 20
|
|
152 #define DEC 21
|
|
153 #define CPOSTINC 22
|
|
154 #define CPREINC 23
|
|
155 #define CPOSTDEC 24
|
|
156 #define CPREDEC 25
|
|
157 #define CUPOSTINC 26
|
|
158 #define CUPREINC 27
|
|
159 #define CUPOSTDEC 28
|
|
160 #define CUPREDEC 29
|
164
|
161 #define SPOSTINC (SOP+CPOSTINC)
|
|
162 #define SPREINC (SOP+CPREINC)
|
|
163 #define SPOSTDEC (SOP+CPOSTDEC)
|
|
164 #define SPREDEC (SOP+CPREDEC)
|
|
165 #define SUPOSTINC (SOP+CUPOSTINC)
|
|
166 #define SUPREINC (SOP+CUPREINC)
|
|
167 #define SUPOSTDEC (SOP+CUPOSTDEC)
|
|
168 #define SUPREDEC (SOP+CUPREDEC)
|
|
169 #define FPOSTINC (FOP+POSTINC)
|
|
170 #define FPREINC (FOP+PREINC)
|
|
171 #define DPOSTINC (DOP+POSTINC)
|
|
172 #define DPREINC (DOP+PREINC)
|
165
|
173 #define LPOSTINC (LOP+CPOSTINC)
|
|
174 #define LPREINC (LOP+CPREINC)
|
164
|
175 #define LUPOSTINC (LOP+CUPOSTINC)
|
|
176 #define LUPREINC (LOP+CUPREINC)
|
168
|
177 #define INDIRECT 30
|
|
178 #define RINDIRECT 31
|
|
179 #define CRINDIRECT 32
|
|
180 #define CURINDIRECT 33
|
164
|
181 #define SRINDIRECT (SOP+CRINDIRECT)
|
|
182 #define SURINDIRECT (SOP+CURINDIRECT)
|
|
183 #define FRINDIRECT (FOP+RINDIRECT)
|
|
184 #define DRINDIRECT (DOP+RINDIRECT)
|
165
|
185 #define LRINDIRECT (DOP+CRINDIRECT)
|
168
|
186 #define RSTRUCT 34
|
|
187 #define CONV 35
|
164
|
188
|
|
189 #define UNARY_ARGS(i) (ADDRESS<=(i%SOP)&&(i%SOP)<=CONV)
|
|
190
|
|
191 /* binary argments */
|
|
192
|
168
|
193 #define MUL 36
|
|
194 #define UMUL 37
|
|
195 #define DIV 38
|
|
196 #define UDIV 39
|
|
197 #define MOD 40
|
|
198 #define UMOD 41
|
|
199 #define ADD 42
|
|
200 #define SUB 43
|
|
201 #define CMP 44
|
|
202 #define RSHIFT 45
|
|
203 #define URSHIFT 46
|
|
204 #define LSHIFT 47
|
|
205 #define ULSHIFT 48
|
|
206 #define GT 49
|
|
207 #define UGT 50
|
|
208 #define GE 51
|
|
209 #define UGE 52
|
|
210 #define LT 53
|
|
211 #define ULT 54
|
|
212 #define LE 55
|
|
213 #define ULE 56
|
|
214 #define EQ 57
|
|
215 #define NEQ 58
|
|
216 #define BAND 59
|
|
217 #define EOR 60
|
|
218 #define BOR 61
|
|
219 #define LAND 62
|
|
220 #define LOR 63
|
|
221 #define ASS 64
|
|
222 #define CMPGE 65
|
|
223 #define ASSOP 66
|
|
224 #define COMMA 67
|
164
|
225
|
168
|
226 #define CASS 68
|
|
227 #define CASSOP 69
|
|
228 #define CUASSOP 70
|
0
|
229
|
165
|
230 #define SASS (SOP+CASS)
|
164
|
231 #define SASSOP (SOP+CASSOP)
|
|
232 #define SUASSOP (SOP+CUASSOP)
|
|
233
|
|
234 #define DASS (DOP+ASS)
|
|
235 #define DCMPGE (DOP+CMPGE)
|
89
|
236 #define DASSOP (DOP+ASSOP)
|
|
237 #define DCMP (DOP+CMP)
|
|
238 #define DMINUS (DOP+MINUS)
|
82
|
239 #define DMUL (DOP+MUL)
|
|
240 #define DDIV (DOP+DIV)
|
|
241 #define DADD (DOP+ADD)
|
|
242 #define DSUB (DOP+SUB)
|
164
|
243
|
|
244 #define FASS (FOP+ASS)
|
|
245 #define FCMPGE (FOP+CMPGE)
|
133
|
246 #define FASSOP (FOP+ASSOP)
|
|
247 #define FCMP (FOP+CMP)
|
|
248 #define FMINUS (FOP+MINUS)
|
|
249 #define FMUL (FOP+MUL)
|
|
250 #define FDIV (FOP+DIV)
|
|
251 #define FADD (FOP+ADD)
|
|
252 #define FSUB (FOP+SUB)
|
78
|
253
|
165
|
254 #define LASS (LOP+CASS)
|
164
|
255 #define LCMPGE (LOP+CMPGE)
|
|
256 #define LASSOP (LOP+CASSOP)
|
|
257 #define LUASSOP (LOP+CUASSOP)
|
|
258 #define LMUL (LOP+MUL)
|
|
259 #define LDIV (LOP+DIV)
|
|
260 #define LUMUL (LOP+UMUL)
|
|
261 #define LUDIV (LOP+UDIV)
|
|
262 #define LADD (LOP+ADD)
|
|
263 #define LSUB (LOP+SUB)
|
81
|
264
|
168
|
265 #define STASS 71
|
164
|
266
|
|
267 #define BINARY_ARGS(i) (MUL<=(i%SOP)&&(i%SOP)<=STASS)
|
|
268
|
|
269 /* tarnary argments */
|
|
270
|
168
|
271 #define COND 72
|
164
|
272 #define SCOND (SOP+COND)
|
133
|
273 #define DCOND (DOP+COND)
|
|
274 #define FCOND (FOP+COND)
|
164
|
275 #define LCOND (LOP+COND)
|
|
276
|
|
277 #define TARNARY_ARGS(i) (COND==(i%SOP))
|
|
278
|
|
279 /* not appeared as tags */
|
81
|
280
|
168
|
281 #define I2D 73
|
|
282 #define D2I 74
|
|
283 #define U2D 75
|
|
284 #define D2U 76
|
|
285 #define F2D 77
|
|
286 #define D2F 78
|
|
287 #define I2F 79
|
|
288 #define F2I 80
|
|
289 #define U2F 81
|
|
290 #define F2U 82
|
164
|
291
|
168
|
292 #define LPAR 83
|
|
293 #define RPAR 84
|
|
294 #define LBRA 85
|
|
295 #define RBRA 86
|
|
296 #define LC 87
|
|
297 #define RC 88
|
|
298 #define COLON 89
|
|
299 #define SM 90
|
|
300 #define PERIOD 91
|
|
301 #define ARROW 92
|
|
302 #define CNAME 93
|
164
|
303
|
|
304 /* tree node tags end */
|
|
305
|
|
306 /* error number start */
|
0
|
307
|
|
308 #define FILERR 1
|
|
309 #define DCERR 2
|
|
310 #define STERR 3
|
|
311 #define EXERR 4
|
|
312 #define CNERR 5
|
|
313 #define CHERR 6
|
|
314 #define GSERR 7
|
|
315 #define LSERR 8
|
|
316 #define STRERR 9
|
|
317 #define LNERR 10
|
|
318 #define EOFERR 11
|
|
319 #define MCERR 12
|
|
320 #define INCERR 13
|
|
321 #define HPERR 14
|
|
322 #define TYERR 15
|
|
323 #define LVERR 16
|
|
324 #define UDERR 17
|
|
325 #define OPTION 18
|
|
326 #define REG_ERR 19
|
|
327 #define CODE_ERR 20
|
29
|
328 #define MSERR 21
|
164
|
329 /* error number end */
|
0
|
330
|
|
331 #define GSYMS 9000
|
|
332 #define LSYMS 500
|
32
|
333 #define MSYMS 3000
|
0
|
334
|
162
|
335 #define HEAPSIZE 20000
|
0
|
336 /* #define CHEAPSIZE 3000 */
|
|
337 #define CHEAPSIZE 256000
|
|
338 #define LBUFSIZE 4096
|
34
|
339 #define MACROSIZE 16000
|
0
|
340
|
25
|
341 #define FILES 10
|
0
|
342 #define OUTPUT_FILE_NAME "mcout.s"
|
|
343
|
29
|
344 EXTERN int sym,ch,type,mode,stmode,gfree,lfree,mflag,lineno,glineno;
|
0
|
345 EXTERN int labelno,gpc,disp,reg_var,debug;
|
|
346 EXTERN int symval,args,init_vars,heap[HEAPSIZE];
|
|
347 EXTERN int blabel,clabel,dlabel,cslabel,ilabel,control,ac,ac2,lsrc,chk,asmf;
|
|
348 EXTERN int MAX_REGISTER_VAR;
|
81
|
349 EXTERN double dsymval;
|
0
|
350
|
|
351 EXTERN unsigned hash;
|
|
352
|
34
|
353 EXTERN int chsave;
|
115
|
354 EXTERN int chptrsave;
|
29
|
355 EXTERN char linebuf[LBUFSIZE],namebuf[LBUFSIZE],*chptr;
|
0
|
356 EXTERN char *name,*cheapp,**av,/*obuf[320],*/*sptr,escape(void);
|
166
|
357 EXTERN int arg_offset,stat_no,size_of_int,size_of_short,disp_offset,endian,csvalue1;
|
0
|
358 EXTERN int code_arg_offset;
|
81
|
359 EXTERN int size_of_double,size_of_float,size_of_longlong;
|
0
|
360 EXTERN int retlabel,retpending,retcont;
|
77
|
361 EXTERN int arglist;
|
0
|
362
|
|
363 EXTERN FILE *obuf;
|
|
364
|
168
|
365 #if 1
|
0
|
366 typedef struct nametable {
|
|
367 char *nm;
|
|
368 int sc,ty,dsp; } NMTBL;
|
110
|
369 #else
|
|
370 typedef struct nametable {
|
|
371 char *nm;
|
|
372 int sc; int ty; int dsp; } NMTBL;
|
|
373 #endif
|
0
|
374
|
30
|
375 EXTERN NMTBL mtable[MSYMS];
|
28
|
376 EXTERN NMTBL ntable[GSYMS+LSYMS];
|
|
377 EXTERN NMTBL *nptr,*gnptr;
|
0
|
378 EXTERN NMTBL *fnptr;
|
105
|
379 EXTERN NMTBL null_nptr;
|
72
|
380 EXTERN int typedefed,gtypedefed;
|
0
|
381
|
173
|
382 EXTERN struct {int fd,ln;char *name0;int inc;FILE *fcb;} *filep,filestack[FILES];
|
0
|
383 EXTERN char cheap[CHEAPSIZE];
|
34
|
384 EXTERN char *macropp,macro_buf[MACROSIZE];
|
0
|
385
|
173
|
386 extern void macro_define(char *n);
|
61
|
387 extern void error(int n);
|
|
388 extern int size(int t);
|
|
389 extern int scalar(int t);
|
81
|
390 extern int dlist2(int e1, double e2);
|
61
|
391 extern int list2(int e1, int e2);
|
|
392 extern int list3(int e1, int e2, int e3);
|
|
393 extern int list4(int e1, int e2, int e3,int e4);
|
|
394 extern int reverse0(int t1);
|
|
395 extern int assign_data(int e, int t, NMTBL *n,int offset);
|
|
396 extern int assign_expr0(int e1,int e2,int t,int type) ;
|
|
397 extern int assign_expr(int e1,int e2,int t,int type) ;
|
|
398 extern int append4(int p,int a1,int a2,int a3);
|
|
399
|
|
400
|
|
401
|
33
|
402 #define car(e) (heap[(int)(e)])
|
|
403
|
|
404 #define cadr(e) (heap[((int)(e))+1])
|
|
405
|
|
406 #define caddr(e) (heap[((int)(e))+2])
|
|
407
|
|
408 #define cadddr(e) (heap[((int)(e))+3])
|
|
409
|
81
|
410 #define dcadr(e) (*(double*)&heap[((int)(e))+1])
|
|
411 #define dcaddr(e) (*(double*)&heap[((int)(e))+2])
|
|
412
|
66
|
413 #include "conv/conv.h"
|
|
414 /*
|
59
|
415 #include "conv/c2cbc.h"
|
|
416 #include "conv/cbc2c.h"
|
66
|
417 */
|
59
|
418
|
62
|
419 extern Converter *conv;
|
59
|
420
|
119
|
421 EXTERN void extern_define(char *s,int dsp,int type,int use);
|
61
|
422 EXTERN void error(int n);
|
|
423 EXTERN int append4(int p,int a1,int a2,int a3);
|
|
424 EXTERN int assign_expr(int e1,int e2,int t,int type);
|
|
425 EXTERN int assign_expr0(int e1,int e2,int t,int type);
|
|
426 EXTERN int backdef(void);
|
|
427 EXTERN int fwdlabel(void);
|
|
428 EXTERN int glist2(int e1,int e2);
|
95
|
429 EXTERN int glist3(int e1,int e2,int e3);
|
117
|
430 EXTERN void free_glist2(int e1);
|
|
431 EXTERN void free_glist3(int e1);
|
|
432 EXTERN int integral(int t);
|
61
|
433 EXTERN int integral(int t);
|
|
434 EXTERN int list2(int e1, int e2);
|
|
435 EXTERN int list3(int e1, int e2, int e3);
|
|
436 EXTERN int list4(int e1, int e2, int e3, int e4);
|
|
437 EXTERN int reverse0(int t1);
|
|
438 EXTERN int rplacad(int e, int n);
|
|
439 EXTERN int rplacadd(int e, int n);
|
|
440 EXTERN int rvalue_t(int e,int type);
|
|
441 EXTERN int scalar(int t);
|
|
442 EXTERN void bexpr(int e1, char cond, int l1);
|
|
443 EXTERN void def_label(int cslabel, int dlabel);
|
|
444 EXTERN void display_ntable(NMTBL *n, char *s);
|
|
445 EXTERN void exit(int l);
|
|
446 EXTERN void fwddef(int l);
|
94
|
447 EXTERN int new_lvar(int size);
|
|
448
|
117
|
449 EXTERN void free_lvar(int lvar);
|
|
450 EXTERN void init_free_lvar_list();
|
61
|
451
|
33
|
452 /* end */
|