Mercurial > hg > CbC > old > device
annotate mc.h @ 467:32737bad7489
fix list/tag interference
author | kono |
---|---|
date | Sat, 30 Jul 2005 16:01:45 +0900 |
parents | d88f08d81bba |
children | 8370ba6e8557 |
rev | line source |
---|---|
0 | 1 /* Micro-C header file */ |
2 | |
195 | 3 #define FLOAT_CODE 1 |
237 | 4 #define LONGLONG_CODE 1 |
292 | 5 #define CASE_CODE 1 |
316 | 6 #define ASM_CODE 1 |
329 | 7 #define BIT_FIELD_CODE 1 |
195 | 8 |
164 | 9 /* reserved word start */ |
10 | |
327 | 11 #define INT (-1) |
12 #define UNSIGNED (-2) | |
13 #define CHAR (-3) | |
14 #define UCHAR (-4) | |
162 | 15 #define POINTER (-5) |
327 | 16 #define ARRAY (-6) |
17 #define STRUCT (-7) | |
18 #define UNION (-8) | |
19 #define FUNCTION (-9) | |
0 | 20 |
327 | 21 #define STATIC (-10) |
22 #define GOTO (-11) | |
23 #define RETURN (-12) | |
24 #define BREAK (-13) | |
25 #define CONTINUE (-14) | |
26 #define IF (-15) | |
27 #define ELSE (-16) | |
28 #define FOR (-17) | |
29 #define DO (-18) | |
30 #define WHILE (-19) | |
31 #define SWITCH (-20) | |
32 #define CASE (-21) | |
0 | 33 #define DEFAULT (-22) |
34 #define RESERVE (-23) | |
327 | 35 #define TAG (-24) |
36 #define FIELD (-25) | |
37 #define IDENT (-26) | |
38 #define MACRO (-27) | |
39 #define BLABEL (-28) | |
40 #define FLABEL (-29) | |
164 | 41 #define TYPEDEF (-30) |
327 | 42 #define SIZEOF (-31) |
43 #define TYPE (-32) | |
44 #define LONG (-33) | |
45 #define SHORT (-34) | |
46 #define USHORT (-35) | |
47 #define EXTRN (-36) | |
48 #define EXTRN1 (-37) | |
49 #define VOID (-38) | |
50 #define INLINE (-39) | |
51 #define REGISTER (-40) | |
52 #define FREGISTER (-41) | |
53 #define DREGISTER (-42) | |
54 #define LREGISTER (-43) | |
55 #define CODE (-44) | |
56 #define ENVIRONMENT (-45) | |
57 #define DEFINED (-46) | |
58 #define ENUM (-47) | |
59 #define KONST (-48) | |
60 #define FMACRO (-49) | |
61 #define LMACRO (-50) | |
62 #define SIGNED (-51) | |
63 #define DOTS (-52) | |
0 | 64 |
327 | 65 #define FLOAT (-53) |
66 #define DOUBLE (-54) | |
67 #define LONGLONG (-55) | |
68 #define ULONGLONG (-56) | |
69 #define VOLATILE (-57) | |
461 | 70 #define RESTRICT (-58) |
71 #define TYPEOF (-59) | |
72 #define ASM (-60) | |
164 | 73 |
74 /* reserved word end */ | |
78 | 75 |
327 | 76 #define EMPTY (-99) |
103 | 77 |
164 | 78 /* mode start */ |
327 | 79 #define TOP 0 |
80 #define GDECL 1 | |
81 #define GSDECL 2 | |
82 #define GUDECL 3 | |
83 #define ADECL 4 | |
84 #define LDECL 5 | |
85 #define LSDECL 6 | |
86 #define LUDECL 7 | |
0 | 87 #define STADECL 8 |
327 | 88 #define STAT 9 |
89 #define GTDECL 10 | |
90 #define LTDECL 11 | |
91 #define IFDEF 12 | |
92 #define MDECL 13 | |
176 | 93 #define GEDECL 14 |
94 #define LEDECL 15 | |
362 | 95 #define LLDECL 16 |
96 #define SFDINIT 17 | |
164 | 97 /* mode end */ |
98 | |
327 | 99 #define US 1 |
100 #define AS 10000 | |
101 #define SOP 200 | |
102 #define COP 400 | |
103 #define DOP 600 | |
104 #define FOP 800 | |
105 #define LOP 1000 | |
164 | 106 |
107 /* tree node tags start */ | |
108 | |
316 | 109 #define LIST_ARGS(i) (i==FUNCTION||i==CODE||i==ASM) |
164 | 110 |
111 /* nullary argments */ | |
0 | 112 |
327 | 113 #define GVAR 1 |
114 #define RGVAR 2 | |
115 #define URGVAR 3 | |
116 #define LVAR 4 | |
117 #define RLVAR 5 | |
118 #define URLVAR 6 | |
119 #define CRGVAR (COP+RGVAR) | |
120 #define CURGVAR (COP+URGVAR) | |
121 #define CRLVAR (COP+RLVAR) | |
122 #define CURLVAR (COP+URLVAR) | |
123 #define FRGVAR (FOP+RGVAR) | |
124 #define FRLVAR (FOP+RLVAR) | |
125 #define DRGVAR (DOP+RGVAR) | |
126 #define DRLVAR (DOP+RLVAR) | |
127 #define SRGVAR (SOP+RGVAR) | |
128 #define SURGVAR (SOP+URGVAR) | |
129 #define SRLVAR (SOP+RLVAR) | |
130 #define SURLVAR (SOP+URLVAR) | |
131 #define LRGVAR (LOP+RGVAR) | |
132 #define LURGVAR (LOP+URGVAR) | |
133 #define LRLVAR (LOP+RLVAR) | |
134 #define LURLVAR (LOP+URLVAR) | |
164 | 135 |
327 | 136 #define CONST 7 |
137 #define DCONST (DOP+CONST) | |
138 #define FCONST (FOP+CONST) | |
139 #define LCONST (LOP+CONST) | |
140 #define STRING 8 | |
141 #define FNAME 9 | |
450
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
142 #define LCALL 10 |
452 | 143 #define COMMENT 11 |
144 #define DECL 12 | |
145 #define COMP 13 | |
146 #define LABEL 14 | |
164 | 147 |
450
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
148 #define NULLARY_ARGS(i) (i==RETURN||i==ENVIRONMENT||i==LCALL||i==REGISTER||i==DREGISTER||i==FREGISTER||i==LREGISTER||(GVAR<=(i%SOP)&&(i%SOP)<=LABEL)) |
164 | 149 |
150 /* unary argments */ | |
151 | |
452 | 152 #define ADDRESS 15 |
153 #define MINUS 16 | |
154 #define LNOT 17 | |
155 #define BNOT 18 | |
156 #define INC 19 | |
157 #define POSTINC 20 | |
158 #define UPOSTINC 21 | |
159 #define PREINC 22 | |
160 #define UPREINC 23 | |
161 #define POSTDEC 24 | |
162 #define UPOSTDEC 25 | |
163 #define PREDEC 26 | |
164 #define UPREDEC 27 | |
165 #define DEC 28 | |
196 | 166 #define CPOSTINC (COP+POSTINC) |
167 #define CUPOSTINC (COP+UPOSTINC) | |
168 #define CPREINC (COP+PREINC) | |
169 #define CUPREINC (COP+UPREINC) | |
170 #define CPOSTDEC (COP+POSTDEC) | |
171 #define CUPOSTDEC (COP+UPOSTDEC) | |
172 #define CPREDEC (COP+CPREDEC) | |
173 #define CUPREDEC (COP+UPREDEC) | |
174 #define SPOSTINC (SOP+POSTINC) | |
175 #define SUPOSTINC (SOP+UPOSTINC) | |
176 #define SPREINC (SOP+PREINC) | |
177 #define SUPREINC (SOP+UPREINC) | |
178 #define SPOSTDEC (SOP+POSTDEC) | |
179 #define SUPOSTDEC (SOP+UPOSTDEC) | |
180 #define SPREDEC (SOP+PREDEC) | |
181 #define SUPREDEC (SOP+UPREDEC) | |
327 | 182 #define FPOSTINC (FOP+POSTINC) |
183 #define FPREINC (FOP+PREINC) | |
184 #define DPOSTINC (DOP+POSTINC) | |
185 #define DPREINC (DOP+PREINC) | |
186 #define LPOSTINC (LOP+POSTINC) | |
187 #define LPREINC (LOP+PREINC) | |
188 #define LUPOSTINC (LOP+UPOSTINC) | |
189 #define LUPREINC (LOP+UPREINC) | |
452 | 190 #define INDIRECT 29 |
191 #define RINDIRECT 30 | |
192 #define URINDIRECT 31 | |
327 | 193 #define CRINDIRECT (COP+RINDIRECT) |
194 #define CURINDIRECT (COP+URINDIRECT) | |
195 #define SRINDIRECT (SOP+RINDIRECT) | |
196 #define SURINDIRECT (SOP+URINDIRECT) | |
197 #define FRINDIRECT (FOP+RINDIRECT) | |
198 #define DRINDIRECT (DOP+RINDIRECT) | |
199 #define LRINDIRECT (LOP+RINDIRECT) | |
200 #define LURINDIRECT (LOP+URINDIRECT) | |
452 | 201 #define RSTRUCT 32 |
202 #define ALLOCA 33 | |
456 | 203 #define BUILTINP 34 |
461 | 204 #define BUILTIN_EXPECT 35 |
205 #define ATTRIBUTE 36 | |
206 #define BIT_FIELD 37 | |
207 #define RBIT_FIELD 38 | |
208 #define BPREINC 39 | |
209 #define BPOSTINC 40 | |
210 #define CONV 41 | |
164 | 211 |
212 #define UNARY_ARGS(i) (ADDRESS<=(i%SOP)&&(i%SOP)<=CONV) | |
213 | |
214 /* binary argments */ | |
215 | |
461 | 216 #define MUL 42 |
217 #define UMUL 43 | |
218 #define DIV 44 | |
219 #define UDIV 45 | |
220 #define MOD 46 | |
221 #define UMOD 47 | |
222 #define ADD 48 | |
223 #define SUB 49 | |
224 #define CMP 50 | |
225 #define RSHIFT 51 | |
226 #define URSHIFT 52 | |
227 #define LSHIFT 53 | |
228 #define ULSHIFT 54 | |
229 #define GT 55 | |
230 #define UGT 56 | |
231 #define GE 57 | |
232 #define UGE 58 | |
233 #define LT 59 | |
234 #define ULT 60 | |
235 #define LE 61 | |
236 #define ULE 62 | |
237 #define EQ 63 | |
238 #define NEQ 64 | |
239 #define BAND 65 | |
240 #define EOR 66 | |
241 #define BOR 67 | |
242 #define LAND 68 | |
243 #define LOR 69 | |
244 #define ASS 70 | |
245 #define UCMP 71 | |
246 #define UCMPGE 72 | |
247 #define CMPGE 73 | |
248 #define CMPEQ 74 | |
249 #define CMPNEQ 75 | |
250 #define ASSOP 76 | |
251 #define COMMA 77 | |
164 | 252 |
461 | 253 #define CASS 78 |
254 #define CASSOP 79 | |
255 #define CUASSOP 80 | |
0 | 256 |
327 | 257 #define SASS (SOP+CASS) |
164 | 258 #define SASSOP (SOP+CASSOP) |
259 #define SUASSOP (SOP+CUASSOP) | |
260 | |
327 | 261 #define DASS (DOP+ASS) |
262 #define DCMPGE (DOP+CMPGE) | |
263 #define DCMPEQ (DOP+CMPEQ) | |
264 #define DCMPNEQ (DOP+CMPNEQ) | |
265 #define DASSOP (DOP+ASSOP) | |
266 #define DCMP (DOP+CMP) | |
267 #define DMINUS (DOP+MINUS) | |
268 #define DMUL (DOP+MUL) | |
269 #define DDIV (DOP+DIV) | |
270 #define DADD (DOP+ADD) | |
271 #define DSUB (DOP+SUB) | |
164 | 272 |
327 | 273 #define FASS (FOP+ASS) |
274 #define FCMPGE (FOP+CMPGE) | |
275 #define FCMPEQ (FOP+CMPEQ) | |
276 #define FCMPNEQ (FOP+CMPNEQ) | |
277 #define FASSOP (FOP+ASSOP) | |
278 #define FCMP (FOP+CMP) | |
279 #define FMINUS (FOP+MINUS) | |
280 #define FMUL (FOP+MUL) | |
281 #define FDIV (FOP+DIV) | |
282 #define FADD (FOP+ADD) | |
283 #define FSUB (FOP+SUB) | |
78 | 284 |
327 | 285 #define LASS (LOP+CASS) |
286 #define LCMPGE (LOP+CMPGE) | |
287 #define LCMPEQ (LOP+CMPEQ) | |
288 #define LCMPNEQ (LOP+CMPNEQ) | |
195 | 289 #define LASSOP (LOP+CASSOP) |
164 | 290 #define LUASSOP (LOP+CUASSOP) |
327 | 291 #define LCMP (LOP+CMP) |
292 #define LMINUS (LOP+MINUS) | |
293 #define LMUL (LOP+MUL) | |
294 #define LDIV (LOP+DIV) | |
295 #define LUMUL (LOP+UMUL) | |
296 #define LUDIV (LOP+UDIV) | |
297 #define LADD (LOP+ADD) | |
298 #define LSUB (LOP+SUB) | |
81 | 299 |
195 | 300 |
327 | 301 #define LMOD (LOP+MOD) |
302 #define LUMOD (LOP+UMOD) | |
303 #define LLSHIFT (LOP+LSHIFT) | |
304 #define LULSHIFT (LOP+ULSHIFT) | |
305 #define LRSHIFT (LOP+RSHIFT) | |
306 #define LURSHIFT (LOP+URSHIFT) | |
307 #define LBAND (LOP+BAND) | |
308 #define LEOR (LOP+EOR) | |
309 #define LBOR (LOP+BOR) | |
195 | 310 |
461 | 311 #define BASS 81 |
312 #define BASSOP 82 | |
313 #define BFD_REPL 83 | |
195 | 314 |
461 | 315 #define STASS 84 |
326 | 316 |
164 | 317 |
318 #define BINARY_ARGS(i) (MUL<=(i%SOP)&&(i%SOP)<=STASS) | |
319 | |
320 /* tarnary argments */ | |
321 | |
461 | 322 #define COND 85 |
327 | 323 #define SCOND (SOP+COND) |
324 #define DCOND (DOP+COND) | |
325 #define FCOND (FOP+COND) | |
326 #define LCOND (LOP+COND) | |
164 | 327 |
328 #define TARNARY_ARGS(i) (COND==(i%SOP)) | |
329 | |
330 /* not appeared as tags */ | |
81 | 331 |
461 | 332 #define LPAR 86 |
333 #define RPAR 87 | |
334 #define LBRA 88 | |
335 #define RBRA 89 | |
336 #define LC 90 | |
337 #define RC 91 | |
338 #define COLON 92 | |
339 #define SM 93 | |
340 #define PERIOD 94 | |
341 #define ARROW 95 | |
342 #define CNAME 96 | |
194 | 343 |
461 | 344 #define I2C 97 |
345 #define I2S 98 | |
346 #define I2I 99 | |
347 #define I2U 100 | |
348 #define I2D 101 | |
349 #define I2F 102 | |
350 #define I2LL 103 | |
351 #define I2ULL 104 | |
353 | 352 |
461 | 353 #define U2UC 105 |
354 #define U2US 106 | |
355 #define U2I 107 | |
356 #define U2U 108 | |
357 #define U2D 109 | |
358 #define U2F 110 | |
359 #define U2LL 111 | |
360 #define U2ULL 112 | |
353 | 361 |
194 | 362 |
327 | 363 #define D2I (DOP+I2I) |
364 #define D2U (DOP+I2U) | |
365 #define D2D (DOP+I2D) | |
366 #define D2F (DOP+I2F) | |
367 #define D2LL (DOP+I2LL) | |
368 #define D2ULL (DOP+I2ULL) | |
164 | 369 |
327 | 370 #define F2I (FOP+I2I) |
371 #define F2U (FOP+I2U) | |
372 #define F2D (FOP+I2D) | |
373 #define F2F (FOP+I2F) | |
374 #define F2LL (FOP+I2LL) | |
375 #define F2ULL (FOP+I2ULL) | |
194 | 376 |
327 | 377 #define LL2I (LOP+I2I) |
378 #define LL2U (LOP+I2U) | |
379 #define LL2D (LOP+I2D) | |
380 #define LL2F (LOP+I2F) | |
381 #define LL2LL (LOP+I2LL) | |
382 #define LL2ULL (LOP+I2ULL) | |
194 | 383 |
327 | 384 #define ULL2I (LOP+U2I) |
385 #define ULL2U (LOP+U2U) | |
386 #define ULL2D (LOP+U2D) | |
387 #define ULL2F (LOP+U2F) | |
388 #define ULL2LL (LOP+U2LL) | |
389 #define ULL2ULL (LOP+U2ULL) | |
194 | 390 |
164 | 391 /* tree node tags end */ |
392 | |
453 | 393 /* statement start */ |
394 | |
461 | 395 #define ST_DECL 113 |
396 #define ST_IF 114 | |
397 #define ST_DO 115 | |
398 #define ST_WHILE 116 | |
399 #define ST_FOR 117 | |
400 #define ST_SWITCH 118 | |
401 #define ST_COMP 119 | |
402 #define ST_BREAK 120 | |
403 #define ST_CONTINUE 121 | |
404 #define ST_CASE 122 | |
405 #define ST_DEFAULT 123 | |
406 #define ST_RETURN 124 | |
407 #define ST_GOTO 125 | |
408 #define ST_ASM 126 | |
409 #define ST_LABEL 127 | |
410 #define ST_COMMENT 128 | |
453 | 411 |
412 #define IS_STATEMENT(i) (ST_DECL<=i&&i<=ST_COMMENT) | |
413 | |
414 /* statement end */ | |
415 | |
164 | 416 /* error number start */ |
0 | 417 |
327 | 418 #define FILERR 1 |
419 #define DCERR 2 | |
420 #define RDERR 3 | |
421 #define STERR 4 | |
422 #define EXERR 5 | |
423 #define CNERR 6 | |
424 #define CHERR 7 | |
425 #define GSERR 8 | |
426 #define LSERR 9 | |
427 #define STRERR 10 | |
428 #define LNERR 11 | |
429 #define EOFERR 12 | |
430 #define MCERR 13 | |
431 #define INCERR 14 | |
432 #define HPERR 15 | |
433 #define TYERR 16 | |
434 #define LVERR 17 | |
435 #define UDERR 18 | |
436 #define OPTION 19 | |
437 #define REG_ERR 20 | |
389 | 438 #define RGERR 21 |
439 #define CODE_ERR 22 | |
440 #define MSERR 23 | |
441 #define BTERR 24 | |
442 #define HSERR 25 | |
443 #define NMERR 26 | |
444 #define MMERR 27 | |
445 #define INERR 28 | |
453 | 446 #define ILERR 29 |
327 | 447 |
164 | 448 /* error number end */ |
0 | 449 |
461 | 450 #define KONST_BIT 1 |
451 #define VOLATILE_BIT 2 | |
452 #define RESTRICT_BIT 4 | |
453 | |
25 | 454 #define FILES 10 |
327 | 455 #define MAX_INCLUDE_PATH_COUNT 10 |
448 | 456 /* |
457 For this comiler 8192*2 is Ok. Linux kernel requires 8192*4. | |
458 */ | |
447 | 459 #define GSYMS (8192*4) |
358 | 460 #define HEAPSIZE 30000 |
452 | 461 #define CHEAPSIZE (sizeof(NMTBL)*8192) |
327 | 462 #define LBUFSIZE 4096 |
347 | 463 #define STRSIZE 4096 |
254 | 464 |
0 | 465 typedef struct nametable { |
327 | 466 char *nm; |
348 | 467 struct nametable *next; |
445 | 468 int sc,attr; |
469 int ty,dsp; } NMTBL; | |
0 | 470 |
452 | 471 extern int *heap; /* heap area (in cheap ) */ |
472 extern NMTBL *global_list; /* list of all global NMTBL */ | |
473 extern NMTBL *local_static_list; /* list of local static variable */ | |
0 | 474 |
195 | 475 #if FLOAT_CODE |
81 | 476 extern int dlist2(int e1, double e2); |
195 | 477 #endif |
478 #if LONGLONG_CODE | |
479 extern int llist2(int e1, long long e2); | |
480 #endif | |
61 | 481 extern int list2(int e1, int e2); |
482 extern int list3(int e1, int e2, int e3); | |
483 extern int list4(int e1, int e2, int e3,int e4); | |
450
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
484 extern int list5(int e1, int e2, int e3,int e4,int e5); |
318 | 485 extern int length(int e1); |
464 | 486 extern int getfree(int size); |
318 | 487 extern int nth(int n,int e1); |
61 | 488 extern int reverse0(int t1); |
489 extern int append4(int p,int a1,int a2,int a3); | |
450
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
490 extern int append5(int p,int a1,int a2,int a3,int a4); |
309 | 491 extern int insert_ascend(int p,int e,int eq()); |
61 | 492 |
347 | 493 extern void free_nptr(NMTBL *n); |
494 extern NMTBL *get_nptr(); | |
346 | 495 |
467 | 496 #if 1 |
450
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
497 extern int heapsize; |
467 | 498 #define CHECK_HEAP(b) ({int _k=(int)(b);if(_k>heapsize||_k<0)error(-1);_k;}) |
450
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
499 #else |
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
500 #define CHECK_HEAP(b) (b) |
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
501 #endif |
33 | 502 |
450
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
503 #define car(e) (heap[(int)(CHECK_HEAP(e))]) |
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
504 |
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
505 #define cadr(e) (heap[((int)(CHECK_HEAP(e)))+1]) |
33 | 506 |
450
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
507 #define caddr(e) (heap[((int)(CHECK_HEAP(e)))+2]) |
33 | 508 |
450
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
509 #define cadddr(e) (heap[((int)(CHECK_HEAP(e)))+3]) |
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
510 |
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
511 #define caddddr(e) (heap[((int)(CHECK_HEAP(e)))+4]) |
449 | 512 |
195 | 513 #if FLOAT_CODE |
81 | 514 #define dcadr(e) (*(double*)&heap[((int)(e))+1]) |
515 #define dcaddr(e) (*(double*)&heap[((int)(e))+2]) | |
195 | 516 #endif |
517 | |
518 #if LONGLONG_CODE | |
519 #define lcadr(e) (*(long long*)&heap[((int)(e))+1]) | |
520 #define lcaddr(e) (*(long long*)&heap[((int)(e))+2]) | |
521 #endif | |
81 | 522 |
33 | 523 /* end */ |