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