1 /* $Id: il1_aux.c,v 1.7 1994/06/24 10:25:24 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
12 #include "../share/types.h"
14 #include "../share/debug.h"
15 #include "../share/alloc.h"
16 #include "../share/global.h"
17 #include "../share/lset.h"
21 #define USE_INDIR(p) (p->p_use->u_flags & UF_INDIR)
23 #define IS_INSTR(c) (c >= sp_fmnem && c <= sp_lmnem)
29 /* See if the two types have the same size */
31 return tsize(t1) == tsize(t2);
36 STATIC bool is_reg(off,s)
40 /* See if there is a register message
41 * for the local or parameter at offset off
48 for (i = Lfirst(mesregs); i != (Lindex) 0; i = Lnext(i,mesregs)) {
49 arg = ((line_p) Lelem(i))->l_a.la_arg->a_next;
50 if (arg->a_a.a_offset == off &&
51 arg->a_next->a_a.a_offset == s) {
62 /* remove the actual-list */
66 for (a = acts; a != (actual_p) 0; a = next) {
68 /* REMOVE CODE OF a->ac_exp HERE */
78 /* Remove the list of formals of p */
82 for (f = p->P_FORMALS; f != (formal_p) 0; f = next) {
86 p->P_FORMALS = (formal_p) 0;
94 /* Formals that may be accessed indirectly
95 * cannot be expanded in line, so they are
96 * removed from the formals list.
99 formal_p prev, f, next;
101 if (!USE_INDIR(p) && !CHANGE_INDIR(p)) return;
102 /* Any formal for which we don't have
103 * a register message is now doomed.
106 for (f = p->P_FORMALS; f != (formal_p) 0; f = next) {
108 if (!is_reg(f->f_offset,tsize(f->f_type))) {
109 if (prev == (formal_p) 0) {
121 bool par_overlap(off1,t1,off2,t2)
125 /* See if the parameter at offset off1 and type t1
126 * overlaps the paramete at offset off2 and type t2.
130 return off2 + tsize(t2) > off1;
133 return off1 + tsize(t1) > off2;
145 /* determine the loop nesting level of basic block b;
146 * this is the highest nesting level of all blocks
148 * Note that the level of a loop is 0 for outer loops,
149 * so a block inside a loop with nesting level N has
156 for (i = Lfirst(b->b_loops); i != (Lindex)0; i = Lnext(i,b->b_loops)) {
157 if (((loop_p) Lelem(i))->lp_level >= max) {
158 max = ((loop_p) Lelem(i))->lp_level + 1;
169 /* count the number of EM instructions of p */
176 for (b = p->p_start; b != (bblock_p) 0; b = b->b_next) {
177 for (l = b->b_start; l != (line_p) 0; l = l->l_next) {
178 if (IS_INSTR(INSTR(l))) {
179 /* skip pseudo instructions */
191 line_p copy_code(l1,l2)
194 /* copy the code between l1 and l2 */
196 line_p head, tail, l, lnp;
199 for (lnp = l1; ; lnp = lnp->l_next) {
201 if (head == (line_p) 0) {
203 PREV(l) = (line_p) 0;
209 if (lnp == l2) break;