1 /* $Id: il1_cal.c,v 1.5 1994/06/24 10:25:30 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
6 /* I N L I N E S U B S T I T U T I O N
14 #include "../share/types.h"
17 #include "../share/debug.h"
18 #include "../share/alloc.h"
19 #include "../share/global.h"
20 #include "../share/lset.h"
22 #include "../share/parser.h"
24 STATIC actual_p acts, *app;
26 #define INIT_ACTS() {acts = (actual_p) 0; app = &acts;}
27 #define APPEND_ACTUAL(a) {*app = a; app = &a->ac_next;}
29 STATIC make_actual(l1,l2,size)
33 /* Allocate a struct for a new actual parameter
34 * expression, the code of which extends from
41 a->ac_exp = copy_code(l1,l2);
43 APPEND_ACTUAL(a); /* append it to actual-list */
48 STATIC bool chck_asp(p,l)
52 /* We require a call to a procedure p that has n formal
53 * parameters to be followed by an 'asp n' instruction
54 * (i.e. the caller should remove the actual parameters).
57 return (p->p_nrformals == 0 || (l != (line_p) 0 &&INSTR(l) == op_asp &&
58 TYPE(l) == OPSHORT && SHORT(l) == p->p_nrformals));
63 STATIC inc_count(caller,callee)
64 proc_p caller, callee;
66 /* Update the call-count information.
67 * Record the fact that there is one more call
68 * to 'callee', appearing in 'caller'.
73 if (!SUITABLE(caller)) return;
74 /* if the calling routine is never expanded in line
75 * we do not need call-count information.
77 for (cc = cchead; cc != (calcnt_p) 0; cc = cc->cc_next) {
78 if (cc->cc_proc == callee) {
80 /* #calls to callee from caller */
84 /* This is the first call from caller to callee.
85 * Allocate a new calcnt struct.
90 cc->cc_next = cchead; /* insert it at front of list */
102 /* Analyze a call instruction. If the called
103 * routine may be expanded in line, try to
104 * recognize the actual parameter expressions of
105 * the call and extend the call list.
117 if (SUITABLE(callee)) {
118 /* The called procedure may be expanded */
119 callee->P_NRCALLED++; /* #calls to callee from anywhere */
121 if (parse(PREV(call),callee->p_nrformals,&lnp,0,make_actual) &&
122 chck_asp(callee,call->l_next)) {
123 /* succeeded in recognizing the actuals */
128 c->cl_looplevel = (byte) looplevel(b);
129 if (c->cl_looplevel > 0 && IS_FIRM(b)) {
130 c->cl_flags |= CLF_FIRM;
132 c->cl_actuals = acts;
134 /* update call-count info */
135 putcall(c,cf,(short) 0); /* write the call to the calfile */