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