17bc9cdef7
Most warnings are for functions implicitly returning int. Change most
of these functions to return void. (Traditional K&R C had no void
type, but C89 has it.)
Add prototypes to most function declarations in headers. This is
easy, because ego declares most of its extern functions, and the
comments listed most parameters. There were a few outdated or missing
declarations, and a few .c files that failed to include an .h with the
declarations.
Add prototypes to a few function definitions in .c files. Most
functions still have traditional K&R definitions. Most STATIC
functions still don't have prototypes, because they have no earlier
declaration where I would have added the prototype.
Change some prototypes in util/ego/share/alloc.h. Functions newmap()
and oldmap() handle an array of pointers to something; change the
array's type from `short **` to `void **`. Callers use casts to go
between `void **` and the correct type, like `line_p *`. Function
oldtable() takes a `short *`, not a `short **`; I added the wrong type
in 5bbbaf4
.
Make a few other changes to silence warnings. There are a few places
where clang wants extra parentheses in the code.
Edit util/ego/ra/build.lua to add the missing dependency on ra*.h; I
needed this to prevent crashes from ra.
148 lines
3.2 KiB
C
148 lines
3.2 KiB
C
/* $Id$ */
|
|
/*
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
*/
|
|
/* I N L I N E S U B S T I T U T I O N
|
|
*
|
|
* I L 1 _ F O R M A L . C
|
|
*/
|
|
|
|
#include "../share/types.h"
|
|
#include "il.h"
|
|
#include "../share/debug.h"
|
|
#include "../share/alloc.h"
|
|
#include "../share/global.h"
|
|
#include "../share/lset.h"
|
|
#include "il1_aux.h"
|
|
#include "il1_formal.h"
|
|
|
|
#define NOT_USED(f) (!(f->f_flags & USEMASK))
|
|
#define USED_ONCE(f) f->f_flags |= FF_ONCEUSED
|
|
#define USED_OFTEN(f) f->f_flags |= FF_OFTENUSED
|
|
#define BADFORMAL(f) f->f_flags |= FF_BAD
|
|
|
|
#define OUTSIDE_LOOP(b) (Lnrelems(b->b_loops) == 0)
|
|
#define IS_FORMAL(x) (x >= 0)
|
|
|
|
|
|
|
|
formal_p find_formal(p,type,off)
|
|
proc_p p;
|
|
int type;
|
|
offset off;
|
|
{
|
|
/* Find a formal parameter of p
|
|
* If the formal overlaps with an existing formal
|
|
* or has an unknown type (i.e. its address is used)
|
|
* 0 is returned.
|
|
*/
|
|
|
|
formal_p f,prev,nf;
|
|
|
|
if (type == UNKNOWN) return (formal_p) 0;
|
|
prev = (formal_p) 0;
|
|
for (f = p->P_FORMALS; f != (formal_p) 0; f = f->f_next) {
|
|
if (f->f_offset >= off) break;
|
|
prev = f;
|
|
}
|
|
if (f != (formal_p) 0 && f->f_offset == off) {
|
|
return (same_size(f->f_type,type) ? f : (formal_p) 0);
|
|
}
|
|
if (f != (formal_p) 0 && par_overlap(off,type,f->f_offset,f->f_type)) {
|
|
return (formal_p) 0;
|
|
}
|
|
if (prev != (formal_p) 0 && par_overlap(prev->f_offset,prev->f_type,
|
|
off,type)) {
|
|
return (formal_p) 0;
|
|
}
|
|
nf = newformal();
|
|
nf->f_type = type;
|
|
nf->f_offset = off;
|
|
if (prev == (formal_p) 0) {
|
|
p->P_FORMALS = nf;
|
|
} else {
|
|
prev->f_next = nf;
|
|
}
|
|
nf->f_next = f;
|
|
return nf;
|
|
}
|
|
|
|
|
|
|
|
STATIC void no_inl_pars(p)
|
|
proc_p p;
|
|
{
|
|
/* p may not have any in line parameters */
|
|
|
|
p->p_flags2 |= PF_NO_INLPARS;
|
|
remov_formals(p);
|
|
}
|
|
|
|
|
|
|
|
STATIC void inc_use(f,b)
|
|
formal_p f;
|
|
bblock_p b;
|
|
{
|
|
/* Increment the use count of formal f.
|
|
* The counter has only three states: not used,
|
|
* used once, used more than once.
|
|
* We count the number of times the formal
|
|
* is used dynamically (rather than statically),
|
|
* so if it is used in a loop, the counter
|
|
* is always set to more than once.
|
|
*/
|
|
|
|
if (NOT_USED(f) && OUTSIDE_LOOP(b)) {
|
|
USED_ONCE(f);
|
|
} else {
|
|
USED_OFTEN(f);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void
|
|
formal(p,b,off,type,usage)
|
|
proc_p p;
|
|
bblock_p b;
|
|
offset off;
|
|
int type,
|
|
usage;
|
|
{
|
|
/* Analyze a reference to a parameter of p
|
|
* (occurring within basic block b).
|
|
* The parameter has offset off. If this
|
|
* offset is less than 0, it is not a
|
|
* parameter, but a local.
|
|
* The type can be SINGLE (1 word), DOUBLE
|
|
* (2 words), POINTER or UNKNOWN.
|
|
*/
|
|
|
|
formal_p f;
|
|
|
|
if (!IS_FORMAL(off) || !SUITABLE(p) || !INLINE_PARS(p)) return;
|
|
/* We are not interested in formal parameters of
|
|
* proccedures that will never be expanded in line,
|
|
* or whose parameters will not be expanded in line.
|
|
*/
|
|
f = find_formal(p,type,off);
|
|
/* Find the formal; if not found, create one;
|
|
* if inconsistent with previous formals (e.g.
|
|
* overlapping formals) then return 0;
|
|
* also fills in its type.
|
|
*/
|
|
if (f == (formal_p) 0) {
|
|
no_inl_pars(p);
|
|
/* parameters of p may not be expanded in line */
|
|
} else {
|
|
if (usage == CHANGE) {
|
|
/* don't expand f in line */
|
|
BADFORMAL(f);
|
|
} else {
|
|
inc_use(f,b); /* increment use count */
|
|
}
|
|
}
|
|
}
|