| 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 |
#include <stdarg.h> |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
static void printip(struct interpass *pole); |
| 41 |
|
| 42 |
struct ntds { |
| 43 |
int temp; |
| 44 |
TWORD type; |
| 45 |
union dimfun *df; |
| 46 |
struct attr *attr; |
| 47 |
}; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
static struct istat { |
| 53 |
SLIST_ENTRY(istat) link; |
| 54 |
struct symtab *sp; |
| 55 |
int flags; |
| 56 |
#define CANINL 1 |
| 57 |
#define WRITTEN 2 |
| 58 |
#define REFD 4 |
| 59 |
struct ntds *nt; |
| 60 |
int nargs; |
| 61 |
int retval; |
| 62 |
struct interpass shead; |
| 63 |
} *cifun; |
| 64 |
|
| 65 |
static SLIST_HEAD(, istat) ipole = { NULL, &ipole.q_forw }; |
| 66 |
static int nlabs, svclass; |
| 67 |
|
| 68 |
#define IP_REF (MAXIP+1) |
| 69 |
#ifdef PCC_DEBUG |
| 70 |
#define SDEBUG(x) if (sdebug) printf x |
| 71 |
#else |
| 72 |
#define SDEBUG(x) |
| 73 |
#endif |
| 74 |
|
| 75 |
int isinlining; |
| 76 |
int inlstatcnt; |
| 77 |
|
| 78 |
#define SZSI sizeof(struct istat) |
| 79 |
int istatsz = SZSI; |
| 80 |
#define ialloc() memset(permalloc(SZSI), 0, SZSI); inlstatcnt++ |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
static struct interpass_prolog * |
| 86 |
getprol(struct istat *is, int type) |
| 87 |
{ |
| 88 |
struct interpass *ip; |
| 89 |
|
| 90 |
DLIST_FOREACH(ip, &is->shead, qelem) |
| 91 |
if (ip->type == type) |
| 92 |
return (struct interpass_prolog *)ip; |
| 93 |
cerror("getprol: %d not found", type); |
| 94 |
return 0; |
| 95 |
} |
| 96 |
|
| 97 |
static struct istat * |
| 98 |
findfun(struct symtab *sp) |
| 99 |
{ |
| 100 |
struct istat *is; |
| 101 |
|
| 102 |
SLIST_FOREACH(is, &ipole, link) |
| 103 |
if (is->sp == sp) |
| 104 |
return is; |
| 105 |
return NULL; |
| 106 |
} |
| 107 |
|
| 108 |
static void |
| 109 |
refnode(struct symtab *sp) |
| 110 |
{ |
| 111 |
struct interpass *ip; |
| 112 |
|
| 113 |
SDEBUG(("refnode(%s)\n", sp->sname)); |
| 114 |
|
| 115 |
ip = permalloc(sizeof(*ip)); |
| 116 |
ip->type = IP_REF; |
| 117 |
ip->ip_name = (char *)sp; |
| 118 |
inline_addarg(ip); |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
static struct attr * |
| 125 |
inapcopy(struct attr *ap) |
| 126 |
{ |
| 127 |
struct attr *nap = attr_dup(ap); |
| 128 |
|
| 129 |
if (ap->next) |
| 130 |
nap->next = inapcopy(ap->next); |
| 131 |
return nap; |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
static NODE * |
| 138 |
intcopy(NODE *p) |
| 139 |
{ |
| 140 |
NODE *q = permalloc(sizeof(NODE)); |
| 141 |
int o = coptype(p->n_op); |
| 142 |
|
| 143 |
*q = *p; |
| 144 |
if (nlabs > 1 && (p->n_op == REG || p->n_op == OREG) && |
| 145 |
regno(p) == FPREG) |
| 146 |
SLIST_FIRST(&ipole)->flags &= ~CANINL; |
| 147 |
if (q->n_ap) |
| 148 |
q->n_ap = inapcopy(q->n_ap); |
| 149 |
if (q->n_op == NAME || q->n_op == ICON || |
| 150 |
q->n_op == XASM || q->n_op == XARG) { |
| 151 |
if (*q->n_name) |
| 152 |
q->n_name = xstrdup(q->n_name); |
| 153 |
else |
| 154 |
q->n_name = ""; |
| 155 |
} |
| 156 |
if (o == BITYPE) |
| 157 |
q->n_right = intcopy(q->n_right); |
| 158 |
if (o != LTYPE) |
| 159 |
q->n_left = intcopy(q->n_left); |
| 160 |
return q; |
| 161 |
} |
| 162 |
|
| 163 |
void |
| 164 |
inline_addarg(struct interpass *ip) |
| 165 |
{ |
| 166 |
struct interpass_prolog *ipp; |
| 167 |
NODE *q; |
| 168 |
static int g = 0; |
| 169 |
extern P1ND *cftnod; |
| 170 |
|
| 171 |
SDEBUG(("inline_addarg(%p)\n", ip)); |
| 172 |
DLIST_INSERT_BEFORE(&cifun->shead, ip, qelem); |
| 173 |
switch (ip->type) { |
| 174 |
case IP_ASM: |
| 175 |
ip->ip_asm = xstrdup(ip->ip_asm); |
| 176 |
break; |
| 177 |
case IP_DEFLAB: |
| 178 |
nlabs++; |
| 179 |
break; |
| 180 |
case IP_NODE: |
| 181 |
q = ip->ip_node; |
| 182 |
ip->ip_node = intcopy(ip->ip_node); |
| 183 |
tfree(q); |
| 184 |
break; |
| 185 |
case IP_EPILOG: |
| 186 |
ipp = (struct interpass_prolog *)ip; |
| 187 |
if (ipp->ip_labels[0]) |
| 188 |
uerror("no computed goto in inlined functions"); |
| 189 |
ipp->ip_labels = &g; |
| 190 |
break; |
| 191 |
} |
| 192 |
if (cftnod) |
| 193 |
cifun->retval = regno(cftnod); |
| 194 |
} |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
void |
| 200 |
inline_start(struct symtab *sp, int class) |
| 201 |
{ |
| 202 |
struct istat *is; |
| 203 |
|
| 204 |
SDEBUG(("inline_start(\"%s\")\n", sp->sname)); |
| 205 |
|
| 206 |
if (isinlining) |
| 207 |
cerror("already inlining function"); |
| 208 |
|
| 209 |
svclass = class; |
| 210 |
if ((is = findfun(sp)) != 0) { |
| 211 |
if (!DLIST_ISEMPTY(&is->shead, qelem)) |
| 212 |
uerror("inline function already defined"); |
| 213 |
} else { |
| 214 |
is = ialloc(); |
| 215 |
is->sp = sp; |
| 216 |
SLIST_INSERT_FIRST(&ipole, is, link); |
| 217 |
DLIST_INIT(&is->shead, qelem); |
| 218 |
} |
| 219 |
cifun = is; |
| 220 |
nlabs = 0; |
| 221 |
isinlining++; |
| 222 |
} |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
void |
| 247 |
inline_end(void) |
| 248 |
{ |
| 249 |
struct symtab *sp = cifun->sp; |
| 250 |
|
| 251 |
SDEBUG(("inline_end()\n")); |
| 252 |
|
| 253 |
if (sdebug)printip(&cifun->shead); |
| 254 |
isinlining = 0; |
| 255 |
|
| 256 |
if (xgnu89 && svclass == SNULL) |
| 257 |
sp->sclass = EXTERN; |
| 258 |
|
| 259 |
#ifdef GCC_COMPAT |
| 260 |
if (sp->sclass != STATIC && |
| 261 |
(attr_find(sp->sap, GCC_ATYP_GNU_INLINE) || xgnu89)) { |
| 262 |
if (sp->sclass == EXTDEF) |
| 263 |
sp->sclass = EXTERN; |
| 264 |
else |
| 265 |
sp->sclass = EXTDEF; |
| 266 |
} |
| 267 |
#endif |
| 268 |
|
| 269 |
if (sp->sclass == EXTDEF) { |
| 270 |
cifun->flags |= REFD; |
| 271 |
inline_prtout(); |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
void |
| 281 |
inline_ref(struct symtab *sp) |
| 282 |
{ |
| 283 |
struct istat *w; |
| 284 |
|
| 285 |
SDEBUG(("inline_ref(\"%s\")\n", sp->sname)); |
| 286 |
if (sp->sclass == SNULL) |
| 287 |
return; |
| 288 |
if (isinlining) { |
| 289 |
refnode(sp); |
| 290 |
} else { |
| 291 |
SLIST_FOREACH(w,&ipole, link) { |
| 292 |
if (w->sp != sp) |
| 293 |
continue; |
| 294 |
w->flags |= REFD; |
| 295 |
return; |
| 296 |
} |
| 297 |
|
| 298 |
w = ialloc(); |
| 299 |
w->sp = sp; |
| 300 |
w->flags |= REFD; |
| 301 |
SLIST_INSERT_FIRST(&ipole, w, link); |
| 302 |
DLIST_INIT(&w->shead, qelem); |
| 303 |
} |
| 304 |
} |
| 305 |
|
| 306 |
static void |
| 307 |
puto(struct istat *w) |
| 308 |
{ |
| 309 |
struct interpass_prolog *ipp, *epp, *pp; |
| 310 |
struct interpass *ip, *nip; |
| 311 |
extern int crslab; |
| 312 |
int lbloff = 0; |
| 313 |
|
| 314 |
|
| 315 |
ipp = 0; |
| 316 |
DLIST_FOREACH(ip, &w->shead, qelem) { |
| 317 |
switch (ip->type) { |
| 318 |
case IP_EPILOG: |
| 319 |
case IP_PROLOG: |
| 320 |
if (ip->type == IP_PROLOG) { |
| 321 |
ipp = (struct interpass_prolog *)ip; |
| 322 |
|
| 323 |
lbloff = crslab - ipp->ip_lblnum; |
| 324 |
} else { |
| 325 |
epp = (struct interpass_prolog *)ip; |
| 326 |
crslab += (epp->ip_lblnum - ipp->ip_lblnum); |
| 327 |
} |
| 328 |
pp = xmalloc(sizeof(struct interpass_prolog)); |
| 329 |
memcpy(pp, ip, sizeof(struct interpass_prolog)); |
| 330 |
pp->ip_lblnum += lbloff; |
| 331 |
#ifdef PCC_DEBUG |
| 332 |
if (ip->type == IP_EPILOG && crslab != pp->ip_lblnum) |
| 333 |
cerror("puto: %d != %d", crslab, pp->ip_lblnum); |
| 334 |
#endif |
| 335 |
pass2_compile((struct interpass *)pp); |
| 336 |
break; |
| 337 |
|
| 338 |
case IP_REF: |
| 339 |
inline_ref((struct symtab *)ip->ip_name); |
| 340 |
break; |
| 341 |
|
| 342 |
default: |
| 343 |
nip = xmalloc(sizeof(struct interpass)); |
| 344 |
*nip = *ip; |
| 345 |
if (nip->type == IP_NODE) { |
| 346 |
NODE *p; |
| 347 |
|
| 348 |
p = nip->ip_node = tcopy(nip->ip_node); |
| 349 |
if (p->n_op == GOTO) |
| 350 |
slval(p->n_left, |
| 351 |
glval(p->n_left) + lbloff); |
| 352 |
else if (p->n_op == CBRANCH) |
| 353 |
slval(p->n_right, |
| 354 |
glval(p->n_right) + lbloff); |
| 355 |
} else if (nip->type == IP_DEFLAB) |
| 356 |
nip->ip_lbl += lbloff; |
| 357 |
pass2_compile(nip); |
| 358 |
break; |
| 359 |
} |
| 360 |
} |
| 361 |
w->flags |= WRITTEN; |
| 362 |
} |
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
void |
| 368 |
inline_prtout(void) |
| 369 |
{ |
| 370 |
struct istat *w; |
| 371 |
int gotone = 0; |
| 372 |
|
| 373 |
SLIST_FOREACH(w, &ipole, link) { |
| 374 |
if ((w->flags & (REFD|WRITTEN)) == REFD && |
| 375 |
!DLIST_ISEMPTY(&w->shead, qelem)) { |
| 376 |
locctr(PROG, w->sp); |
| 377 |
defloc(w->sp); |
| 378 |
puto(w); |
| 379 |
w->flags |= WRITTEN; |
| 380 |
gotone++; |
| 381 |
} |
| 382 |
} |
| 383 |
if (gotone) |
| 384 |
inline_prtout(); |
| 385 |
} |
| 386 |
|
| 387 |
#if 1 |
| 388 |
static void |
| 389 |
printip(struct interpass *pole) |
| 390 |
{ |
| 391 |
static char *foo[] = { |
| 392 |
0, "NODE", "PROLOG", "STKOFF", "EPILOG", "DEFLAB", "DEFNAM", "ASM" }; |
| 393 |
struct interpass *ip; |
| 394 |
struct interpass_prolog *ipplg, *epplg; |
| 395 |
|
| 396 |
DLIST_FOREACH(ip, pole, qelem) { |
| 397 |
if (ip->type > MAXIP) |
| 398 |
printf("IP(%d) (%p): ", ip->type, ip); |
| 399 |
else |
| 400 |
printf("%s (%p): ", foo[ip->type], ip); |
| 401 |
switch (ip->type) { |
| 402 |
case IP_NODE: printf("\n"); |
| 403 |
#ifdef PCC_DEBUG |
| 404 |
#ifndef TWOPASS |
| 405 |
{ extern void e2print(NODE *p, int down, int *a, int *b); |
| 406 |
fwalk(ip->ip_node, e2print, 0); break; } |
| 407 |
#endif |
| 408 |
#endif |
| 409 |
case IP_PROLOG: |
| 410 |
ipplg = (struct interpass_prolog *)ip; |
| 411 |
printf("%s %s autos %d mintemp %d minlbl %d\n", |
| 412 |
ipplg->ipp_name, ipplg->ipp_vis ? "(local)" : "", |
| 413 |
ipplg->ipp_autos, |
| 414 |
ipplg->ip_tmpnum, ipplg->ip_lblnum); |
| 415 |
break; |
| 416 |
case IP_EPILOG: |
| 417 |
epplg = (struct interpass_prolog *)ip; |
| 418 |
printf("%s %s autos %d mintemp %d minlbl %d\n", |
| 419 |
epplg->ipp_name, epplg->ipp_vis ? "(local)" : "", |
| 420 |
epplg->ipp_autos, |
| 421 |
epplg->ip_tmpnum, epplg->ip_lblnum); |
| 422 |
break; |
| 423 |
case IP_DEFLAB: printf(LABFMT "\n", ip->ip_lbl); break; |
| 424 |
case IP_DEFNAM: printf("\n"); break; |
| 425 |
case IP_ASM: printf("%s", ip->ip_asm); break; |
| 426 |
default: |
| 427 |
break; |
| 428 |
} |
| 429 |
} |
| 430 |
} |
| 431 |
#endif |
| 432 |
|
| 433 |
static int toff; |
| 434 |
|
| 435 |
static P1ND * |
| 436 |
mnode(struct ntds *nt, P1ND *p) |
| 437 |
{ |
| 438 |
P1ND *q; |
| 439 |
int num = nt->temp + toff; |
| 440 |
|
| 441 |
if (p->n_op == CM) { |
| 442 |
q = p->n_right; |
| 443 |
q = tempnode(num, nt->type, nt->df, nt->attr); |
| 444 |
nt--; |
| 445 |
p->n_right = buildtree(ASSIGN, q, p->n_right); |
| 446 |
p->n_left = mnode(nt, p->n_left); |
| 447 |
p->n_op = COMOP; |
| 448 |
} else { |
| 449 |
p = pconvert(p); |
| 450 |
q = tempnode(num, nt->type, nt->df, nt->attr); |
| 451 |
p = buildtree(ASSIGN, q, p); |
| 452 |
} |
| 453 |
return p; |
| 454 |
} |
| 455 |
|
| 456 |
static void |
| 457 |
rtmps(NODE *p, void *arg) |
| 458 |
{ |
| 459 |
if (p->n_op == TEMP) |
| 460 |
regno(p) += toff; |
| 461 |
} |
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
P1ND * |
| 474 |
inlinetree(struct symtab *sp, P1ND *f, P1ND *ap) |
| 475 |
{ |
| 476 |
extern int crslab, tvaloff; |
| 477 |
struct istat *is = findfun(sp); |
| 478 |
struct interpass *ip, *ipf, *ipl; |
| 479 |
struct interpass_prolog *ipp, *ipe; |
| 480 |
int lmin, l0, l1, l2, gainl, n; |
| 481 |
NODE *pp; |
| 482 |
P1ND *p, *rp; |
| 483 |
|
| 484 |
if (is == NULL || nerrors) { |
| 485 |
inline_ref(sp); |
| 486 |
return NULL; |
| 487 |
} |
| 488 |
|
| 489 |
SDEBUG(("inlinetree(%p,%p) OK %d\n", f, ap, is->flags & CANINL)); |
| 490 |
|
| 491 |
#ifdef GCC_COMPAT |
| 492 |
gainl = attr_find(sp->sap, GCC_ATYP_ALW_INL) != NULL; |
| 493 |
#else |
| 494 |
gainl = 0; |
| 495 |
#endif |
| 496 |
|
| 497 |
n = nerrors; |
| 498 |
if ((is->flags & CANINL) == 0 && gainl) |
| 499 |
werror("cannot inline but always_inline"); |
| 500 |
nerrors = n; |
| 501 |
|
| 502 |
if ((is->flags & CANINL) == 0 || (xinline == 0 && gainl == 0)) { |
| 503 |
if (is->sp->sclass == STATIC || is->sp->sclass == USTATIC) |
| 504 |
inline_ref(sp); |
| 505 |
return NULL; |
| 506 |
} |
| 507 |
|
| 508 |
if (isinlining && cifun->sp == sp) { |
| 509 |
|
| 510 |
inline_ref(sp); |
| 511 |
return NULL; |
| 512 |
} |
| 513 |
|
| 514 |
#ifdef mach_i386 |
| 515 |
if (kflag) { |
| 516 |
is->flags |= REFD; |
| 517 |
return NULL; |
| 518 |
} |
| 519 |
#endif |
| 520 |
|
| 521 |
|
| 522 |
branch(l0 = getlab()); |
| 523 |
plabel(l1 = getlab()); |
| 524 |
l2 = getlab(); |
| 525 |
SDEBUG(("branch labels %d,%d,%d\n", l0, l1, l2)); |
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
ipp = getprol(is, IP_PROLOG); |
| 530 |
ipe = getprol(is, IP_EPILOG); |
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
SDEBUG(("pre-offsets crslab %d tvaloff %d\n", crslab, tvaloff)); |
| 535 |
lmin = crslab - ipp->ip_lblnum; |
| 536 |
crslab += (ipe->ip_lblnum - ipp->ip_lblnum) + 2; |
| 537 |
toff = tvaloff - ipp->ip_tmpnum; |
| 538 |
tvaloff += (ipe->ip_tmpnum - ipp->ip_tmpnum) + 1; |
| 539 |
SDEBUG(("offsets crslab %d lmin %d tvaloff %d toff %d\n", |
| 540 |
crslab, lmin, tvaloff, toff)); |
| 541 |
|
| 542 |
|
| 543 |
n = 0; |
| 544 |
DLIST_FOREACH(ipf, &is->shead, qelem) { |
| 545 |
if (ipf->type == IP_REF) |
| 546 |
inline_ref((struct symtab *)ipf->ip_name); |
| 547 |
if (ipf->type == IP_DEFLAB && n++ == 1) |
| 548 |
break; |
| 549 |
} |
| 550 |
|
| 551 |
|
| 552 |
DLIST_FOREACH_REVERSE(ipl, &is->shead, qelem) { |
| 553 |
if (ipl->type == IP_REF) |
| 554 |
inline_ref((struct symtab *)ipl->ip_name); |
| 555 |
if (ipl->type == IP_DEFLAB) |
| 556 |
break; |
| 557 |
} |
| 558 |
|
| 559 |
|
| 560 |
for (ip = ipf; ip != ipl; ip = DLIST_NEXT(ip, qelem)) { |
| 561 |
switch (ip->type) { |
| 562 |
case IP_NODE: |
| 563 |
pp = tcopy(ip->ip_node); |
| 564 |
if (pp->n_op == GOTO) |
| 565 |
slval(pp->n_left, glval(pp->n_left) + lmin); |
| 566 |
else if (pp->n_op == CBRANCH) |
| 567 |
slval(pp->n_right, glval(pp->n_right) + lmin); |
| 568 |
walkf(pp, rtmps, 0); |
| 569 |
#ifdef PCC_DEBUG |
| 570 |
#ifndef TWOPASS |
| 571 |
if (sdebug) { |
| 572 |
extern void e2print(NODE *p, int down, int *a, int *b); |
| 573 |
printf("converted node\n"); |
| 574 |
fwalk(ip->ip_node, e2print, 0); |
| 575 |
fwalk(pp, e2print, 0); |
| 576 |
} |
| 577 |
#endif |
| 578 |
#endif |
| 579 |
send_passt(IP_NODE, pp); |
| 580 |
break; |
| 581 |
|
| 582 |
case IP_DEFLAB: |
| 583 |
SDEBUG(("converted label %d to %d\n", |
| 584 |
ip->ip_lbl, ip->ip_lbl + lmin)); |
| 585 |
send_passt(IP_DEFLAB, ip->ip_lbl + lmin); |
| 586 |
break; |
| 587 |
|
| 588 |
case IP_ASM: |
| 589 |
send_passt(IP_ASM, ip->ip_asm); |
| 590 |
break; |
| 591 |
|
| 592 |
case IP_REF: |
| 593 |
inline_ref((struct symtab *)ip->ip_name); |
| 594 |
break; |
| 595 |
|
| 596 |
default: |
| 597 |
cerror("bad inline stmt %d", ip->type); |
| 598 |
} |
| 599 |
} |
| 600 |
SDEBUG(("last label %d to %d\n", ip->ip_lbl, ip->ip_lbl + lmin)); |
| 601 |
send_passt(IP_DEFLAB, ip->ip_lbl + lmin); |
| 602 |
|
| 603 |
branch(l2); |
| 604 |
plabel(l0); |
| 605 |
|
| 606 |
|
| 607 |
rp = block(GOTO, bcon(l1), NULL, INT, 0, 0); |
| 608 |
if (is->retval) |
| 609 |
p = tempnode(is->retval + toff, DECREF(sp->stype), |
| 610 |
sp->sdf, sp->sap); |
| 611 |
else |
| 612 |
p = xbcon(0, NULL, DECREF(sp->stype)); |
| 613 |
rp = buildtree(COMOP, rp, p); |
| 614 |
|
| 615 |
if (is->nargs) { |
| 616 |
p = mnode(&is->nt[is->nargs-1], ap); |
| 617 |
rp = buildtree(COMOP, p, rp); |
| 618 |
} |
| 619 |
|
| 620 |
p1tfree(f); |
| 621 |
return rp; |
| 622 |
} |
| 623 |
|
| 624 |
void |
| 625 |
inline_args(struct symtab **sp, int nargs) |
| 626 |
{ |
| 627 |
union arglist *al; |
| 628 |
struct istat *cf; |
| 629 |
TWORD t; |
| 630 |
int i; |
| 631 |
|
| 632 |
SDEBUG(("inline_args\n")); |
| 633 |
cf = cifun; |
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
if (cf->sp->sdf->dfun == NULL) |
| 641 |
return; |
| 642 |
for (al = cf->sp->sdf->dfun; al->type != TNULL; al++) { |
| 643 |
t = al->type; |
| 644 |
if (t == TELLIPSIS) |
| 645 |
return; |
| 646 |
if (ISSOU(BTYPE(t))) |
| 647 |
al++; |
| 648 |
for (; t > BTMASK; t = DECREF(t)) |
| 649 |
if (ISARY(t) || ISFTN(t)) |
| 650 |
al++; |
| 651 |
} |
| 652 |
|
| 653 |
if (nargs) { |
| 654 |
for (i = 0; i < nargs; i++) |
| 655 |
if ((sp[i]->sflags & STNODE) == 0) |
| 656 |
return; |
| 657 |
cf->nt = permalloc(sizeof(struct ntds)*nargs); |
| 658 |
for (i = 0; i < nargs; i++) { |
| 659 |
cf->nt[i].temp = sp[i]->soffset; |
| 660 |
cf->nt[i].type = sp[i]->stype; |
| 661 |
cf->nt[i].df = sp[i]->sdf; |
| 662 |
cf->nt[i].attr = sp[i]->sap; |
| 663 |
} |
| 664 |
} |
| 665 |
cf->nargs = nargs; |
| 666 |
cf->flags |= CANINL; |
| 667 |
} |