scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

i386-sysv.c (3859B)


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