amd64-sysv.c (3911B)
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 tp->op == PTR && eqtype(tp->type, va_type, EQUIV); 24 } 25 26 Arch * 27 amd64_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 .ushorttype = { 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 .shorttype = { 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 = { 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 = { 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_INT64, 110 .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, 111 .size = 8, 112 .align = 8, 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 = 8, 121 .n.rank = RANK_ULONG, 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 = 8, 153 .n.rank = RANK_DOUBLE, 154 }, 155 .ldoubletype = { 156 .op = FLOAT, 157 .letter = L_LDOUBLE, 158 .prop = TDEFINED | TARITH, 159 .size = 16, 160 .align = 16, 161 .n.rank = RANK_LDOUBLE, 162 }, 163 .sizettype = { 164 .op = INT, 165 .letter = L_UINT64, 166 .prop = TDEFINED | TINTEGER | TARITH, 167 .size = 8, 168 .align = 8, 169 .n.rank = RANK_UINT, 170 }, 171 .pdifftype = { 172 .op = INT, 173 .letter = L_INT64, 174 .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, 175 .size = 8, 176 .align = 8, 177 .n.rank = RANK_LONG, 178 }, 179 .ellipsistype = { 180 .op = ELLIPSIS, 181 .letter = L_ELLIPSIS, 182 .prop = TDEFINED, 183 }, 184 .va_type = { 185 .op = STRUCT, 186 .letter = L_VA_ARG, 187 .prop = TDEFINED, 188 .size = 24, 189 .align = 8, 190 }, 191 .wchartype = { 192 .op = INT, 193 .letter = L_UINT32, 194 .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, 195 .size = 4, 196 .align = 4, 197 .n.rank = RANK_INT, 198 }, 199 }; 200 201 sizettype = &arch.sizettype; 202 arch.va_list_type = *mktype(&arch.va_type, ARY, 1, NULL); 203 arch.pvoidtype.type = &arch.voidtype; 204 arch.valid_va_list = local_valid_va_list; 205 206 return &arch; 207 }