| 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 |
|
| 29 |
|
| 30 |
# include "pass1.h" |
| 31 |
|
| 32 |
#ifndef LANG_CXX |
| 33 |
#define NODE P1ND |
| 34 |
#undef NIL |
| 35 |
#define NIL NULL |
| 36 |
#define talloc p1alloc |
| 37 |
#endif |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
void |
| 43 |
setseg(int seg, char *name) |
| 44 |
{ |
| 45 |
switch (seg) { |
| 46 |
case PROG: name = ".text"; break; |
| 47 |
case STRNG: |
| 48 |
case RDATA: |
| 49 |
case DATA: |
| 50 |
case LDATA: name = ".data"; break; |
| 51 |
case UDATA: break; |
| 52 |
default: |
| 53 |
cerror("setseg"); |
| 54 |
} |
| 55 |
printf("\t%s\n", name); |
| 56 |
} |
| 57 |
|
| 58 |
void |
| 59 |
defalign(int al) |
| 60 |
{ |
| 61 |
if (al > ALCHAR) |
| 62 |
printf(".even\n"); |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
void |
| 70 |
defloc(struct symtab *sp) |
| 71 |
{ |
| 72 |
static char *loctbl[] = { "text", "data", "data" }; |
| 73 |
TWORD t; |
| 74 |
char *n; |
| 75 |
int s; |
| 76 |
|
| 77 |
t = sp->stype; |
| 78 |
s = ISFTN(t) ? PROG : ISCON(cqual(t, sp->squal)) ? RDATA : DATA; |
| 79 |
if (s != lastloc) |
| 80 |
printf(" .%s\n", loctbl[s]); |
| 81 |
lastloc = s; |
| 82 |
n = getexname(sp); |
| 83 |
if (sp->sclass == EXTDEF) |
| 84 |
printf(" .globl %s\n", n); |
| 85 |
if (sp->slevel == 0) { |
| 86 |
printf("%s:\n", n); |
| 87 |
printf("~~%s:\n", n+1); |
| 88 |
} else { |
| 89 |
printf(LABFMT ":\n", sp->soffset); |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
void |
| 99 |
efcode(void) |
| 100 |
{ |
| 101 |
struct symtab *sp; |
| 102 |
NODE *p, *q; |
| 103 |
|
| 104 |
if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN) |
| 105 |
return; |
| 106 |
|
| 107 |
|
| 108 |
sp = getsymtab("007", SSTMT); |
| 109 |
sp->stype = DECREF(cftnsp->stype); |
| 110 |
sp->sdf = cftnsp->sdf; |
| 111 |
sp->sap = cftnsp->sap; |
| 112 |
sp->sclass = STATIC; |
| 113 |
sp->soffset = getlab(); |
| 114 |
sp->slevel = 1; |
| 115 |
defzero(sp); |
| 116 |
|
| 117 |
|
| 118 |
q = nametree(sp); |
| 119 |
p = block(REG, NIL, NIL, PTR+STRTY, 0, cftnsp->sap); |
| 120 |
p = buildtree(UMUL, p, NIL); |
| 121 |
p = buildtree(ASSIGN, q, p); |
| 122 |
ecomp(p); |
| 123 |
|
| 124 |
|
| 125 |
q = buildtree(ADDROF, nametree(sp), NIL); |
| 126 |
p = block(REG, NIL, NIL, PTR+STRTY, 0, cftnsp->sap); |
| 127 |
p = buildtree(ASSIGN, p, q); |
| 128 |
ecomp(p); |
| 129 |
} |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
void |
| 136 |
bfcode(struct symtab **sp, int cnt) |
| 137 |
{ |
| 138 |
struct symtab *sp2; |
| 139 |
NODE *n; |
| 140 |
int i; |
| 141 |
|
| 142 |
if (xtemps == 0) |
| 143 |
return; |
| 144 |
|
| 145 |
|
| 146 |
for (i = 0; i < cnt; i++) { |
| 147 |
if (sp[i]->stype == STRTY || sp[i]->stype == UNIONTY || |
| 148 |
cisreg(sp[i]->stype) == 0) |
| 149 |
continue; |
| 150 |
sp2 = sp[i]; |
| 151 |
n = tempnode(0, sp[i]->stype, sp[i]->sdf, sp[i]->sap); |
| 152 |
n = buildtree(ASSIGN, n, nametree(sp2)); |
| 153 |
sp[i]->soffset = regno(n->n_left); |
| 154 |
sp[i]->sflags |= STNODE; |
| 155 |
ecomp(n); |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
void |
| 163 |
ejobcode(int flag) |
| 164 |
{ |
| 165 |
} |
| 166 |
|
| 167 |
void |
| 168 |
bjobcode(void) |
| 169 |
{ |
| 170 |
extern char *asspace; |
| 171 |
|
| 172 |
astypnames[INT] = astypnames[UNSIGNED] = ""; |
| 173 |
asspace = ".=.+"; |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
NODE * |
| 182 |
funcode(NODE *p) |
| 183 |
{ |
| 184 |
NODE *r, *l; |
| 185 |
|
| 186 |
|
| 187 |
for (r = p->n_right; r->n_op == CM; r = r->n_left) { |
| 188 |
if (r->n_right->n_op != STARG) |
| 189 |
r->n_right = block(FUNARG, r->n_right, NIL, |
| 190 |
r->n_right->n_type, r->n_right->n_df, |
| 191 |
r->n_right->n_ap); |
| 192 |
} |
| 193 |
if (r->n_op != STARG) { |
| 194 |
l = talloc(); |
| 195 |
*l = *r; |
| 196 |
r->n_op = FUNARG; |
| 197 |
r->n_left = l; |
| 198 |
r->n_type = l->n_type; |
| 199 |
} |
| 200 |
return p; |
| 201 |
} |
| 202 |
|
| 203 |
|
| 204 |
void |
| 205 |
fldty(struct symtab *p) |
| 206 |
{ |
| 207 |
} |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
int |
| 213 |
mygenswitch(int num, TWORD type, struct swents **p, int n) |
| 214 |
{ |
| 215 |
return 0; |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
NODE * |
| 222 |
builtin_cfa(const struct bitable *bt, NODE *a) |
| 223 |
{ |
| 224 |
uerror(__func__); |
| 225 |
return bcon(0); |
| 226 |
} |
| 227 |
|
| 228 |
NODE * |
| 229 |
builtin_return_address(const struct bitable *bt, NODE *a) |
| 230 |
{ |
| 231 |
uerror(__func__); |
| 232 |
return bcon(0); |
| 233 |
} |
| 234 |
|
| 235 |
NODE * |
| 236 |
builtin_frame_address(const struct bitable *bt, NODE *a) |
| 237 |
{ |
| 238 |
uerror(__func__); |
| 239 |
return bcon(0); |
| 240 |
} |