scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

arch.c (4705B)


      1 static char sccsid[] = "@(#) ./cc1/arch/z80/arch.c";
      2 
      3 #include "../../../inc/scc.h"
      4 #include "../../cc1.h"
      5 
      6 #define RANK_BOOL    0
      7 #define RANK_SCHAR   1
      8 #define RANK_UCHAR   1
      9 #define RANK_CHAR    1
     10 #define RANK_SHORT   2
     11 #define RANK_USHORT  2
     12 #define RANK_INT     3
     13 #define RANK_UINT    3
     14 #define RANK_LONG    4
     15 #define RANK_ULONG   4
     16 #define RANK_LLONG   5
     17 #define RANK_ULLONG  5
     18 #define RANK_FLOAT   6
     19 #define RANK_DOUBLE  7
     20 #define RANK_LDOUBLE 8
     21 
     22 /*
     23  * Initializaion of type pointers were done with
     24  * a C99 initilizator '... = &(Type) {...', but
     25  * c compiler in Plan9 gives error with this
     26  * syntax, so I have switched it to this ugly form
     27  * I hope I will change it again in the future
     28  */
     29 
     30 static Type types[] = {
     31 	{       /* 0 = voidtype */
     32 		.op = VOID,
     33 		.letter = L_VOID,
     34 	},
     35 	{       /* 1 = pvoidtype */
     36 		.op = PTR,
     37 		.letter = L_POINTER,
     38 		.prop = TDEFINED,
     39 		.type = &types[5], /* char type */
     40 		.size = 2,
     41 		.align = 2,
     42 	},
     43 	{      /* 2 = booltype */
     44 		.op = INT,
     45 		.letter = L_BOOL,
     46 		.prop = TDEFINED | TINTEGER | TARITH,
     47 		.size = 1,
     48 		.align = 1,
     49 		.n.rank = RANK_BOOL,
     50 	},
     51 	{       /* 3 = schartype */
     52 		.op = INT,
     53 		.letter = L_INT8,
     54 		.prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
     55 		.size = 1,
     56 		.align = 1,
     57 		.n.rank = RANK_SCHAR,
     58 	},
     59 	{      /* 4 = uchartype */
     60 		.op = INT,
     61 		.letter = L_UINT8,
     62 		.prop = TDEFINED | TINTEGER | TARITH,
     63 		.size = 1,
     64 		.align = 1,
     65 		.n.rank = RANK_UCHAR,
     66 	},
     67 	{      /* 5 = chartype */
     68 		.op = INT,
     69 		.letter = L_UINT8,
     70 		.prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
     71 		.size = 1,
     72 		.align = 1,
     73 		.n.rank = RANK_CHAR,
     74 	},
     75 	{       /* 6 = ushortype */
     76 		.op = INT,
     77 		.letter = L_UINT16,
     78 		.prop = TDEFINED | TINTEGER | TARITH,
     79 		.size = 2,
     80 		.align = 1,
     81 		.n.rank = RANK_USHORT,
     82 	},
     83 	{       /* 7 = shortype */
     84 		.op = INT,
     85 		.letter = L_INT16,
     86 		.prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
     87 		.size = 2,
     88 		.align = 1,
     89 		.n.rank = RANK_SHORT,
     90 	},
     91 	{       /* 8 = uinttype */
     92 		.op = INT,
     93 		.letter = L_UINT16,
     94 		.prop = TDEFINED | TINTEGER | TARITH,
     95 		.size = 2,
     96 		.align = 1,
     97 		.n.rank = RANK_UINT,
     98 	},
     99 	{       /* 9 = inttype */
    100 		.op = INT,
    101 		.letter = L_INT16,
    102 		.prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
    103 		.size = 2,
    104 		.align = 1,
    105 		.n.rank = RANK_INT,
    106 	},
    107 	{      /* 10 = longtype */
    108 		.op = INT,
    109 		.letter = L_INT32,
    110 		.prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
    111 		.size = 4,
    112 		.align = 1,
    113 		.n.rank = RANK_LONG,
    114 	},
    115 	{       /* 11 = ulongtype */
    116 		.op = INT,
    117 		.letter = L_UINT32,
    118 		.prop = TDEFINED | TINTEGER | TARITH,
    119 		.size = 4,
    120 		.align = 1,
    121 		.n.rank = RANK_ULONG,
    122 	},
    123 	{	/* 12 = ullongtype */
    124 		.op = INT,
    125 		.letter = L_UINT64,
    126 		.prop = TDEFINED | TINTEGER | TARITH,
    127 		.size = 8,
    128 		.align = 1,
    129 		.n.rank = RANK_ULLONG,
    130 	},
    131 	{       /* 13 = llongtype */
    132 		.op = INT,
    133 		.letter = L_INT64,
    134 		.prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
    135 		.size = 8,
    136 		.align = 1,
    137 		.n.rank = RANK_LLONG,
    138 	},
    139 	{       /* 14 = floattype */
    140 		.op = FLOAT,
    141 		.letter = L_FLOAT,
    142 		.prop = TDEFINED | TARITH,
    143 		.size = 4,
    144 		.align = 1,
    145 		.n.rank = RANK_FLOAT,
    146 	},
    147 	{       /* 15 = doubletype */
    148 		.op = FLOAT,
    149 		.letter = L_DOUBLE,
    150 		.prop = TDEFINED | TARITH,
    151 		.size = 8,
    152 		.align = 1,
    153 		.n.rank = RANK_DOUBLE,
    154 	},
    155 	{       /* 16 = ldoubletype */
    156 		.op = FLOAT,
    157 		.letter = L_LDOUBLE,
    158 		.prop = TDEFINED | TARITH,
    159 		.size = 16,
    160 		.align = 1,
    161 		.n.rank = RANK_LDOUBLE,
    162 	},
    163 	{       /* 17 = sizettype */
    164 		.op = INT,
    165 		.letter = L_UINT16,
    166 		.prop = TDEFINED | TINTEGER | TARITH,
    167 		.size = 2,
    168 		.align = 1,
    169 		.n.rank = RANK_UINT,
    170 	},
    171 	{      /* 18 = ellipsis */
    172 		.op = ELLIPSIS,
    173 		.letter = L_ELLIPSIS,
    174 		.prop = TDEFINED,
    175 	},
    176 	{       /* 7 = pdifftype */
    177 		.op = INT,
    178 		.letter = L_INT16,
    179 		.prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
    180 		.size = 2,
    181 		.align = 1,
    182 		.n.rank = RANK_SHORT,
    183 	},
    184 	{       /* 20 = va_list_type */
    185 		.op = PTR,
    186 		.letter = L_POINTER,
    187 		.prop = TDEFINED,
    188 		.size = 2,
    189 		.align = 1,
    190 	}
    191 };
    192 
    193 Type *voidtype = &types[0], *pvoidtype = &types[1],
    194      *booltype = &types[2], *schartype = &types[3],
    195      *uchartype = &types[4], *chartype = &types[5],
    196      *ushortype = &types[6], *shortype = &types[7],
    197      *uinttype = &types[8], *inttype = &types[9],
    198      *longtype = &types[10], *ulongtype = &types[11],
    199      *ullongtype = &types[12], *llongtype = &types[13],
    200      *floattype = &types[14], *doubletype = &types[15],
    201      *ldoubletype = &types[16],
    202      *sizettype = &types[17], *pdifftype = &types[19],
    203      *ellipsistype = &types[18], *va_list_type = &types[20];
    204 
    205 
    206 static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
    207               dummy1 = {.u.i = 1, .type = &types[9]};
    208 Symbol *zero = &dummy0, *one = &dummy1;
    209 
    210 void
    211 iarch(void)
    212 {
    213 }
    214 
    215 int
    216 valid_va_list(Type *tp)
    217 {
    218 	return eqtype(tp, va_list_type, 1);
    219 }