| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
# include "pass1.h" |
| 29 |
|
| 30 |
#ifdef LANG_CXX |
| 31 |
#define p1listf listf |
| 32 |
#define p1tfree tfree |
| 33 |
#define P1ND NODE |
| 34 |
#else |
| 35 |
#define NODE P1ND |
| 36 |
#define talloc p1alloc |
| 37 |
#endif |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
void |
| 43 |
setseg(int seg, char *name) |
| 44 |
{ |
| 45 |
#if 0 |
| 46 |
switch (seg) { |
| 47 |
case PROG: name = ".text"; break; |
| 48 |
case DATA: |
| 49 |
case LDATA: name = ".data"; break; |
| 50 |
case UDATA: break; |
| 51 |
case PICLDATA: name = ".section .data.rel.local,\"aw\",@progbits";break; |
| 52 |
case PICDATA: name = ".section .data.rel.rw,\"aw\",@progbits"; break; |
| 53 |
case PICRDATA: name = ".section .data.rel.ro,\"aw\",@progbits"; break; |
| 54 |
case STRNG: |
| 55 |
case RDATA: name = ".data"; break; |
| 56 |
case TLSDATA: name = ".section .tdata,\"awT\",@progbits"; break; |
| 57 |
case TLSUDATA: name = ".section .tbss,\"awT\",@nobits"; break; |
| 58 |
case CTORS: name = ".section\t.ctors,\"aw\",@progbits"; break; |
| 59 |
case DTORS: name = ".section\t.dtors,\"aw\",@progbits"; break; |
| 60 |
case NMSEG: |
| 61 |
printf(PRTPREF "\t.section %s,\"a%c\",@progbits\n", name, |
| 62 |
cftnsp ? 'x' : 'w'); |
| 63 |
return; |
| 64 |
} |
| 65 |
printf(PRTPREF "\t%s\n", name); |
| 66 |
#endif |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
void |
| 71 |
defalign(int al) |
| 72 |
{ |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
void |
| 80 |
defloc(struct symtab *sp) |
| 81 |
{ |
| 82 |
extern void dellab(int); |
| 83 |
char *name; |
| 84 |
|
| 85 |
name = getexname(sp); |
| 86 |
if (sp->slevel == 0) { |
| 87 |
if (sp->sclass == STATIC) |
| 88 |
printf(PRTPREF "\t.local %s\n", name); |
| 89 |
printf(PRTPREF "%s:\t", name); |
| 90 |
} else { |
| 91 |
dellab(sp->soffset); |
| 92 |
printf(PRTPREF LABFMT ":\t", sp->soffset); |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
void |
| 101 |
efcode(void) |
| 102 |
{ |
| 103 |
if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN) |
| 104 |
return; |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
void |
| 114 |
bfcode(struct symtab **sp, int cnt) |
| 115 |
{ |
| 116 |
P1ND *p, *p2; |
| 117 |
char *c; |
| 118 |
int i, l; |
| 119 |
|
| 120 |
|
| 121 |
l = strlen(cftnsp->sname)+10; |
| 122 |
c = tmpalloc(l); |
| 123 |
snprintf(c, l, " isz %s\n", exname(cftnsp->sname)); |
| 124 |
|
| 125 |
|
| 126 |
for (i = 0; i < cnt; i++) { |
| 127 |
sp[i]->sclass = STATIC; |
| 128 |
sp[i]->soffset = getlab(); |
| 129 |
p2 = cast(buildtree(ADDROF, |
| 130 |
nametree(cftnsp), 0), INCREF(INCREF(sp[i]->stype)), 0); |
| 131 |
p = buildtree(ASSIGN, nametree(sp[i]), |
| 132 |
buildtree(UMUL, buildtree(UMUL, p2, 0), 0)); |
| 133 |
ecomp(p); |
| 134 |
send_passt(IP_ASM, c); |
| 135 |
printf(LABFMT ": 0\n", sp[i]->soffset); |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
void |
| 142 |
ejobcode(int flag) |
| 143 |
{ |
| 144 |
extern void printlab(void); |
| 145 |
printlab(); |
| 146 |
} |
| 147 |
|
| 148 |
void |
| 149 |
bjobcode(void) |
| 150 |
{ |
| 151 |
astypnames[INT] = astypnames[UNSIGNED] = ""; |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
NODE * |
| 160 |
funcode(NODE *p) |
| 161 |
{ |
| 162 |
extern int gotnr; |
| 163 |
NODE *r, *l; |
| 164 |
TWORD t = DECREF(DECREF(p->n_left->n_type)); |
| 165 |
int stcall; |
| 166 |
|
| 167 |
stcall = ISSOU(t); |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
for (r = p->n_right; r->n_op == CM; r = r->n_left) { |
| 176 |
if (r->n_right->n_op != STARG) |
| 177 |
r->n_right = block(FUNARG, r->n_right, NIL, |
| 178 |
r->n_right->n_type, r->n_right->n_df, |
| 179 |
r->n_right->n_ap); |
| 180 |
} |
| 181 |
if (r->n_op != STARG) { |
| 182 |
l = talloc(); |
| 183 |
*l = *r; |
| 184 |
r->n_op = FUNARG; |
| 185 |
r->n_left = l; |
| 186 |
r->n_type = l->n_type; |
| 187 |
} |
| 188 |
return p; |
| 189 |
} |
| 190 |
|
| 191 |
|
| 192 |
void |
| 193 |
fldty(struct symtab *p) |
| 194 |
{ |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
int |
| 201 |
mygenswitch(int num, TWORD type, struct swents **p, int n) |
| 202 |
{ |
| 203 |
return 0; |
| 204 |
} |
| 205 |
|
| 206 |
NODE * |
| 207 |
builtin_return_address(const struct bitable *bt, NODE *a) |
| 208 |
{ |
| 209 |
uerror("missing builtin_return_address"); |
| 210 |
return bcon(0); |
| 211 |
} |
| 212 |
|
| 213 |
NODE * |
| 214 |
builtin_frame_address(const struct bitable *bt, NODE *a) |
| 215 |
{ |
| 216 |
uerror("missing __builtin_frame_address"); |
| 217 |
return bcon(0); |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
NODE * |
| 224 |
builtin_cfa(const struct bitable *bt, NODE *a) |
| 225 |
{ |
| 226 |
uerror("missing builtin_cfa"); |
| 227 |
return bcon(0); |
| 228 |
} |
| 229 |
|