Mercurial > hg > CbC > old > device
view mc.h @ 856:d9dd3e6e7c5f
macro compatibility
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Nov 2011 05:44:49 +0900 |
parents | 75e30aea08cd |
children | 9745d517f113 |
line wrap: on
line source
/* Micro-C header file */ /************************************************************************ ** Copyright (C) 2006 Shinji Kono ** 連絡先: 琉球大学情報工学科 河野 真治 ** (E-Mail Address: kono@ie.u-ryukyu.ac.jp) ** ** このソースのいかなる複写,改変,修正も許諾します。ただし、 ** その際には、誰が貢献したを示すこの部分を残すこと。 ** 再配布や雑誌の付録などの問い合わせも必要ありません。 ** 営利利用も上記に反しない範囲で許可します。 ** バイナリの配布の際にはversion messageを保存することを条件とします。 ** このプログラムについては特に何の保証もしない、悪しからず。 ** ** Everyone is permitted to do anything on this program ** including copying, modifying, improving, ** as long as you don't try to pretend that you wrote it. ** i.e., the above copyright notice has to appear in all copies. ** Binary distribution requires original version messages. ** You don't have to ask before copying, redistribution or publishing. ** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. ***********************************************************************/ #define FLOAT_CODE 1 #define LONGLONG_CODE 1 #define CASE_CODE 1 #define ASM_CODE 1 #define BIT_FIELD_CODE 1 #define STRUCT_ALIGN 1 /* reserved word start */ /* type ( keyword ) */ #define INT (-1) #define UNSIGNED (-2) #define CHAR (-3) #define UCHAR (-4) #define POINTER (-5) #define ARRAY (-6) #define STRUCT (-7) #define UNION (-8) #define FUNCTION (-9) #define SIGNED (-10) #define LONG (-11) #define SHORT (-12) #define USHORT (-13) #define VOID (-14) #define CODE (-15) #define ENUM (-16) #define FLOAT (-17) #define DOUBLE (-18) #define LONGLONG (-19) #define ULONGLONG (-20) /* type qualifier */ #define KONST (-21) #define STATIC (-22) #define EXTRN (-23) #define EXTRN1 (-24) #define VOLATILE (-25) #define RESTRICT (-26) #define INLINE (-27) #define NOINLINE (-28) #define REGISTER (-29) #define FREGISTER (-30) #define DREGISTER (-31) #define LREGISTER (-32) #define POSSIBLE_VALUES (-33) #define DOTS (-34) /* keyword */ #define GOTO (-35) #define RETURN (-36) #define BREAK (-37) #define CONTINUE (-38) #define IF (-39) #define ELSE (-40) #define FOR (-41) #define DO (-42) #define WHILE (-43) #define SWITCH (-44) #define CASE (-45) #define DEFAULT (-46) #define RESERVE (-47) #define TAG (-48) #define FIELD (-49) #define IDENT (-50) #define MACRO (-51) #define BLABEL (-52) #define FLABEL (-53) #define TYPEDEF (-54) #define SIZEOF (-55) #define TYPE (-56) #define DEFINED (-57) #define ENVIRONMENT (-58) #define FMACRO (-59) #define LMACRO (-60) #define TYPEOF (-61) #define ASM (-62) #define C_FILE (-63) #define C_FUNCTION (-64) #define C_LINE (-65) #define ALIGNED (-66) #define GENERATED (-67) #define NORETURN (-68) /* reserved word end */ #define EMPTY (-99) /* mode start */ #define TOP 0 #define GDECL 1 #define GSDECL 2 #define GUDECL 3 #define ADECL 4 #define LDECL 5 #define LSDECL 6 #define LUDECL 7 #define STADECL 8 #define STAT 9 #define GTDECL 10 #define LTDECL 11 #define IFDEF 12 #define MDECL 13 #define GEDECL 14 #define LEDECL 15 #define LLDECL 16 #define SFDINIT 17 /* mode end */ #define US 1 #define AS 10000 #define SOP 200 #define COP 400 #define DOP 600 #define FOP 800 #define LOP 1000 /* tree node tags start */ #define LIST_ARGS(i) (i==FUNCTION||i==CODE||i==ASM) #define OP(i) (i%SOP) /* tag value without attribute */ #define OP_TAG(i) (((i)/SOP)*SOP) /* attribute of tag */ /* nullary argments */ #define GVAR 1 #define RGVAR 2 #define URGVAR 3 #define LVAR 4 #define RLVAR 5 #define URLVAR 6 #define CRGVAR (COP+RGVAR) #define CURGVAR (COP+URGVAR) #define CRLVAR (COP+RLVAR) #define CURLVAR (COP+URLVAR) #define FRGVAR (FOP+RGVAR) #define FRLVAR (FOP+RLVAR) #define DRGVAR (DOP+RGVAR) #define DRLVAR (DOP+RLVAR) #define SRGVAR (SOP+RGVAR) #define SURGVAR (SOP+URGVAR) #define SRLVAR (SOP+RLVAR) #define SURLVAR (SOP+URLVAR) #define LRGVAR (LOP+RGVAR) #define LURGVAR (LOP+URGVAR) #define LRLVAR (LOP+RLVAR) #define LURLVAR (LOP+URLVAR) #define CONST 7 #define DCONST (DOP+CONST) #define FCONST (FOP+CONST) #define LCONST (LOP+CONST) #define STRING 8 #define FNAME 9 #define LCALL 10 #define COMMENT 11 #define DECL 12 #define COMP 13 #define IVAR 14 #define RIVAR 15 #define BUILTIN_INF 16 #define BUILTIN_INFF 17 #define BUILTIN_INFL 18 #define LABEL 19 #define STRINGS 20 #define NULLARY_ARGS(i) (i==RETURN||i==ENVIRONMENT||i==LCALL||i==REGISTER||i==DREGISTER||i==FREGISTER||i==LREGISTER||(GVAR<=(i%SOP)&&(i%SOP)<=LABEL)) /* unary argments */ #define ADDRESS 21 #define MINUS 22 #define LNOT 23 #define BNOT 24 #define INC 25 #define PERIOD 26 #define ARROW 27 #define POSTINC 28 #define UPOSTINC 29 #define PREINC 30 #define UPREINC 31 #define POSTDEC 32 #define UPOSTDEC 33 #define PREDEC 34 #define UPREDEC 35 #define DEC 36 #define CPOSTINC (COP+POSTINC) #define CUPOSTINC (COP+UPOSTINC) #define CPREINC (COP+PREINC) #define CUPREINC (COP+UPREINC) #define CPOSTDEC (COP+POSTDEC) #define CUPOSTDEC (COP+UPOSTDEC) #define CPREDEC (COP+CPREDEC) #define CUPREDEC (COP+UPREDEC) #define SPOSTINC (SOP+POSTINC) #define SUPOSTINC (SOP+UPOSTINC) #define SPREINC (SOP+PREINC) #define SUPREINC (SOP+UPREINC) #define SPOSTDEC (SOP+POSTDEC) #define SUPOSTDEC (SOP+UPOSTDEC) #define SPREDEC (SOP+PREDEC) #define SUPREDEC (SOP+UPREDEC) #define FPOSTINC (FOP+POSTINC) #define FPREINC (FOP+PREINC) #define DPOSTINC (DOP+POSTINC) #define DPREINC (DOP+PREINC) #define LPOSTINC (LOP+POSTINC) #define LPREINC (LOP+PREINC) #define LUPOSTINC (LOP+UPOSTINC) #define LUPREINC (LOP+UPREINC) #define INDIRECT 37 #define RINDIRECT 38 #define URINDIRECT 39 #define CRINDIRECT (COP+RINDIRECT) #define CURINDIRECT (COP+URINDIRECT) #define SRINDIRECT (SOP+RINDIRECT) #define SURINDIRECT (SOP+URINDIRECT) #define FRINDIRECT (FOP+RINDIRECT) #define DRINDIRECT (DOP+RINDIRECT) #define LRINDIRECT (LOP+RINDIRECT) #define LURINDIRECT (LOP+URINDIRECT) #define RSTRUCT 40 #define ALLOCA 41 #define BUILTINP 42 #define BUILTIN_EXPECT 43 #define BUILTIN_FABS 44 #define BUILTIN_FABSF 45 #define BUILTIN_FABSL 46 #define ATTRIBUTE 47 #define BIT_FIELD 48 #define RBIT_FIELD 49 #define BPREINC 50 #define BPOSTINC 51 #define CAST 52 #define DECL_DATA 53 #define CONV 54 #define UNARY_ARGS(i) (ADDRESS<=(i%SOP)&&(i%SOP)<=CONV) /* binary argments */ #define MUL 55 #define UMUL 56 #define DIV 57 #define UDIV 58 #define MOD 59 #define UMOD 60 #define ADD 61 #define SUB 62 #define CMP 63 #define RSHIFT 64 #define URSHIFT 65 #define LSHIFT 66 #define ULSHIFT 67 #define GT 68 #define UGT 69 #define GE 70 #define UGE 71 #define LT 72 #define ULT 73 #define LE 74 #define ULE 75 #define EQ 76 #define NEQ 77 #define BAND 78 #define EOR 79 #define BOR 80 #define LAND 81 #define LOR 82 #define ASS 83 #define UCMP 84 #define UCMPGE 85 #define CMPGE 86 #define CMPEQ 87 #define CMPNEQ 88 #define ASSOP 89 #define UASSOP 90 #define COMMA 91 #define CASS (COP+ASS) #define CASSOP (COP+ASSOP) #define CUASSOP (COP+UASSOP) #define SASS (SOP+ASS) #define SASSOP (SOP+ASSOP) #define SUASSOP (SOP+UASSOP) #define DASS (DOP+ASS) #define DCMPGE (DOP+CMPGE) #define DCMPEQ (DOP+CMPEQ) #define DCMPNEQ (DOP+CMPNEQ) #define DASSOP (DOP+ASSOP) #define DCMP (DOP+CMP) #define DMINUS (DOP+MINUS) #define DMUL (DOP+MUL) #define DDIV (DOP+DIV) #define DADD (DOP+ADD) #define DSUB (DOP+SUB) #define FASS (FOP+ASS) #define FCMPGE (FOP+CMPGE) #define FCMPEQ (FOP+CMPEQ) #define FCMPNEQ (FOP+CMPNEQ) #define FASSOP (FOP+ASSOP) #define FCMP (FOP+CMP) #define FMINUS (FOP+MINUS) #define FMUL (FOP+MUL) #define FDIV (FOP+DIV) #define FADD (FOP+ADD) #define FSUB (FOP+SUB) #define LASS (LOP+CASS) #define LCMPGE (LOP+CMPGE) #define LCMPEQ (LOP+CMPEQ) #define LCMPNEQ (LOP+CMPNEQ) #define LASSOP (LOP+CASSOP) #define LUASSOP (LOP+CUASSOP) #define LCMP (LOP+CMP) #define LMINUS (LOP+MINUS) #define LMUL (LOP+MUL) #define LDIV (LOP+DIV) #define LUMUL (LOP+UMUL) #define LUDIV (LOP+UDIV) #define LADD (LOP+ADD) #define LSUB (LOP+SUB) #define LMOD (LOP+MOD) #define LUMOD (LOP+UMOD) #define LLSHIFT (LOP+LSHIFT) #define LULSHIFT (LOP+ULSHIFT) #define LRSHIFT (LOP+RSHIFT) #define LURSHIFT (LOP+URSHIFT) #define LBAND (LOP+BAND) #define LEOR (LOP+EOR) #define LBOR (LOP+BOR) #define BASS 92 #define BASSOP 93 #define BFD_REPL 94 #define JUMP 95 #define DECL_DATA_ARRAY 96 #define DECL_DATA_LIST 97 #define DECL_DATA_FIELD 98 #define STASS 99 #define BINARY_ARGS(i) ((MUL<=(i%SOP)&&(i%SOP)<=STASS)||i==ARRAY) /* ternary argments */ #define COND 100 #define UCOND 101 #define SCOND (SOP+COND) #define SUCOND (SOP+UCOND) #define DCOND (DOP+COND) #define FCOND (FOP+COND) #define LCOND (LOP+COND) #define LUCOND (LOP+UCOND) #define TERNARY_ARGS(i) (COND==(i%SOP)||UCOND==(i%SOP)) /* not appeared as tags */ #define LPAR 102 #define RPAR 103 #define LBRA 104 #define RBRA 105 #define LC 106 #define RC 107 #define COLON 108 #define SM 109 #define CNAME 110 #define I2C 111 #define I2S 112 #define I2I 113 #define I2U 114 #define I2D 115 #define I2F 116 #define I2LL 117 #define I2ULL 118 #define U2UC 119 #define U2US 120 #define U2I 121 #define U2U 122 #define U2D 123 #define U2F 124 #define U2LL 125 #define U2ULL 126 #define D2I (DOP+I2I) #define D2U (DOP+I2U) #define D2D (DOP+I2D) #define D2F (DOP+I2F) #define D2LL (DOP+I2LL) #define D2ULL (DOP+I2ULL) #define F2I (FOP+I2I) #define F2U (FOP+I2U) #define F2D (FOP+I2D) #define F2F (FOP+I2F) #define F2LL (FOP+I2LL) #define F2ULL (FOP+I2ULL) #define LL2I (LOP+I2I) #define LL2U (LOP+I2U) #define LL2D (LOP+I2D) #define LL2F (LOP+I2F) #define LL2LL (LOP+I2LL) #define LL2ULL (LOP+I2ULL) #define ULL2I (LOP+U2I) #define ULL2U (LOP+U2U) #define ULL2D (LOP+U2D) #define ULL2F (LOP+U2F) #define ULL2LL (LOP+U2LL) #define ULL2ULL (LOP+U2ULL) #define BUILTIN_TYPES_COMPATIBLE_P 127 /* tree node tags end */ /* statement start */ #define ST_DECL 128 #define ST_IF 129 #define ST_DO 130 #define ST_WHILE 131 #define ST_FOR 132 #define ST_SWITCH 133 #define ST_COMP 134 #define ST_BREAK 135 #define ST_CONTINUE 136 #define ST_CASE 137 #define ST_DEFAULT 138 #define ST_RETURN 139 #define ST_GOTO 140 #define ST_ASM 141 #define ST_LABEL 142 #define ST_OP 143 #define ST_COMMENT 144 #define IS_STATEMENT(i) (i==INLINE||(ST_DECL<=i&&i<=ST_COMMENT)) #define HAS_ADDRESS 145 /* statement end */ /* error number start */ #define FILERR 1 #define DCERR 2 #define RDERR 3 #define STERR 4 #define EXERR 5 #define CNERR 6 #define CHERR 7 #define GSERR 8 #define LSERR 9 #define STRERR 10 #define LNERR 11 #define EOFERR 12 #define MCERR 13 #define INCERR 14 #define HPERR 15 #define TYERR 16 #define LVERR 17 #define UDERR 18 #define OPTION 19 #define REG_ERR 20 #define RGERR 21 #define CODE_ERR 22 #define MSERR 23 #define BTERR 24 #define HSERR 25 #define NMERR 26 #define MMERR 27 #define INERR 28 #define AGERR 29 #define ILERR 30 #define CSERR 31 #define GTERR 32 #define FNERR 33 #define UCERR 34 #define UFERR 35 #define ENERR 36 #define RETERR 37 #define UFLDERR 38 #define SIERR 39 /* error number end */ /* ctmode bit */ #define KONST_BIT 1 #define VOLATILE_BIT 2 #define RESTRICT_BIT 4 #define FILES 10 #define MAX_INCLUDE_PATH_COUNT 10 /* For this comiler 8192*2 is Ok. Linux kernel requires 8192*4. we need automatic increment of gsyms? */ #define GSYMS (8192*32) #define HEAPSIZE 150000 #define CHEAPSIZE (sizeof(NMTBL)*8192) #define LBUFSIZE 4096 #define STRSIZE 4096 typedef struct nametable { char *nm; struct nametable *next; int sc,attr; int ty,dsp; union { struct nametable *nptr; char *nm; } u; } NMTBL; extern int *heap; /* heap area (in cheap ) */ extern NMTBL *global_list; /* list of all global NMTBL */ extern NMTBL *local_static_list; /* list of local static variable */ #if FLOAT_CODE extern int dlist2(int e1, double e2); #endif #if LONGLONG_CODE extern int llist2(int e1, long long e2); #endif extern int list2(int e1, int e2); extern int list3(int e1, int e2, int e3); extern int list3n(int e1, int e2, NMTBL *e3); extern int glist3n(int e1, int e2, NMTBL *e3); extern int list4(int e1, int e2, int e3,int e4); extern int list4n(int e1, int e2, int e3,NMTBL *e4); extern int list4s(int e1, int e2, int e3,char *e4); extern int glist4n(int e1, int e2, int e3,NMTBL *e4); extern int list5(int e1, int e2, int e3,int e4,int e5); extern int list5n(int e1, int e2, int e3,int e4,NMTBL * e5); extern int length(int e1); extern int getfree(int size); extern int nth(int n,int e1); extern int reverse0(int t1); extern int append4(int p,int a1,int a2,int a3); extern int append5(int p,int a1,int a2,int a3,int a4); extern int insert_ascend(int p,int e,int eq()); extern void free_nptr(NMTBL *n); extern NMTBL *get_nptr(); #define align(x,alig) ((x+(alig-1))&~(alig-1)) // mc-tree.c extern void print_expr(int e, FILE *vout); // #if 1 //extern int heapsize; // #define CHECK_HEAP1(b) ({int _k=(int)(b);if(_k>heapsize||_k<=0)error(-1);_k;}) //#else #define CHECK_HEAP(b) (b) //#endif #define car(e) (heap[(int)(CHECK_HEAP(e))]) #define cadr(e) (heap[((int)(CHECK_HEAP(e)))+1]) #define caddr(e) (heap[((int)(CHECK_HEAP(e)))+2]) #define cadddr(e) (heap[((int)(CHECK_HEAP(e)))+3]) #define caddddr(e) (heap[((int)(CHECK_HEAP(e)))+4]) #define ncaddr(e) (*(NMTBL**)&heap[((int)(e))+2]) #define ncadddr(e) (*(NMTBL**)&heap[((int)(e))+3]) #define ncaddddr(e) (*(NMTBL**)&heap[((int)(e))+4]) #define vcaddr(e) (*(void**)&heap[((int)(e))+2]) #define vcadddr(e) (*(void**)&heap[((int)(e))+3]) #define pcaddr(e) (*(int**)&heap[((int)(e))+2]) #define pcadddr(e) (*(int**)&heap[((int)(e))+3]) #define scaddr(e) (*(char**)&heap[((int)(e))+2]) #ifdef NOTHREAD my_spe_run_thread(t_args); #endif #define scadddr(e) (*(char**)&heap[((int)(e))+3]) #if FLOAT_CODE #define dcadr(e) (*(double*)&heap[((int)(e))+1]) #define dcaddr(e) (*(double*)&heap[((int)(e))+2]) #endif #if LONGLONG_CODE #define lcadr(e) (*(long long*)&heap[((int)(e))+1]) #define lcaddr(e) (*(long long*)&heap[((int)(e))+2]) #endif /* end */