commit
0bcbaf848a
|
@ -97,8 +97,7 @@ int sz;
|
|||
#include <ctype.h>
|
||||
#include <flt_arith.h>
|
||||
|
||||
int float_cst(str, sz, buf) char *str, *buf;
|
||||
int sz;
|
||||
static int float_cst(const char *float_str, int sz, char *buf)
|
||||
{
|
||||
int overflow = 0;
|
||||
flt_arith e;
|
||||
|
@ -107,7 +106,7 @@ int sz;
|
|||
{
|
||||
return 1;
|
||||
}
|
||||
flt_str2flt(str, &e);
|
||||
flt_str2flt(float_str, &e);
|
||||
#ifdef IEEEFLOAT
|
||||
if (sz == 4)
|
||||
{
|
||||
|
@ -115,7 +114,7 @@ int sz;
|
|||
#ifdef PDPFLOAT
|
||||
e.flt_exp += 129;
|
||||
#else
|
||||
e.flt_exp += 127;
|
||||
e.flt_exp += 127;
|
||||
#endif
|
||||
if (e.flt_mantissa.flt_h_32 == 0)
|
||||
e.flt_exp = 0;
|
||||
|
|
|
@ -16,7 +16,7 @@ static char rcs_mh[]= ID_MH ;
|
|||
*/
|
||||
|
||||
void
|
||||
con_part(sz,w) register sz; word w; {
|
||||
con_part(int sz, word w) {
|
||||
|
||||
while (part_size % sz)
|
||||
part_size++;
|
||||
|
|
|
@ -14,7 +14,7 @@ static char rcs_mh[]= ID_MH ;
|
|||
*/
|
||||
|
||||
void
|
||||
con_part(sz,w) register sz; word w; {
|
||||
con_part(int sz, word w) {
|
||||
|
||||
while (part_size % sz)
|
||||
part_size++;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <stb.h>
|
||||
|
||||
void
|
||||
con_part(sz,w) register sz; word w; {
|
||||
con_part(int sz, word w) {
|
||||
|
||||
while (part_size % sz)
|
||||
part_size++;
|
||||
|
@ -88,7 +88,7 @@ regscore(off,size,typ,score,totyp)
|
|||
return score;
|
||||
}
|
||||
struct regsav_t {
|
||||
char *rs_reg; /* e.g. "a3" or "d5" */
|
||||
const char *rs_reg; /* e.g. "a3" or "d5" */
|
||||
long rs_off; /* offset of variable */
|
||||
int rs_size; /* 2 or 4 bytes */
|
||||
} regsav[9];
|
||||
|
|
|
@ -25,7 +25,7 @@ Something very wrong here!
|
|||
#define SYNTAX_68020 1
|
||||
#endif
|
||||
|
||||
/* #define FANCY_MODES 1
|
||||
/* #define FANCY_MODES 1 */
|
||||
/* On the M68020, there are some real fancy addressing modes.
|
||||
Their use makes the code a bit shorter, but also much slower.
|
||||
The FANCY_MODES #define enables the use of these addressing
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
MAXOP 5;
|
||||
LABEL_STARTER '.';
|
||||
|
||||
{
|
||||
int plus(const char *, const char *, char *);
|
||||
}
|
||||
|
||||
%%;
|
||||
|
||||
X, Y, Z { TRUE };
|
||||
|
@ -27,7 +31,7 @@ static int fits16(long l) {
|
|||
}
|
||||
|
||||
/* Tries sum = a + b with signed 16-bit integers. */
|
||||
int plus(const char *a, const char *b, const char *sum)
|
||||
int plus(const char *a, const char *b, char *sum)
|
||||
{
|
||||
long la, lb, lsum;
|
||||
char *end;
|
||||
|
|
|
@ -6,6 +6,13 @@ MAXOP 2;
|
|||
LABEL_STARTER 'I';
|
||||
OPC_TERMINATOR ' ';
|
||||
|
||||
{
|
||||
int no_side_effects(char *);
|
||||
int is_register(char *);
|
||||
int is_scratchreg(char *);
|
||||
int carry_dead(char *);
|
||||
}
|
||||
|
||||
%%;
|
||||
|
||||
/* useful addressing modes: */
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
#define newilb(x) fprintf(codefile,"%s:\n",x)
|
||||
#define newdlb(x) fprintf(codefile,"%s:\n",x)
|
||||
#define dlbdlb(x,y) fprintf(codefile,"%s = %s\n",x,y)
|
||||
#define newlbss(l,x) fprintf(codefile,".comm %s,%u\n",l,x);
|
||||
#define newlbss(l,x) fprintf(codefile,".comm %s,%ld\n",l,x);
|
||||
|
||||
#define cst_fmt "%d"
|
||||
#define off_fmt "%d"
|
||||
#define cst_fmt "%ld"
|
||||
#define off_fmt "%ld"
|
||||
#define ilb_fmt "I%x_%x"
|
||||
#define dlb_fmt "_%d"
|
||||
#define hol_fmt "hol%d"
|
||||
|
|
|
@ -4,6 +4,13 @@
|
|||
MAXOP 5;
|
||||
LABEL_STARTER '.';
|
||||
|
||||
{
|
||||
int not_using_sp(const char *);
|
||||
int positive(const char *);
|
||||
int lift(const char *);
|
||||
int plus(const char *, const char *, char *);
|
||||
}
|
||||
|
||||
%%;
|
||||
|
||||
L1, L2, L3, L4, L5 { not_using_sp(VAL) };
|
||||
|
@ -160,7 +167,7 @@ static int liftcmp(const void *a, const void *b) {
|
|||
int lift(const char *s) {
|
||||
return bsearch(&s, liftables,
|
||||
sizeof(liftables) / sizeof(liftables[0]),
|
||||
sizeof(liftables[0]), liftcmp);
|
||||
sizeof(liftables[0]), liftcmp) != NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,7 +177,7 @@ static int fits16(long l) {
|
|||
}
|
||||
|
||||
/* Tries sum = a + b with signed 16-bit integers. */
|
||||
int plus(const char *a, const char *b, const char *sum)
|
||||
int plus(const char *a, const char *b, char *sum)
|
||||
{
|
||||
long la, lb, lsum;
|
||||
char *end;
|
||||
|
|
|
@ -106,7 +106,7 @@ extern int curr_token;
|
|||
int yyparse(void);
|
||||
/* comm4.c */
|
||||
void stop(void);
|
||||
void newmodule(const char *);
|
||||
void newmodule(char *);
|
||||
/* comm5.c */
|
||||
int yylex(void);
|
||||
void putval(int);
|
||||
|
|
|
@ -35,6 +35,10 @@ void stop(void) {
|
|||
exit(nerrors != 0);
|
||||
}
|
||||
|
||||
static void stop_on_signal(int sig) {
|
||||
stop();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
@ -54,9 +58,9 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
progname = *argv++; argc--;
|
||||
for (p = sigs; i = *p++; )
|
||||
for (p = sigs; (i = *p++) != 0; )
|
||||
if (signal(i, SIG_IGN) != SIG_IGN)
|
||||
signal(i, stop);
|
||||
signal(i, stop_on_signal);
|
||||
for (i = 0; i < argc; i++) {
|
||||
p = argv[i];
|
||||
if (*p++ != '-')
|
||||
|
@ -433,7 +437,7 @@ pass_23(int n)
|
|||
}
|
||||
|
||||
void
|
||||
newmodule(const char *s)
|
||||
newmodule(char *s)
|
||||
{
|
||||
static char nmbuf[STRINGMAX];
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ definerule("build_ncg",
|
|||
"mach/proto/ncg/result.h",
|
||||
"mach/proto/ncg/state.h",
|
||||
"mach/proto/ncg/types.h",
|
||||
"mach/proto/ncg/xmach.h",
|
||||
"mach/"..e.arch.."/ncg/mach.c",
|
||||
"mach/"..e.arch.."/ncg/*.h",
|
||||
}
|
||||
|
|
|
@ -706,7 +706,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for
|
|||
do
|
||||
{
|
||||
npos = exactmatch = 0;
|
||||
for (rpp = reglist[propno]; rp = *rpp; rpp++)
|
||||
for (rpp = reglist[propno]; (rp = *rpp) != NULL; rpp++)
|
||||
if (getrefcount((int)(rp - machregs), FALSE) == 0)
|
||||
{
|
||||
pos[npos++] = rp - machregs;
|
||||
|
|
|
@ -23,6 +23,9 @@ static char rcsid2[] = "$Id$";
|
|||
#include "regvar.h"
|
||||
#include <em_reg.h>
|
||||
#endif
|
||||
#ifdef USE_TES
|
||||
#include "label.h"
|
||||
#endif
|
||||
#include "extern.h"
|
||||
|
||||
/*
|
||||
|
@ -80,10 +83,16 @@ static int regallowed=0;
|
|||
extern char em_flag[];
|
||||
extern short em_ptyp[];
|
||||
|
||||
/* machine dependent */
|
||||
/*
|
||||
* Declare the machine dependent functions.
|
||||
*
|
||||
* These functions now return void, which is not compatible with
|
||||
* traditional K&R C. Old mach.c files stop working until one fixes
|
||||
* them to return void, not int.
|
||||
*/
|
||||
void con_part(int, word);
|
||||
void con_mult(word);
|
||||
void con_float(void); /* actually returns void, but need K&R C compatibility */
|
||||
void con_float(void);
|
||||
void prolog(full nlocals);
|
||||
void mes(word);
|
||||
|
||||
|
@ -706,8 +715,8 @@ static void savelab(void) {
|
|||
}
|
||||
p = argstr;
|
||||
q = labstr;
|
||||
while (*q++ = *p++)
|
||||
;
|
||||
while ((*q++ = *p++) != '\0')
|
||||
continue;
|
||||
}
|
||||
|
||||
static void dumplab(void) {
|
||||
|
|
|
@ -13,7 +13,7 @@ static char rcsid[] = "$Id$";
|
|||
#include "result.h"
|
||||
#include "extern.h"
|
||||
#ifdef USE_TES
|
||||
#include "mach.h"
|
||||
#include "xmach.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -6,7 +6,7 @@ static char rcsid[] = "$Id$";
|
|||
#include "param.h"
|
||||
#include "tables.h"
|
||||
#include "types.h"
|
||||
#include "mach.h"
|
||||
#include "xmach.h"
|
||||
|
||||
/*
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
|
|
|
@ -67,7 +67,3 @@ void garbage_collect(void);
|
|||
void itokcost(void);
|
||||
void error(const char *s, ...);
|
||||
void fatal(const char *s, ...);
|
||||
|
||||
#ifdef MACH_OPTIONS
|
||||
void mach_option(char *); /* machine dependent */
|
||||
#endif
|
||||
|
|
15
mach/proto/ncg/xmach.h
Normal file
15
mach/proto/ncg/xmach.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include "mach.h", then if "mach.h" defines MACH_OPTIONS, also
|
||||
* declare mach_option(), a machine dependent function.
|
||||
*/
|
||||
|
||||
#include "mach.h"
|
||||
|
||||
#ifdef MACH_OPTIONS
|
||||
void mach_option(char *);
|
||||
#endif
|
|
@ -6,21 +6,18 @@
|
|||
#include "top.h"
|
||||
#include "queue.h"
|
||||
|
||||
empty_queue(q)
|
||||
register queue q;
|
||||
void empty_queue(queue q)
|
||||
{
|
||||
q->head = q->tail = (instr_p) 0;
|
||||
q->qlen = 0;
|
||||
}
|
||||
|
||||
int empty(q)
|
||||
queue q;
|
||||
int empty(queue q)
|
||||
{
|
||||
return q->qlen == 0;
|
||||
}
|
||||
|
||||
remove_head(q)
|
||||
register queue q;
|
||||
void remove_head(queue q)
|
||||
{
|
||||
if ( (q->head = q->head->fw) == (instr_p) 0) {
|
||||
q->tail = (instr_p) 0;
|
||||
|
@ -30,9 +27,7 @@ remove_head(q)
|
|||
q->qlen--;
|
||||
}
|
||||
|
||||
add(q,instr)
|
||||
register queue q;
|
||||
register instr_p instr;
|
||||
void add(queue q, instr_p instr)
|
||||
{
|
||||
if (q->qlen++ == 0) {
|
||||
q->head = q->tail = instr;
|
||||
|
@ -45,9 +40,7 @@ add(q,instr)
|
|||
instr->fw = (instr_p) 0;
|
||||
}
|
||||
|
||||
insert(q,instr)
|
||||
register queue q;
|
||||
register instr_p instr;
|
||||
void insert(queue q, instr_p instr)
|
||||
{
|
||||
if (q->qlen++ == 0) {
|
||||
q->head = q->tail = instr;
|
||||
|
@ -60,8 +53,7 @@ insert(q,instr)
|
|||
instr->bw = (instr_p) 0;
|
||||
}
|
||||
|
||||
join_queues(q1,q2)
|
||||
register queue q1,q2;
|
||||
void join_queues(queue q1, queue q2)
|
||||
{
|
||||
if (q1->qlen > 0) {
|
||||
q2->qlen += q1->qlen;
|
||||
|
|
|
@ -14,3 +14,10 @@ struct queue_t {
|
|||
#define qhead(q) (q)->head
|
||||
#define qlength(q) (q)->qlen
|
||||
#define next(x) (x)->fw
|
||||
|
||||
void empty_queue(queue);
|
||||
int empty(queue);
|
||||
void remove_head(queue);
|
||||
void add(queue, instr_p);
|
||||
void insert(queue, instr_p);
|
||||
void join_queues(queue, queue);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -13,18 +14,38 @@
|
|||
|
||||
/* STANDARD MACHINE-INDEPENT C CODE *************/
|
||||
|
||||
extern char *lstrip();
|
||||
extern instr_p newinstr();
|
||||
extern instr_p read_instr();
|
||||
extern instr_p gen_instr();
|
||||
static void optimize(void);
|
||||
static bool try_hashentry(int *, queue);
|
||||
static int hash(queue);
|
||||
static void fill_window(queue, int);
|
||||
static void write_first(queue);
|
||||
static void set_opcode(instr_p);
|
||||
static bool check_pattern(patdescr_p, queue);
|
||||
static bool check_operands(patdescr_p, queue);
|
||||
static void clear_vars(void);
|
||||
static bool opmatch(templ_p, const char *);
|
||||
static bool split_operands(instr_p);
|
||||
static void labeldef(instr_p);
|
||||
static bool operand(instr_p, int);
|
||||
static bool remainder_empty(instr_p);
|
||||
static char *lstrip(char *, const char *);
|
||||
static bool rstrip(char *, const char *);
|
||||
static bool unify(const char *, struct variable *);
|
||||
static void xform(patdescr_p, queue);
|
||||
static void replacement(patdescr_p, queue);
|
||||
static instr_p gen_instr(idescr_p);
|
||||
static instr_p read_instr(void);
|
||||
static instr_p newinstr(void);
|
||||
static void oldinstr(instr_p);
|
||||
static bool op_separator(instr_p);
|
||||
static bool well_shaped(const char *);
|
||||
static bool is_letter(char);
|
||||
|
||||
struct variable var[NRVARS+1];
|
||||
struct variable ANY; /* ANY symbol matching any instruction */
|
||||
static struct variable var[NRVARS+1];
|
||||
static struct variable ANY; /* ANY symbol matching any instruction */
|
||||
|
||||
char *REST; /* Opcode of first instruction not matched by current pattern */
|
||||
|
||||
void labeldef();
|
||||
void set_opcode();
|
||||
/* Opcode of first instruction not matched by current pattern */
|
||||
static char *REST;
|
||||
|
||||
#include "gen.c"
|
||||
|
||||
|
@ -36,7 +57,7 @@ void set_opcode();
|
|||
/* Skip white space in the unprocessed part of instruction 'ip' */
|
||||
#define skip_white(ip) while (is_white(*(ip)->rest_line)) (ip)->rest_line++
|
||||
|
||||
main()
|
||||
int main(void)
|
||||
{
|
||||
optimize();
|
||||
exit(0);
|
||||
|
@ -63,7 +84,7 @@ main()
|
|||
* is written to the output and is removed.
|
||||
*/
|
||||
|
||||
optimize()
|
||||
static void optimize(void)
|
||||
{
|
||||
struct queue_t windowq, backupq;
|
||||
queue window, backup;
|
||||
|
@ -93,11 +114,9 @@ optimize()
|
|||
|
||||
|
||||
|
||||
bool try_hashentry(list,window)
|
||||
int *list;
|
||||
queue window;
|
||||
static bool try_hashentry(int *list, queue window)
|
||||
{
|
||||
register int *pp;
|
||||
int *pp;
|
||||
patdescr_p p;
|
||||
|
||||
for (pp = list; *pp != -1; pp++) {
|
||||
|
@ -126,11 +145,10 @@ bool try_hashentry(list,window)
|
|||
*/
|
||||
|
||||
|
||||
int hash(w)
|
||||
queue w;
|
||||
static int hash(queue w)
|
||||
{
|
||||
register char *p;
|
||||
register sum,i;
|
||||
char *p;
|
||||
int sum,i;
|
||||
instr_p ip;
|
||||
|
||||
ip = qhead(w);
|
||||
|
@ -147,10 +165,9 @@ int hash(w)
|
|||
* When end-of-file is encountered it may contain fewer items.
|
||||
*/
|
||||
|
||||
fill_window(w,len)
|
||||
register queue w;
|
||||
static void fill_window(queue w, int len)
|
||||
{
|
||||
register instr_p ip;
|
||||
instr_p ip;
|
||||
|
||||
while(qlength(w) < len) {
|
||||
if ((ip = read_instr()) == NIL) break;
|
||||
|
@ -160,10 +177,9 @@ fill_window(w,len)
|
|||
}
|
||||
}
|
||||
|
||||
write_first(w)
|
||||
queue w;
|
||||
static void write_first(queue w)
|
||||
{
|
||||
register instr_p ip = qhead(w);
|
||||
instr_p ip = qhead(w);
|
||||
|
||||
fputs(ip->line, stdout);
|
||||
remove_head(w);
|
||||
|
@ -173,12 +189,9 @@ write_first(w)
|
|||
|
||||
/* Try to recognize the opcode part of an instruction */
|
||||
|
||||
void
|
||||
set_opcode(ip)
|
||||
register instr_p ip;
|
||||
static void set_opcode(instr_p ip)
|
||||
{
|
||||
register char *p,*q;
|
||||
char *qlim;
|
||||
char *p,*q,*qlim;
|
||||
|
||||
if (ip->state == JUNK) return;
|
||||
skip_white(ip);
|
||||
|
@ -206,13 +219,10 @@ set_opcode(ip)
|
|||
|
||||
/* Check if pattern 'p' matches the current input */
|
||||
|
||||
bool check_pattern(p,w)
|
||||
patdescr_p p;
|
||||
queue w;
|
||||
static bool check_pattern(patdescr_p p, queue w)
|
||||
{
|
||||
register idescr_p id_p;
|
||||
idescr_p idlim;
|
||||
register instr_p ip;
|
||||
idescr_p id_p, idlim;
|
||||
instr_p ip;
|
||||
|
||||
ip = qhead(w);
|
||||
ANY.vstate = UNINSTANTIATED;
|
||||
|
@ -232,12 +242,10 @@ bool check_pattern(p,w)
|
|||
|
||||
|
||||
|
||||
bool check_operands(p,w)
|
||||
patdescr_p p;
|
||||
queue w;
|
||||
static bool check_operands(patdescr_p p, queue w)
|
||||
{
|
||||
register instr_p ip;
|
||||
register idescr_p id_p;
|
||||
instr_p ip;
|
||||
idescr_p id_p;
|
||||
int n;
|
||||
|
||||
/* fprintf(stderr,"try pattern %d\n",p-patterns); */
|
||||
|
@ -263,9 +271,9 @@ bool check_operands(p,w)
|
|||
|
||||
/* Reset all variables to uninstantiated */
|
||||
|
||||
clear_vars()
|
||||
static void clear_vars(void)
|
||||
{
|
||||
register v;
|
||||
int v;
|
||||
|
||||
for (v = 1; v <= NRVARS; v++) var[v].vstate = UNINSTANTIATED;
|
||||
}
|
||||
|
@ -278,9 +286,7 @@ clear_vars()
|
|||
* mode-definitions part of the table.
|
||||
*/
|
||||
|
||||
bool opmatch(t,s)
|
||||
templ_p t;
|
||||
char *s;
|
||||
static bool opmatch(templ_p t, const char *s)
|
||||
{
|
||||
char *l, buf[MAXOPLEN+1];
|
||||
bool was_instantiated;
|
||||
|
@ -304,10 +310,9 @@ bool opmatch(t,s)
|
|||
|
||||
/* Try to recognize the operands of an instruction */
|
||||
|
||||
bool split_operands(ip)
|
||||
register instr_p ip;
|
||||
static bool split_operands(instr_p ip)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
bool res;
|
||||
|
||||
if (strcmp(ip->opc,"labdef") ==0) {
|
||||
|
@ -322,11 +327,9 @@ bool split_operands(ip)
|
|||
|
||||
|
||||
|
||||
void
|
||||
labeldef(ip)
|
||||
register instr_p ip;
|
||||
static void labeldef(instr_p ip)
|
||||
{
|
||||
register char *p;
|
||||
char *p;
|
||||
int oplen;
|
||||
|
||||
p = ip->rest_line;
|
||||
|
@ -344,10 +347,9 @@ labeldef(ip)
|
|||
|
||||
/* Try to recognize the next operand of instruction 'ip' */
|
||||
|
||||
bool operand(ip,n)
|
||||
register instr_p ip;
|
||||
static bool operand(instr_p ip, int n)
|
||||
{
|
||||
register char *p;
|
||||
char *p;
|
||||
int oplen;
|
||||
#ifdef PAREN_OPEN
|
||||
int nesting = 0;
|
||||
|
@ -381,8 +383,7 @@ bool operand(ip,n)
|
|||
* (or contains only white space).
|
||||
*/
|
||||
|
||||
bool remainder_empty(ip)
|
||||
instr_p ip;
|
||||
static bool remainder_empty(instr_p ip)
|
||||
{
|
||||
skip_white(ip);
|
||||
return *ip->rest_line == '\n';
|
||||
|
@ -393,8 +394,7 @@ bool remainder_empty(ip)
|
|||
* succeeds then return a pointer to the rest (unmatched part) of 'str'.
|
||||
*/
|
||||
|
||||
char *lstrip(str,ctxt)
|
||||
register char *str, *ctxt;
|
||||
static char *lstrip(char *str, const char *ctxt)
|
||||
{
|
||||
assert(ctxt != NULLSTRING);
|
||||
while (*str != '\0' && *str == *ctxt) {
|
||||
|
@ -410,10 +410,10 @@ char *lstrip(str,ctxt)
|
|||
* replace truncate 'str'.
|
||||
*/
|
||||
|
||||
bool rstrip(str,ctxt)
|
||||
char *str,*ctxt;
|
||||
static bool rstrip(char *str, const char *ctxt)
|
||||
{
|
||||
register char *s, *c;
|
||||
char *s;
|
||||
const char *c;
|
||||
|
||||
for (s = str; *s != '\0'; s++);
|
||||
for (c = ctxt; *c != '\0'; c++);
|
||||
|
@ -432,9 +432,7 @@ bool rstrip(str,ctxt)
|
|||
* variable becomes instantiated to the string.
|
||||
*/
|
||||
|
||||
bool unify(str,v)
|
||||
char *str;
|
||||
register struct variable *v;
|
||||
static bool unify(const char *str, struct variable *v)
|
||||
{
|
||||
if (v->vstate == UNINSTANTIATED) {
|
||||
v->vstate = INSTANTIATED;
|
||||
|
@ -449,11 +447,9 @@ bool unify(str,v)
|
|||
|
||||
/* Transform the working window according to pattern 'p' */
|
||||
|
||||
xform(p,w)
|
||||
patdescr_p p;
|
||||
queue w;
|
||||
static void xform(patdescr_p p, queue w)
|
||||
{
|
||||
register instr_p ip;
|
||||
instr_p ip;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < p->patlen; i++) {
|
||||
|
@ -471,11 +467,9 @@ xform(p,w)
|
|||
* Note that we generate instructions in reverser order.
|
||||
*/
|
||||
|
||||
replacement(p,w)
|
||||
register patdescr_p p;
|
||||
queue w;
|
||||
static void replacement(patdescr_p p, queue w)
|
||||
{
|
||||
register idescr_p id_p;
|
||||
idescr_p id_p;
|
||||
|
||||
for (id_p = &p->repl[p->replen-1]; id_p >= p->repl; id_p--) {
|
||||
insert(w,gen_instr(id_p));
|
||||
|
@ -490,13 +484,11 @@ replacement(p,w)
|
|||
* in exactly the same way as normal instructions that are just read in.
|
||||
*/
|
||||
|
||||
instr_p gen_instr(id_p)
|
||||
idescr_p id_p;
|
||||
static instr_p gen_instr(idescr_p id_p)
|
||||
{
|
||||
char *opc;
|
||||
char *opc, *s;
|
||||
instr_p ip;
|
||||
register templ_p t;
|
||||
register char *s;
|
||||
templ_p t;
|
||||
bool islabdef;
|
||||
int n;
|
||||
static char tmp[] = "x";
|
||||
|
@ -547,13 +539,12 @@ instr_p gen_instr(id_p)
|
|||
|
||||
static bool junk_state = FALSE; /* TRUE while processing a very long line */
|
||||
|
||||
instr_p read_instr()
|
||||
static instr_p read_instr(void)
|
||||
{
|
||||
instr_p ip;
|
||||
register int c;
|
||||
register char *p;
|
||||
register FILE *inp = stdin;
|
||||
char *plim;
|
||||
int c;
|
||||
char *p, *plim;
|
||||
FILE *inp = stdin;
|
||||
|
||||
ip = newinstr();
|
||||
plim = &ip->line[MAXLINELEN];
|
||||
|
@ -586,9 +577,9 @@ instr_p read_instr()
|
|||
static instr_p instr_pool;
|
||||
int nr_mallocs = 0; /* for statistics */
|
||||
|
||||
instr_p newinstr()
|
||||
static instr_p newinstr(void)
|
||||
{
|
||||
register instr_p ip;
|
||||
instr_p ip;
|
||||
int i;
|
||||
|
||||
if (instr_pool == NIL) {
|
||||
|
@ -607,8 +598,7 @@ instr_p newinstr()
|
|||
return ip;
|
||||
}
|
||||
|
||||
oldinstr(ip)
|
||||
instr_p ip;
|
||||
static void oldinstr(instr_p ip)
|
||||
{
|
||||
ip->fw = instr_pool;
|
||||
instr_pool = ip;
|
||||
|
@ -616,30 +606,9 @@ oldinstr(ip)
|
|||
|
||||
|
||||
|
||||
/* Debugging stuff */
|
||||
|
||||
badassertion(file,line)
|
||||
char *file;
|
||||
unsigned line;
|
||||
{
|
||||
fprintf(stderr,"assertion failed file %s, line %u\n",file,line);
|
||||
error("assertion");
|
||||
}
|
||||
|
||||
/* VARARGS1 */
|
||||
error(s,a)
|
||||
char *s,*a;
|
||||
{
|
||||
fprintf(stderr,s,a);
|
||||
fprintf(stderr,"\n");
|
||||
abort();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* Low level routines */
|
||||
|
||||
bool op_separator(ip)
|
||||
instr_p ip;
|
||||
static bool op_separator(instr_p ip)
|
||||
{
|
||||
skip_white(ip);
|
||||
if (*(ip->rest_line) == OP_SEPARATOR) {
|
||||
|
@ -652,14 +621,13 @@ bool op_separator(ip)
|
|||
|
||||
|
||||
|
||||
bool well_shaped(opc)
|
||||
char *opc;
|
||||
static bool well_shaped(const char *opc)
|
||||
{
|
||||
return is_letter(opc[0]);
|
||||
}
|
||||
|
||||
|
||||
bool is_letter(c)
|
||||
static bool is_letter(char c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
|
|
@ -89,5 +89,3 @@ typedef int bool;
|
|||
|
||||
#define NIL (instr_p) 0
|
||||
#define NULLSTRING (char *) 0
|
||||
|
||||
#define assert(x) if(!(x)) badassertion(__FILE__,__LINE__)
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
#define newilb(x) fprintf(codefile,"%s:\n",x)
|
||||
#define newdlb(x) fprintf(codefile,"%s:\n",x)
|
||||
#define dlbdlb(x,y) fprintf(codefile,"%s = %s\n",x,y)
|
||||
#define newlbss(l,x) fprintf(codefile,".comm %s,%u\n",l,x);
|
||||
#define newlbss(l,x) fprintf(codefile,".comm %s,%ld\n",l,x);
|
||||
|
||||
#define cst_fmt "%d"
|
||||
#define off_fmt "%d"
|
||||
#define cst_fmt "%ld"
|
||||
#define off_fmt "%ld"
|
||||
#define ilb_fmt "I%x_%x"
|
||||
#define dlb_fmt "_%d"
|
||||
#define hol_fmt "hol%d"
|
||||
|
|
|
@ -78,7 +78,7 @@ int flt_cmp(flt_arith *e1, flt_arith *e2);
|
|||
* digits. They may not both be missing. The decimal point, the e and the
|
||||
* exponent may be missing.
|
||||
*/
|
||||
void flt_str2flt(char *s, flt_arith *e);
|
||||
void flt_str2flt(const char *s, flt_arith *e);
|
||||
/** Converts the number indicated by `e` into a string, in a scientific
|
||||
* notation acceptable for EM. The result is stored in `buf`. At most
|
||||
* `bufsize` characters are stored. The maximum length needed is
|
||||
|
|
|
@ -216,7 +216,7 @@ static void add_exponent(register flt_arith *e, int exp)
|
|||
flt_status = status;
|
||||
}
|
||||
|
||||
void flt_str2flt(char *s, flt_arith *e)
|
||||
void flt_str2flt(const char *s, flt_arith *e)
|
||||
{
|
||||
register int c;
|
||||
int dotseen = 0;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
/* $Id$ */
|
||||
|
||||
#include <unistd.h>
|
||||
#include "system.h"
|
||||
|
||||
int
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
clibrary {
|
||||
name = "headers",
|
||||
hdrs = { "./src/*.h" }
|
||||
hdrs = { "./src/*.h" } -- rm alloc.h
|
||||
}
|
||||
|
||||
cprogram {
|
||||
name = "llgen",
|
||||
|
||||
-- These use pre-LLgen'd versions of LLgen.c, Lpars.c and tokens.c. If
|
||||
-- LLgen.g gets updated, they need rebuilding. Use the bootstrap script to
|
||||
-- do this.
|
||||
-- These use pre-LLgen'd versions of LLgen.c, Lpars.c, Lpars.h, and
|
||||
-- tokens.c. If LLgen.g or tokens.g gets updated, they need
|
||||
-- rebuilding. Use the bootstrap target to do this.
|
||||
|
||||
srcs = { "./src/*.c" },
|
||||
deps = { "+headers" },
|
||||
|
@ -20,6 +20,20 @@ cprogram {
|
|||
}
|
||||
}
|
||||
|
||||
-- This bootstrap target rebuilds LLgen's own parser with LLgen.
|
||||
-- It acts like ./bootstrap.sh but without installing LLgen in PATH.
|
||||
normalrule {
|
||||
name = "bootstrap",
|
||||
ins = "+llgen",
|
||||
outleaves = { "phony" },
|
||||
commands = {
|
||||
"cd %{abspath(cwd()..\"/src\")}",
|
||||
"%{abspath(ins)} -vvv -x tokens.g LLgen.g",
|
||||
"echo",
|
||||
"echo You should now be able to rebuild LLgen with the new parser.",
|
||||
}
|
||||
}
|
||||
|
||||
definerule("llgen",
|
||||
{
|
||||
srcs = { type="targets" },
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/* $Id$ */
|
||||
#ifdef LL_DEBUG
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define LL_assert(x) assert(x)
|
||||
#else
|
||||
#define LL_assert(x) /* nothing */
|
||||
|
|
|
@ -118,8 +118,8 @@ static struct nonterminal *nonterminals;
|
|||
/* These functions must be called instead of the original functions in
|
||||
* 'malloc.h'. They offer a checking allocation mechanism.
|
||||
*/
|
||||
static char *Malloc(unsigned);
|
||||
static char *Realloc(char*, unsigned);
|
||||
static void *Malloc(size_t);
|
||||
static void *Realloc(void *, size_t);
|
||||
|
||||
|
||||
|
||||
|
@ -164,11 +164,11 @@ void LLnc_recover(void);
|
|||
|
||||
|
||||
|
||||
static char *Malloc(unsigned size)
|
||||
static void *Malloc(size_t size)
|
||||
{
|
||||
char *p;
|
||||
void *p;
|
||||
|
||||
if ((p = malloc(size)) == (char *)0) {
|
||||
if ((p = malloc(size)) == NULL) {
|
||||
fprintf(stderr, "fatal error: out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -176,11 +176,11 @@ static char *Malloc(unsigned size)
|
|||
}
|
||||
|
||||
|
||||
static char *Realloc(char *ptr, unsigned size)
|
||||
static void *Realloc(void *ptr, size_t size)
|
||||
{
|
||||
char *p;
|
||||
void *p;
|
||||
|
||||
if ((p = realloc(ptr, size)) == (char *)0) {
|
||||
if ((p = realloc(ptr, size)) == NULL) {
|
||||
fprintf(stderr, "fatal error: out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -195,13 +195,13 @@ static void init_grammar(void)
|
|||
int i;
|
||||
|
||||
terminals = (struct terminal *)
|
||||
Malloc((unsigned) LLFIRST_NT * sizeof(struct terminal));
|
||||
Malloc(LLFIRST_NT * sizeof(struct terminal));
|
||||
for (i = 0; i < LLFIRST_NT; i++) {
|
||||
(terminals + i)->link = (struct symbol *)0;
|
||||
}
|
||||
|
||||
nonterminals = (struct nonterminal *)
|
||||
Malloc((unsigned)LLNNONTERMINALS * sizeof(struct nonterminal));
|
||||
Malloc(LLNNONTERMINALS * sizeof(struct nonterminal));
|
||||
for (i = 0; i < LLNNONTERMINALS; i++) {
|
||||
(nonterminals + i)->rule = (struct lhs *)0;
|
||||
(nonterminals + i)->link = (struct symbol *)0;
|
||||
|
@ -637,8 +637,7 @@ static void new_head(struct stacks *stack, struct stack_elt *ptr)
|
|||
/* buffer full? */
|
||||
stack->heads_buf_size += LLHEADS_BUF_INCR;
|
||||
stack->heads_buf = (struct stack_elt **)
|
||||
Realloc((char *)
|
||||
stack->heads_buf, (unsigned)
|
||||
Realloc(stack->heads_buf,
|
||||
stack->heads_buf_size *
|
||||
sizeof(struct stack_elt *)
|
||||
);
|
||||
|
@ -677,8 +676,8 @@ static void to_delete(struct stacks *stack, struct stack_elt *ptr)
|
|||
else if (stack->nr_cleanups == stack->cleanup_buf_size) {
|
||||
stack->cleanup_buf_size += LLCLEANUP_BUF_INCR;
|
||||
stack->cleanup_buf = (struct stack_elt **)
|
||||
Realloc((char *) stack->cleanup_buf,
|
||||
(unsigned) stack->cleanup_buf_size *
|
||||
Realloc(stack->cleanup_buf,
|
||||
stack->cleanup_buf_size *
|
||||
sizeof(struct stack_elt *));
|
||||
}
|
||||
*(stack->cleanup_buf + stack->nr_cleanups) = ptr;
|
||||
|
@ -790,8 +789,7 @@ static int join(struct stacks *stack, struct stack_elt *top, int l_ahead)
|
|||
|
||||
/* Allocate one more pointer to descendants */
|
||||
size = se->nr_nexts * sizeof(struct edge);
|
||||
se->edges = (struct edge *)Realloc((char *) se->edges,
|
||||
(unsigned) size);
|
||||
se->edges = (struct edge *)Realloc(se->edges, size);
|
||||
|
||||
/* Link it */
|
||||
(se->edges + se->nr_nexts - 1)->ptr = top->edges->ptr;
|
||||
|
@ -904,8 +902,8 @@ static void generate_heads(struct stacks *stack, struct stack_elt *se,
|
|||
else if (stack->nr_visited == stack->visited_buf_size) {
|
||||
stack->visited_buf_size += LL_VIS_INCR;
|
||||
stack->visited_buf = (struct stack_elt **)
|
||||
Realloc((char *) stack->visited_buf,
|
||||
(unsigned) stack->visited_buf_size *
|
||||
Realloc(stack->visited_buf,
|
||||
stack->visited_buf_size *
|
||||
sizeof(struct stack_elt *));
|
||||
}
|
||||
*(stack->visited_buf + stack->nr_visited) = next_se;
|
||||
|
@ -1089,7 +1087,7 @@ static struct stack_elt *split(struct stack_elt *se)
|
|||
#endif
|
||||
|
||||
new_stack->edges = (struct edge *)
|
||||
Malloc((unsigned)se->nr_nexts * sizeof(struct edge));
|
||||
Malloc(se->nr_nexts * sizeof(struct edge));
|
||||
|
||||
/* Copy gets the same successors as the original */
|
||||
memcpy((char *) new_stack->edges, (char *) se->edges,
|
||||
|
@ -1242,14 +1240,14 @@ static void match_heads(struct stacks *stack, int symb)
|
|||
if (stack->heads_buf_size == 0) {
|
||||
stack->heads_buf_size = LLHEADS_BUF_INCR;
|
||||
stack->heads_buf = (struct stack_elt **)
|
||||
Malloc((unsigned)stack->heads_buf_size *
|
||||
Malloc(stack->heads_buf_size *
|
||||
sizeof(struct stack_elt *));
|
||||
}
|
||||
else if (stack->nr_heads == stack->heads_buf_size) {
|
||||
stack->heads_buf_size += LLHEADS_BUF_INCR;
|
||||
stack->heads_buf = (struct stack_elt **)
|
||||
Realloc((char *) stack->heads_buf,
|
||||
(unsigned) stack->heads_buf_size *
|
||||
Realloc(stack->heads_buf,
|
||||
stack->heads_buf_size *
|
||||
sizeof(struct stack_elt *));
|
||||
}
|
||||
*(stack->heads_buf + stack->nr_heads) =
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
/* $Id$ */
|
||||
#ifdef LL_DEBUG
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#define LL_assert(x) assert(x)
|
||||
#else
|
||||
#define LL_assert(x) /* nothing */
|
||||
|
@ -251,7 +250,7 @@ LL_NOSCANDONE(C_IDENT);
|
|||
ff->ff_name = p;
|
||||
ff->ff_next = start;
|
||||
start = ff;
|
||||
while (ff = ff->ff_next) {
|
||||
while ((ff = ff->ff_next)) {
|
||||
if (! strcmp(p, ff->ff_name)) {
|
||||
error(linecount, "\"%s\" already used in a %%start", p);
|
||||
break;
|
||||
|
@ -474,7 +473,7 @@ LL6_simpleproduction(
|
|||
{ if (n_alts >= max_alts-2) {
|
||||
alt_table = (p_gram ) ralloc(
|
||||
(p_mem) alt_table,
|
||||
(unsigned)(max_alts+=ALTINCR)*sizeof(t_gram));
|
||||
(max_alts+=ALTINCR)*sizeof(t_gram));
|
||||
}
|
||||
if (t & DEF) {
|
||||
if (haddefault) {
|
||||
|
@ -687,7 +686,7 @@ LL_SAFE(C_ILLEGAL);
|
|||
if (n_rules >= max_rules-2) {
|
||||
rule_table = (p_gram) ralloc(
|
||||
(p_mem) rule_table,
|
||||
(unsigned)(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||
(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||
}
|
||||
elmcnt++;
|
||||
rule_table[n_rules++] =
|
||||
|
@ -730,7 +729,7 @@ LL7_elem(
|
|||
{ if (n_rules >= max_rules-2) {
|
||||
rule_table = (p_gram) ralloc(
|
||||
(p_mem) rule_table,
|
||||
(unsigned)(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||
(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||
}
|
||||
kind = FIXED;
|
||||
cnt = 0;
|
||||
|
@ -782,7 +781,7 @@ LLsdecr(4);
|
|||
if (n_rules >= max_rules-2) {
|
||||
rule_table = (p_gram) ralloc(
|
||||
(p_mem) rule_table,
|
||||
(unsigned)(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||
(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||
}
|
||||
}
|
||||
elem = *--(q->t_rule);
|
||||
|
@ -1314,7 +1313,7 @@ STATIC p_gram copyrule(register p_gram p,int length)
|
|||
register p_gram t;
|
||||
p_gram rule;
|
||||
|
||||
t = (p_gram) alloc((unsigned) length * sizeof(t_gram));
|
||||
t = (p_gram) alloc(length * sizeof(t_gram));
|
||||
rule = t;
|
||||
while (length--) {
|
||||
*t++ = *p++;
|
||||
|
|
|
@ -131,7 +131,7 @@ def { register string p; }
|
|||
ff->ff_name = p;
|
||||
ff->ff_next = start;
|
||||
start = ff;
|
||||
while (ff = ff->ff_next) {
|
||||
while ((ff = ff->ff_next)) {
|
||||
if (! strcmp(p, ff->ff_name)) {
|
||||
error(linecount, "\"%s\" already used in a %%start", p);
|
||||
break;
|
||||
|
@ -261,7 +261,7 @@ productions(p_gram *p;)
|
|||
{ if (n_alts >= max_alts-2) {
|
||||
alt_table = (p_gram ) ralloc(
|
||||
(p_mem) alt_table,
|
||||
(unsigned)(max_alts+=ALTINCR)*sizeof(t_gram));
|
||||
(max_alts+=ALTINCR)*sizeof(t_gram));
|
||||
}
|
||||
if (t & DEF) {
|
||||
if (haddefault) {
|
||||
|
@ -348,7 +348,7 @@ simpleproduction(p_gram *p; register int *conflres;)
|
|||
if (n_rules >= max_rules-2) {
|
||||
rule_table = (p_gram) ralloc(
|
||||
(p_mem) rule_table,
|
||||
(unsigned)(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||
(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||
}
|
||||
elmcnt++;
|
||||
rule_table[n_rules++] =
|
||||
|
@ -363,7 +363,7 @@ simpleproduction(p_gram *p; register int *conflres;)
|
|||
{ if (n_rules >= max_rules-2) {
|
||||
rule_table = (p_gram) ralloc(
|
||||
(p_mem) rule_table,
|
||||
(unsigned)(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||
(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||
}
|
||||
kind = FIXED;
|
||||
cnt = 0;
|
||||
|
@ -391,7 +391,7 @@ simpleproduction(p_gram *p; register int *conflres;)
|
|||
if (n_rules >= max_rules-2) {
|
||||
rule_table = (p_gram) ralloc(
|
||||
(p_mem) rule_table,
|
||||
(unsigned)(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||
(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||
}
|
||||
}
|
||||
elem = *--(q->t_rule);
|
||||
|
@ -653,7 +653,7 @@ STATIC p_gram copyrule(register p_gram p,int length)
|
|||
register p_gram t;
|
||||
p_gram rule;
|
||||
|
||||
t = (p_gram) alloc((unsigned) length * sizeof(t_gram));
|
||||
t = (p_gram) alloc(length * sizeof(t_gram));
|
||||
rule = t;
|
||||
while (length--) {
|
||||
*t++ = *p++;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
/* $Id$ */
|
||||
#ifdef LL_DEBUG
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#define LL_assert(x) assert(x)
|
||||
#else
|
||||
#define LL_assert(x) /* nothing */
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
# include "alloc.h"
|
||||
# include "types.h"
|
||||
# include "extern.h"
|
||||
|
||||
|
@ -27,7 +26,7 @@ static string rcsid = "$Id$";
|
|||
|
||||
static string e_nomem = "Out of memory";
|
||||
|
||||
p_mem alloc(unsigned int size)
|
||||
p_mem alloc(size_t size)
|
||||
{
|
||||
/*
|
||||
Allocate "size" bytes. Panic if it fails
|
||||
|
@ -38,7 +37,7 @@ p_mem alloc(unsigned int size)
|
|||
return p;
|
||||
}
|
||||
|
||||
p_mem ralloc(p_mem p,unsigned int size)
|
||||
p_mem ralloc(p_mem p,size_t size)
|
||||
{
|
||||
/*
|
||||
Re-allocate the chunk of memory indicated by "p", to
|
||||
|
@ -61,7 +60,7 @@ p_mem new_mem(register p_info p)
|
|||
be updated each time this routine is called
|
||||
*/
|
||||
p_mem rp;
|
||||
unsigned sz;
|
||||
size_t sz;
|
||||
|
||||
if (p->i_max >= p->i_top) { /* No more free elements */
|
||||
sz = p->i_size;
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/* Copyright (c) 2019 ACK Project.
|
||||
* See the copyright notice in the ACK home directory,
|
||||
* in the file "Copyright".
|
||||
*
|
||||
* Created on: 2019-02-16
|
||||
*
|
||||
*/
|
||||
#ifndef ALLOC_H_
|
||||
#define ALLOC_H_
|
||||
|
||||
#include "types.h"
|
||||
|
||||
p_mem alloc(unsigned int size);
|
||||
p_mem ralloc(p_mem p,unsigned int size);
|
||||
p_mem new_mem(register p_info p);
|
||||
|
||||
|
||||
|
||||
#endif /* ALLOC_H_ */
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include "alloc.h"
|
||||
# include "types.h"
|
||||
# include "extern.h"
|
||||
# include "sets.h"
|
||||
|
@ -198,7 +197,7 @@ void do_compute(void)
|
|||
for (f = files; f < maxfiles; f++)
|
||||
{
|
||||
register p_set s;
|
||||
f->f_used = s = (p_set) alloc((unsigned) n * sizeof(*(f->f_used)));
|
||||
f->f_used = s = (p_set) alloc(n * sizeof(*(f->f_used)));
|
||||
for (i = n; i; i--)
|
||||
*s++ = 0;
|
||||
for (i = f->f_nonterminals; i != -1; i = p->n_next)
|
||||
|
@ -497,9 +496,7 @@ STATIC int nc_first(p_set setp,register p_gram p,int flag)
|
|||
|
||||
q = g_getterm(p);
|
||||
if (flag == 0)
|
||||
{
|
||||
if (nc_first(q->t_nc_first,q->t_rule,0))/*nothing*/;
|
||||
}
|
||||
(void)nc_first(q->t_nc_first,q->t_rule,0);
|
||||
if (!noenter) s |= setunion(setp,q->t_nc_first);
|
||||
p++;
|
||||
if (r_getkind(q) == STAR ||
|
||||
|
@ -512,9 +509,7 @@ STATIC int nc_first(p_set setp,register p_gram p,int flag)
|
|||
|
||||
l = g_getlink(p);
|
||||
if (flag == 0)
|
||||
{
|
||||
if (nc_first(l->l_nc_symbs,l->l_rule,0))/*nothing*/;
|
||||
}
|
||||
(void)nc_first(l->l_nc_symbs,l->l_rule,0);
|
||||
if (noenter == 0)
|
||||
{
|
||||
s |= setunion(setp,l->l_nc_symbs);
|
||||
|
@ -528,14 +523,15 @@ STATIC int nc_first(p_set setp,register p_gram p,int flag)
|
|||
register p_start subp;
|
||||
|
||||
if (!noenter)
|
||||
if (subpars_sim)
|
||||
s |= setunion(setp, start_firsts);
|
||||
else
|
||||
{
|
||||
for (subp = g_getsubparse(p); subp;
|
||||
if (subpars_sim)
|
||||
s |= setunion(setp, start_firsts);
|
||||
else
|
||||
{
|
||||
for (subp = g_getsubparse(p); subp;
|
||||
subp = subp->ff_next)
|
||||
s |= setunion(setp, (&nonterms[subp->ff_nont])->n_nc_first);
|
||||
|
||||
s |= setunion(setp, (&nonterms[subp->ff_nont])->n_nc_first);
|
||||
}
|
||||
}
|
||||
p++;
|
||||
continue;
|
||||
|
@ -863,7 +859,7 @@ STATIC void do_lengthcomp(void)
|
|||
register p_nont p;
|
||||
p_mem alloc();
|
||||
|
||||
length = (p_length) alloc((unsigned) (nnonterms * sizeof(*length)));
|
||||
length = (p_length) alloc(nnonterms * sizeof(*length));
|
||||
for (pl = &length[nnonterms - 1]; pl >= length; pl--)
|
||||
{
|
||||
pl->val = pl->cnt = INFINITY;
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
* some variables that are visible in more than one file
|
||||
*/
|
||||
|
||||
# include "types.h"
|
||||
|
||||
# define LTEXTSZ 256 /* Size of longest token */
|
||||
|
||||
/*
|
||||
|
@ -94,22 +96,38 @@ extern p_gram illegal_gram;
|
|||
extern int strip_grammar;
|
||||
extern int in_production;
|
||||
|
||||
/* LLgen.g */
|
||||
void LLparse(void);
|
||||
|
||||
/* check.c */
|
||||
void conflchecks(void);
|
||||
|
||||
/* compute.c */
|
||||
void do_compute(void);
|
||||
int empty(p_gram);
|
||||
int t_safety(int, int, int, int);
|
||||
int t_after(int, int, int);
|
||||
|
||||
/* gencode.c */
|
||||
void gencode(int);
|
||||
|
||||
/* machdep.c */
|
||||
void TMPNAM(string);
|
||||
string libpath(string);
|
||||
|
||||
/* main.c */
|
||||
void error(int lineno,string s,string t);
|
||||
void warning(int lineno,string s,string t);
|
||||
void fatal(int lineno,string s,string t);
|
||||
|
||||
|
||||
int empty(register p_gram);
|
||||
int t_safety(int, int, int, int);
|
||||
int t_after(int, int, int);
|
||||
string store(string);
|
||||
void name_init(void);
|
||||
p_gram search(int, register string, int);
|
||||
void co_reach(void);
|
||||
void install(string, string);
|
||||
void copyfile(string);
|
||||
void install(string, string);
|
||||
|
||||
/* name.c */
|
||||
void name_init(void);
|
||||
string store(string);
|
||||
p_gram search(int, string, int);
|
||||
|
||||
|
||||
/* reach.c */
|
||||
void co_reach(void);
|
||||
|
||||
#endif /* EXTERN_H_ */
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
# include "alloc.h"
|
||||
# include "types.h"
|
||||
# include "io.h"
|
||||
# include "extern.h"
|
||||
|
@ -102,7 +101,7 @@ STATIC void doclose(FILE *f)
|
|||
STATIC int *mk_tokenlist(void)
|
||||
{
|
||||
register int i = ntokens;
|
||||
register int *p = (int *) alloc((unsigned) (i * sizeof(int))) + i;
|
||||
register int *p = (int *) alloc(i * sizeof(int)) + i;
|
||||
|
||||
while (i--)
|
||||
*--p = -1;
|
||||
|
@ -295,7 +294,7 @@ STATIC void genrecovery(void)
|
|||
for (psetl = setptr; psetl < maxptr; psetl++)
|
||||
prset(*psetl);
|
||||
fputs(c_arrend, f);
|
||||
index = (int *) alloc((unsigned) (assval * sizeof(int)));
|
||||
index = (int *) alloc(assval * sizeof(int));
|
||||
for (q = index; q < &index[assval];)
|
||||
*q++ = -1;
|
||||
for (t = tokens; t < maxt; t++)
|
||||
|
@ -344,7 +343,7 @@ STATIC void genncrecovery(void)
|
|||
fprintf(f, "#define LLFIRST_NT %d\n", assval);
|
||||
fprintf(f, "#define LLSETSIZE %d\n", nbytes);
|
||||
|
||||
index = (int *) alloc((unsigned) (assval * sizeof(int)));
|
||||
index = (int *) alloc(assval * sizeof(int));
|
||||
for (q = index; q < &index[assval];) *q++ = -1;
|
||||
for (t = tokens; t < maxt; t++)
|
||||
{
|
||||
|
@ -988,14 +987,14 @@ STATIC int *dopush(register p_gram p, int safety, int toplevel, int **pp)
|
|||
/*
|
||||
* The safety only matters if toplevel != 0
|
||||
*/
|
||||
unsigned int i = 100;
|
||||
size_t i = 100;
|
||||
register int *ip = (int *) alloc(100 * sizeof(int));
|
||||
|
||||
*pp = ip;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (ip - *pp >= i)
|
||||
if ((size_t)(ip - *pp) >= i)
|
||||
{
|
||||
*pp = (int *) ralloc((p_mem) (*pp), (i + 100) * sizeof(int));
|
||||
ip = *pp + i;
|
||||
|
|
|
@ -16,12 +16,8 @@
|
|||
* Machine dependant things
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#ifdef USE_SYS
|
||||
#include <system.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
# include "alloc.h"
|
||||
# include "extern.h"
|
||||
# include "types.h"
|
||||
|
||||
|
@ -33,29 +29,18 @@ static string rcsid5 = "$Id$";
|
|||
#define LIBDIR "lib"
|
||||
#endif
|
||||
|
||||
void UNLINK(string x)
|
||||
{
|
||||
/* Must remove the file "x" */
|
||||
#ifdef USE_SYS
|
||||
sys_remove(x); /* systemcall to remove file */
|
||||
#else
|
||||
remove(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
string libpath(string s)
|
||||
{
|
||||
/* Must deliver a full pathname to the library file "s" */
|
||||
register string p;
|
||||
register int length;
|
||||
register size_t length;
|
||||
|
||||
char* libdir = getenv("LLGEN_LIB_DIR");
|
||||
if (!libdir)
|
||||
libdir = LIBDIR;
|
||||
length = strlen(libdir) + strlen(s) + 2;
|
||||
p = (string) alloc((unsigned) length);
|
||||
p = (string) alloc(length);
|
||||
strcpy(p,libdir);
|
||||
strcat(p,"/");
|
||||
strcat(p,s);
|
||||
|
|
|
@ -33,14 +33,6 @@ STATIC void readgrammar(int, char *[]);
|
|||
STATIC void doparse(register p_file);
|
||||
STATIC void comfatal(void);
|
||||
|
||||
extern void UNLINK(string);
|
||||
extern void RENAME(string, string);
|
||||
extern void TMPNAM(string);
|
||||
extern string libpath(string);
|
||||
extern void conflchecks(void);
|
||||
extern void do_compute(void);
|
||||
extern void gencode(int);
|
||||
|
||||
int main(int argc, register string argv[])
|
||||
{
|
||||
register string arg;
|
||||
|
@ -210,8 +202,8 @@ int main(int argc, register string argv[])
|
|||
}
|
||||
else
|
||||
gencode(argc);
|
||||
UNLINK(f_temp);
|
||||
UNLINK(f_pars);
|
||||
remove(f_temp);
|
||||
remove(f_pars);
|
||||
if (verbose)
|
||||
{
|
||||
fprintf(stderr, "number of nonterminals: %d\n", nnonterms);
|
||||
|
@ -235,7 +227,7 @@ STATIC void readgrammar(int argc, char *argv[])
|
|||
/*
|
||||
* Build the file structure
|
||||
*/
|
||||
files = p = (p_file) alloc((unsigned) (argc + 1) * sizeof(t_file));
|
||||
files = p = (p_file) alloc((argc + 1) * sizeof(t_file));
|
||||
if (argc-- == 1)
|
||||
{
|
||||
finput = stdin;
|
||||
|
@ -328,11 +320,11 @@ STATIC void comfatal(void)
|
|||
if (fact != NULL)
|
||||
{
|
||||
fclose(fact);
|
||||
UNLINK(f_temp);
|
||||
remove(f_temp);
|
||||
}
|
||||
if (fpars != NULL)
|
||||
fclose(fpars);
|
||||
UNLINK(f_pars);
|
||||
remove(f_pars);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
# include "alloc.h"
|
||||
# include "types.h"
|
||||
# include "extern.h"
|
||||
# include "assert.h"
|
||||
|
|
|
@ -88,7 +88,7 @@ void save_grammar(FILE *f)
|
|||
/* Generate some constants in the grammar file */
|
||||
|
||||
/* Allocate terms list */
|
||||
t_list = (struct t_list *) alloc((unsigned) nterms * sizeof(struct t_list));
|
||||
t_list = (struct t_list *) alloc(nterms * sizeof(struct t_list));
|
||||
t_list_index = 0;
|
||||
|
||||
sub_list = (struct subparse_list *) alloc(nsubstarts * sizeof(struct subparse_list));
|
||||
|
|
|
@ -63,7 +63,7 @@ p_set get_set(void)
|
|||
static p_set sets, maxsets;
|
||||
|
||||
if ((p = sets) >= maxsets) {
|
||||
q = p = (p_set) alloc((unsigned) (50*setsize*sizeof(*sets)));
|
||||
q = p = (p_set) alloc(50*setsize*sizeof(*sets));
|
||||
maxsets = p + 50 * setsize;
|
||||
do {
|
||||
*q++ = 0;
|
||||
|
@ -81,7 +81,7 @@ p_set setalloc(void)
|
|||
register p_set p;
|
||||
register int size = setsize;
|
||||
|
||||
p = (p_set) alloc((unsigned) (size * sizeof(*p))) + size;
|
||||
p = (p_set) alloc(size * sizeof(*p)) + size;
|
||||
do {
|
||||
*--p = 0;
|
||||
} while (--size);
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
/* $Id$ */
|
||||
#ifdef LL_DEBUG
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#define LL_assert(x) assert(x)
|
||||
#else
|
||||
#define LL_assert(x) /* nothing */
|
||||
|
@ -368,7 +367,7 @@ int input(void)
|
|||
*/
|
||||
register int c;
|
||||
|
||||
if (c = backupc) {
|
||||
if ((c = backupc)) {
|
||||
/* Last char was "unput()". Deliver it again
|
||||
*/
|
||||
backupc = 0;
|
||||
|
|
|
@ -360,7 +360,7 @@ int input(void)
|
|||
*/
|
||||
register int c;
|
||||
|
||||
if (c = backupc) {
|
||||
if ((c = backupc)) {
|
||||
/* Last char was "unput()". Deliver it again
|
||||
*/
|
||||
backupc = 0;
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
* Type and structure definitions
|
||||
*/
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
typedef int *p_set; /* pointer to bitset */
|
||||
typedef char *p_mem; /* pointer to some core */
|
||||
typedef char *string;
|
||||
|
@ -259,14 +261,19 @@ typedef struct info_alloc {
|
|||
/*
|
||||
* Structure used for dynamically growing arrays
|
||||
*/
|
||||
unsigned i_size; /* Size of the array */
|
||||
unsigned i_esize; /* Size of an element */
|
||||
unsigned i_incr; /* When filled, add room for i_incr elements */
|
||||
size_t i_size; /* Size of the array */
|
||||
size_t i_esize; /* Size of an element */
|
||||
size_t i_incr; /* When filled, add room for i_incr elements */
|
||||
p_mem i_ptr; /* ptr to base of array */
|
||||
p_mem i_max; /* ptr to first free */
|
||||
p_mem i_top; /* ptr to top of array */
|
||||
} t_info, *p_info;
|
||||
|
||||
/* alloc.c */
|
||||
p_mem alloc(size_t);
|
||||
p_mem ralloc(p_mem, size_t);
|
||||
p_mem new_mem(p_info);
|
||||
|
||||
# ifdef NDEBUG
|
||||
# define STATIC static
|
||||
# else /* not NDEBUG */
|
||||
|
|
|
@ -64,6 +64,9 @@ typedef struct
|
|||
|
||||
/* Own routines */
|
||||
|
||||
/* files.h */
|
||||
extern void rmtemps(void);
|
||||
|
||||
/* rmach.c */
|
||||
extern void setlist(char*);
|
||||
|
||||
|
@ -80,6 +83,7 @@ extern void fatal(const char*, ...);
|
|||
extern void vprint(const char*, ...);
|
||||
extern void fuerror(const char*, ...);
|
||||
extern void werror(const char*, ...);
|
||||
extern void error(const char*, ...);
|
||||
extern void quit(int);
|
||||
extern char* keeps(const char*);
|
||||
#define throws(str) free(str)
|
||||
|
|
|
@ -169,7 +169,7 @@ static void varinit(void)
|
|||
register char* envstr;
|
||||
extern char* em_dir;
|
||||
|
||||
if (envstr = getenv("ACKDIR"))
|
||||
if ((envstr = getenv("ACKDIR")) != NULL)
|
||||
{
|
||||
em_dir = keeps(envstr);
|
||||
}
|
||||
|
|
|
@ -22,10 +22,12 @@ FILE *dmach ;
|
|||
|
||||
int offset ;
|
||||
|
||||
void readm();
|
||||
void start(const char *) ;
|
||||
void stop(int) ;
|
||||
void readm(void) ;
|
||||
|
||||
main(argc,argv) char **argv ; {
|
||||
register i ;
|
||||
int main(int argc, char **argv) {
|
||||
int i ;
|
||||
|
||||
start(argv[1]) ;
|
||||
for ( i=2 ; i<argc ; i++ ) {
|
||||
|
@ -36,7 +38,7 @@ main(argc,argv) char **argv ; {
|
|||
return 0 ;
|
||||
}
|
||||
|
||||
start(dir) char *dir ; {
|
||||
void start(const char *dir) {
|
||||
tail= dname ;
|
||||
while ( *dir ) {
|
||||
*tail++ = *dir ++ ;
|
||||
|
@ -53,14 +55,14 @@ start(dir) char *dir ; {
|
|||
fprintf(intab,"char intable[] = {\n") ;
|
||||
}
|
||||
|
||||
stop(filled) {
|
||||
void stop(int filled) {
|
||||
fprintf(dmach,"\t{\"\",\t-1\t}\n} ;\n") ;
|
||||
if ( !filled ) fprintf(intab,"\t0\n") ;
|
||||
fprintf(intab,"\n} ;\n") ;
|
||||
fclose(dmach); fclose(intab) ;
|
||||
}
|
||||
|
||||
FILE *do_open(file) char *file ; {
|
||||
FILE *do_open(const char *file) {
|
||||
FILE *fd;
|
||||
|
||||
strcpy(tail,file) ;
|
||||
|
@ -100,7 +102,7 @@ readm() {
|
|||
fprintf(stderr,"warning: non-ascii in %s\n",fname) ;
|
||||
fprintf(intab,"%4d,",token) ;
|
||||
} else {
|
||||
fprintf(intab," 0,",token) ;
|
||||
fprintf(intab," 0,") ;
|
||||
break ;
|
||||
}
|
||||
} else if ( isprint(token) ) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <sys/wait.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -113,12 +113,12 @@ static void try(list_elem *f_scan, const char *suffix) {
|
|||
*/
|
||||
register trf *sneak ;
|
||||
sneak= trafo ;
|
||||
while( sneak=sneak->t_next ) {
|
||||
while( (sneak=sneak->t_next) ) {
|
||||
sneak->t_scan=YES ;
|
||||
}
|
||||
scan_found() ;
|
||||
sneak= trafo ;
|
||||
while( sneak=sneak->t_next ) {
|
||||
while( (sneak=sneak->t_next) ) {
|
||||
sneak->t_scan=NO ;
|
||||
}
|
||||
return ;
|
||||
|
|
|
@ -317,7 +317,8 @@ static growstring scanvars(const char* line)
|
|||
{
|
||||
case A_VAR:
|
||||
gr_add(&name, 0);
|
||||
if (tr = getvar(gr_start(name)))
|
||||
tr = getvar(gr_start(name));
|
||||
if (tr != NULL)
|
||||
{
|
||||
while (*tr)
|
||||
{
|
||||
|
@ -333,7 +334,8 @@ static growstring scanvars(const char* line)
|
|||
break;
|
||||
case C_VAR:
|
||||
gr_add(&name, 0);
|
||||
if (tr = getvar(gr_start(name)))
|
||||
tr = getvar(gr_start(name));
|
||||
if (tr != NULL)
|
||||
{
|
||||
while (*tr)
|
||||
{
|
||||
|
|
|
@ -50,7 +50,6 @@ int setfiles(trf *);
|
|||
void disc_files(trf *);
|
||||
void disc_inputs(trf *);
|
||||
void rmfile(path *);
|
||||
void rmtemps(void);
|
||||
void add_input(path *, trf *);
|
||||
|
||||
/* run.c */
|
||||
|
|
|
@ -785,7 +785,7 @@ static void verbose(void)
|
|||
fprintf(stderr, "Sets %d(%d)\n", nmachsets, MAXSETS);
|
||||
fprintf(stderr, "Tokeninstances %d(%d)\n", narinstance, MAXINSTANCE);
|
||||
fprintf(stderr, "Strings %d(%d)\n", ncodestrings, MAXSTRINGS);
|
||||
fprintf(stderr, "Enodes %d(%d)\n", lastnode - nodes, MAXNODES);
|
||||
fprintf(stderr, "Enodes %d(%d)\n", (int)(lastnode - nodes), MAXNODES);
|
||||
fprintf(stderr, "Patbytes %d(%d)\n", npatbytes, MAXPATTERN);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,9 +62,7 @@ STATIC int Sbo; /* #optimizations found */
|
|||
|
||||
|
||||
|
||||
STATIC line_p last_code(lines,skip_pseu)
|
||||
line_p lines;
|
||||
bool skip_pseu;
|
||||
STATIC line_p last_code(line_p lines, bool skip_pseu)
|
||||
{
|
||||
/* Determine the last line of a list */
|
||||
|
||||
|
@ -82,12 +80,11 @@ STATIC short cc_tab[12] =
|
|||
op_zne,op_bne,op_zgt,op_bgt,op_zge,op_bge};
|
||||
|
||||
|
||||
STATIC short rev_cond(cond)
|
||||
short cond;
|
||||
STATIC short rev_cond(short cond)
|
||||
{
|
||||
register i;
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < 12; i++) {
|
||||
for (i = 0; i < 12; i++) {
|
||||
if (cond == cc_tab[i]) return cc_tab[11-i];
|
||||
}
|
||||
return op_nop;
|
||||
|
@ -100,7 +97,7 @@ STATIC bool is_bcc(l)
|
|||
}
|
||||
|
||||
|
||||
STATIC bo_optloop(p,b,x,bra,bcc)
|
||||
STATIC void bo_optloop(p,b,x,bra,bcc)
|
||||
proc_p p;
|
||||
bblock_p b,x;
|
||||
line_p bra,bcc;
|
||||
|
@ -180,7 +177,7 @@ OUTVERBOSE("branch optimization proc %d block %d\n", curproc->p_id,x->b_id);
|
|||
|
||||
|
||||
|
||||
STATIC bo_loops(p)
|
||||
STATIC void bo_loops(p)
|
||||
proc_p p;
|
||||
{
|
||||
Lindex i;
|
||||
|
@ -192,7 +189,7 @@ STATIC bo_loops(p)
|
|||
}
|
||||
}
|
||||
|
||||
STATIC mv_code(b1,b2)
|
||||
STATIC void mv_code(b1,b2)
|
||||
bblock_p b1,b2;
|
||||
{
|
||||
line_p l,x;
|
||||
|
@ -207,8 +204,7 @@ STATIC mv_code(b1,b2)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
bo_switch(b)
|
||||
STATIC void bo_switch(b)
|
||||
bblock_p b;
|
||||
{
|
||||
bblock_p s,x;
|
||||
|
@ -256,7 +252,7 @@ OUTVERBOSE("branch optimization in proc %d, block %d",curproc->p_id,b->b_id);
|
|||
}
|
||||
}
|
||||
|
||||
STATIC bo_extproc(p)
|
||||
STATIC void bo_extproc(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* Allocate the extended data structures for procedure p */
|
||||
|
@ -272,7 +268,7 @@ STATIC bo_extproc(p)
|
|||
}
|
||||
|
||||
|
||||
STATIC loop_blocks(p)
|
||||
STATIC void loop_blocks(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* Compute the LP_BLOCKS sets for all loops of p */
|
||||
|
@ -288,7 +284,7 @@ STATIC loop_blocks(p)
|
|||
}
|
||||
}
|
||||
|
||||
STATIC bo_cleanproc(p)
|
||||
STATIC void bo_cleanproc(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* Allocate the extended data structures for procedure p */
|
||||
|
@ -321,7 +317,7 @@ void bo_optimize(void *vp)
|
|||
|
||||
|
||||
|
||||
main(argc,argv)
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <em_mes.h>
|
||||
#include "../share/types.h"
|
||||
#include "ca.h"
|
||||
#include "ca_put.h"
|
||||
#include "../share/debug.h"
|
||||
#include "../share/def.h"
|
||||
#include "../share/map.h"
|
||||
|
@ -22,18 +23,18 @@ FILE *outfile;
|
|||
|
||||
STATIC proc_p thispro;
|
||||
|
||||
STATIC outinst(m) {
|
||||
STATIC void outinst(int m) {
|
||||
|
||||
outbyte( (byte) m );
|
||||
}
|
||||
|
||||
STATIC coutshort(i) short i; {
|
||||
STATIC void coutshort(short i) {
|
||||
|
||||
outbyte( (byte) (i&BMASK) );
|
||||
outbyte( (byte) (i>>8) );
|
||||
}
|
||||
|
||||
STATIC coutint(i) short i; {
|
||||
STATIC void coutint(short i) {
|
||||
|
||||
if (i>= -sp_zcst0 && i< sp_ncst0-sp_zcst0)
|
||||
outbyte( (byte) (i+sp_zcst0+sp_fcst0) );
|
||||
|
@ -43,7 +44,7 @@ STATIC coutint(i) short i; {
|
|||
}
|
||||
}
|
||||
|
||||
STATIC coutoff(off) offset off; {
|
||||
STATIC void coutoff(offset off) {
|
||||
|
||||
if ((short) off == off)
|
||||
coutint((short) off);
|
||||
|
@ -55,9 +56,7 @@ STATIC coutoff(off) offset off; {
|
|||
}
|
||||
|
||||
|
||||
STATIC outsym(s,t)
|
||||
char *s;
|
||||
int t;
|
||||
STATIC void outsym(const char *s, int t)
|
||||
{
|
||||
register byte *p;
|
||||
register unsigned num;
|
||||
|
@ -85,21 +84,19 @@ STATIC outsym(s,t)
|
|||
}
|
||||
|
||||
|
||||
STATIC outdsym(dbl)
|
||||
dblock_p dbl;
|
||||
STATIC void outdsym(dblock_p dbl)
|
||||
{
|
||||
if (dnames[dbl->d_id]) outsym(dnames[dbl->d_id],sp_dnam);
|
||||
}
|
||||
|
||||
|
||||
STATIC outpsym(p)
|
||||
proc_p p;
|
||||
STATIC void outpsym(proc_p p)
|
||||
{
|
||||
outsym(pnames[p->p_id],sp_pnam);
|
||||
}
|
||||
|
||||
|
||||
STATIC outddef(id) short id; {
|
||||
STATIC void outddef(short id) {
|
||||
|
||||
dblock_p dbl;
|
||||
|
||||
|
@ -111,7 +108,7 @@ STATIC outddef(id) short id; {
|
|||
}
|
||||
}
|
||||
|
||||
STATIC outpdef(p) proc_p p; {
|
||||
STATIC void outpdef(proc_p p) {
|
||||
p->p_flags2 |= PF_SYMOUT;
|
||||
if (p->p_flags1 & PF_EXTERNAL) {
|
||||
outinst(ps_exp);
|
||||
|
@ -120,7 +117,7 @@ STATIC outpdef(p) proc_p p; {
|
|||
}
|
||||
|
||||
|
||||
STATIC outdocc(obj) obj_p obj; {
|
||||
STATIC void outdocc(obj_p obj) {
|
||||
dblock_p dbl;
|
||||
|
||||
dbl = obj->o_dblock;
|
||||
|
@ -135,7 +132,7 @@ STATIC outdocc(obj) obj_p obj; {
|
|||
}
|
||||
|
||||
|
||||
STATIC outpocc(p) proc_p p; {
|
||||
STATIC void outpocc(proc_p p) {
|
||||
if ((p->p_flags2 & PF_SYMOUT) == 0) {
|
||||
p->p_flags2 |= PF_SYMOUT;
|
||||
if ((p->p_flags1 & PF_EXTERNAL) == 0) {
|
||||
|
@ -146,8 +143,7 @@ STATIC outpocc(p) proc_p p; {
|
|||
}
|
||||
|
||||
|
||||
STATIC coutobject(obj)
|
||||
obj_p obj;
|
||||
STATIC void coutobject(obj_p obj)
|
||||
{
|
||||
/* In general, an object is defined by a global data
|
||||
* label and an offset. There are two special cases:
|
||||
|
@ -169,7 +165,7 @@ STATIC coutobject(obj)
|
|||
}
|
||||
|
||||
|
||||
STATIC cputstr(abp) register argb_p abp; {
|
||||
STATIC void cputstr(argb_p abp) {
|
||||
register argb_p tbp;
|
||||
register length;
|
||||
|
||||
|
@ -188,8 +184,7 @@ STATIC cputstr(abp) register argb_p abp; {
|
|||
}
|
||||
|
||||
|
||||
STATIC outnum(n)
|
||||
int n;
|
||||
STATIC void outnum(int n)
|
||||
{
|
||||
if (n < 256) {
|
||||
outbyte((byte) sp_ilb1);
|
||||
|
@ -201,8 +196,7 @@ STATIC outnum(n)
|
|||
}
|
||||
|
||||
|
||||
STATIC numlab(n)
|
||||
int n;
|
||||
STATIC void numlab(int n)
|
||||
{
|
||||
if (n < sp_nilb0) {
|
||||
outbyte((byte) (n + sp_filb0));
|
||||
|
@ -212,8 +206,7 @@ STATIC numlab(n)
|
|||
}
|
||||
|
||||
|
||||
STATIC cputargs(lnp)
|
||||
line_p lnp;
|
||||
STATIC void cputargs(line_p lnp)
|
||||
{
|
||||
register arg_p ap;
|
||||
int cnt = 0;
|
||||
|
@ -264,8 +257,7 @@ STATIC cputargs(lnp)
|
|||
|
||||
|
||||
|
||||
STATIC outoperand(lnp)
|
||||
line_p lnp;
|
||||
STATIC void outoperand(line_p lnp)
|
||||
{
|
||||
/* Output the operand of instruction lnp */
|
||||
|
||||
|
@ -320,8 +312,7 @@ STATIC outoperand(lnp)
|
|||
}
|
||||
|
||||
|
||||
STATIC outvisibility(lnp)
|
||||
line_p lnp;
|
||||
STATIC void outvisibility(line_p lnp)
|
||||
{
|
||||
/* In EM names of datalabels and procedures can be made
|
||||
* externally visible, so they can be used in other files.
|
||||
|
@ -377,9 +368,7 @@ STATIC outvisibility(lnp)
|
|||
}
|
||||
|
||||
|
||||
cputlines(l,lf)
|
||||
line_p l;
|
||||
FILE *lf;
|
||||
void cputlines(line_p l, FILE *lf)
|
||||
{
|
||||
/* Output the lines in Campact assembly language
|
||||
* format.
|
||||
|
@ -405,13 +394,12 @@ cputlines(l,lf)
|
|||
oldline(lnp);
|
||||
}
|
||||
if (lmap != (line_p *) 0) {
|
||||
oldmap(lmap,llength);
|
||||
oldmap((void **) lmap,llength);
|
||||
lmap = (line_p *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
cputmagic(lf)
|
||||
FILE *lf;
|
||||
void cputmagic(FILE *lf)
|
||||
{
|
||||
/* write the magic number */
|
||||
|
||||
|
|
|
@ -10,5 +10,5 @@
|
|||
*/
|
||||
|
||||
|
||||
extern cputlines();
|
||||
extern cputmagic();
|
||||
void cputlines(line_p, FILE *);
|
||||
void cputmagic(FILE *);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "../share/get.h"
|
||||
#include "../share/put.h"
|
||||
#include "../share/def.h"
|
||||
#include "../share/utils.h"
|
||||
#include "cf.h"
|
||||
#include "cf_succ.h"
|
||||
#include "cf_idom.h"
|
||||
|
@ -75,7 +76,7 @@ STATIC short state; /* We use a finite state machine with the
|
|||
* INIT: initial state
|
||||
*/
|
||||
|
||||
STATIC nextblock()
|
||||
STATIC void nextblock()
|
||||
{
|
||||
/* allocate a new basic block structure and
|
||||
* set b, bp and lp.
|
||||
|
@ -138,12 +139,9 @@ STATIC line_p doread_line(p_out)
|
|||
return lnp;
|
||||
}
|
||||
|
||||
STATIC bool getbblocks(fp, kind_out, n_out, g_out, l_out)
|
||||
FILE* fp;
|
||||
short* kind_out;
|
||||
short* n_out;
|
||||
bblock_p* g_out;
|
||||
line_p* l_out;
|
||||
STATIC bool
|
||||
getbblocks(FILE *fp, short *kind_out, short *n_out, bblock_p *g_out,
|
||||
line_p *l_out)
|
||||
{
|
||||
bblock_p head = (bblock_p)0;
|
||||
line_p headl = (line_p)0;
|
||||
|
@ -252,7 +250,7 @@ line_p* l_out;
|
|||
}
|
||||
}
|
||||
|
||||
STATIC interproc_analysis(p)
|
||||
STATIC void interproc_analysis(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* Interprocedural analysis of a procedure p determines:
|
||||
|
@ -362,7 +360,7 @@ STATIC interproc_analysis(p)
|
|||
}
|
||||
}
|
||||
|
||||
STATIC cf_cleanproc(p)
|
||||
STATIC void cf_cleanproc(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* Remove the extended data structures of p */
|
||||
|
@ -477,7 +475,7 @@ STATIC bool add_info(q, p)
|
|||
return diff;
|
||||
}
|
||||
|
||||
STATIC trans_clos(head)
|
||||
STATIC void trans_clos(head)
|
||||
proc_p head;
|
||||
{
|
||||
/* Compute the transitive closure of the used/changed
|
||||
|
@ -508,7 +506,7 @@ STATIC trans_clos(head)
|
|||
}
|
||||
}
|
||||
|
||||
indir_calls()
|
||||
STATIC void indir_calls()
|
||||
{
|
||||
Cindex i;
|
||||
proc_p p;
|
||||
|
@ -522,7 +520,7 @@ indir_calls()
|
|||
Cdeleteset(cai_set);
|
||||
}
|
||||
|
||||
main(argc, argv) int argc;
|
||||
int main(argc, argv) int argc;
|
||||
char* argv[];
|
||||
{
|
||||
FILE* f, *f2, *gf2; /* The EM input, EM output, basic block output */
|
||||
|
|
|
@ -34,7 +34,7 @@ short dfs_nr;
|
|||
bblock_p *vertex; /* dynamically allocated array */
|
||||
|
||||
|
||||
STATIC dfs(v)
|
||||
STATIC void dfs(v)
|
||||
bblock_p v;
|
||||
{
|
||||
/* Depth First Search */
|
||||
|
@ -56,7 +56,7 @@ STATIC dfs(v)
|
|||
|
||||
|
||||
|
||||
STATIC compress(v)
|
||||
STATIC void compress(v)
|
||||
bblock_p v;
|
||||
{
|
||||
if (v->B_ANCESTOR->B_ANCESTOR != (bblock_p) 0) {
|
||||
|
@ -83,7 +83,7 @@ STATIC bblock_p eval(v)
|
|||
|
||||
|
||||
|
||||
STATIC linkblocks(v,w)
|
||||
STATIC void linkblocks(v,w)
|
||||
bblock_p v,w;
|
||||
{
|
||||
w->B_ANCESTOR = v;
|
||||
|
@ -91,9 +91,7 @@ STATIC linkblocks(v,w)
|
|||
|
||||
|
||||
|
||||
dominators(r,n)
|
||||
bblock_p r;
|
||||
short n;
|
||||
void dominators(bblock_p r, short n)
|
||||
{
|
||||
/* Compute the immediate dominator of every basic
|
||||
* block in the control flow graph rooted by r.
|
||||
|
@ -139,5 +137,6 @@ dominators(r,n)
|
|||
}
|
||||
}
|
||||
r->b_idom = (bblock_p) 0;
|
||||
oldmap(vertex,n); /* release memory for dynamic array vertex */
|
||||
/* release memory for dynamic array vertex */
|
||||
oldmap((void **) vertex,n);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
*/
|
||||
|
||||
|
||||
extern dominator(); /* (bblock_p head, short n)
|
||||
void dominators(bblock_p head, short n);
|
||||
/*
|
||||
* Compute for every basic block its immediate
|
||||
* dominator. The dominator relation is hence
|
||||
* recorded as a tree in which every node contains
|
||||
|
|
|
@ -83,7 +83,7 @@ STATIC bool inner_loop(l1,l2)
|
|||
|
||||
|
||||
|
||||
STATIC insrt(b,lpb,s_p)
|
||||
STATIC void insrt(b,lpb,s_p)
|
||||
bblock_p b;
|
||||
lset *lpb;
|
||||
lset *s_p;
|
||||
|
@ -162,7 +162,7 @@ STATIC loop_p org_loop(lp,loops)
|
|||
|
||||
|
||||
|
||||
STATIC collapse_loops(loops_p)
|
||||
STATIC void collapse_loops(loops_p)
|
||||
lset *loops_p;
|
||||
{
|
||||
register Lindex li1, li2;
|
||||
|
@ -187,7 +187,7 @@ STATIC collapse_loops(loops_p)
|
|||
}
|
||||
|
||||
|
||||
STATIC loop_per_block(lp)
|
||||
STATIC void loop_per_block(lp)
|
||||
loop_p lp;
|
||||
{
|
||||
bblock_p b;
|
||||
|
@ -205,7 +205,7 @@ STATIC loop_per_block(lp)
|
|||
|
||||
|
||||
|
||||
STATIC loop_attrib(loops)
|
||||
STATIC void loop_attrib(loops)
|
||||
lset loops;
|
||||
{
|
||||
/* Compute several attributes */
|
||||
|
@ -223,7 +223,7 @@ STATIC loop_attrib(loops)
|
|||
|
||||
|
||||
|
||||
STATIC nest_levels(loops)
|
||||
STATIC void nest_levels(loops)
|
||||
lset loops;
|
||||
{
|
||||
/* Compute the nesting levels of all loops of
|
||||
|
@ -250,7 +250,7 @@ STATIC nest_levels(loops)
|
|||
}
|
||||
|
||||
|
||||
STATIC cleanup(loops)
|
||||
STATIC void cleanup(loops)
|
||||
lset loops;
|
||||
{
|
||||
/* Throw away the LP_BLOCKS sets */
|
||||
|
@ -280,7 +280,7 @@ STATIC bool does_exit(b,lp)
|
|||
}
|
||||
|
||||
|
||||
STATIC mark_succ(b,lp)
|
||||
STATIC void mark_succ(b,lp)
|
||||
bblock_p b;
|
||||
loop_p lp;
|
||||
{
|
||||
|
@ -339,7 +339,7 @@ STATIC void mark_blocks(lp)
|
|||
|
||||
|
||||
|
||||
STATIC mark_loopblocks(loops)
|
||||
STATIC void mark_loopblocks(loops)
|
||||
lset loops;
|
||||
{
|
||||
/* Determine for all loops which basic blocks
|
||||
|
@ -360,7 +360,7 @@ STATIC mark_loopblocks(loops)
|
|||
|
||||
|
||||
|
||||
loop_detection(p)
|
||||
void loop_detection(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* Find all natural loops of procedure p. Every loop is
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* L O O P D E T E C T I O N
|
||||
*/
|
||||
|
||||
extern loop_detection(); /* (proc_p p)
|
||||
void loop_detection(proc_p p); /*
|
||||
* Detect all loops of procedure p.
|
||||
* Every basic block of p is assigned
|
||||
* a set of all loops it is part of.
|
||||
|
|
|
@ -21,12 +21,13 @@
|
|||
#include "../share/lset.h"
|
||||
#include "../share/cset.h"
|
||||
#include "cf.h"
|
||||
#include "cf_succ.h"
|
||||
#include "../share/map.h"
|
||||
|
||||
extern char em_flag[];
|
||||
|
||||
|
||||
STATIC succeeds(succ,pred)
|
||||
STATIC void succeeds(succ,pred)
|
||||
bblock_p succ, pred;
|
||||
{
|
||||
assert(pred != (bblock_p) 0);
|
||||
|
@ -75,7 +76,7 @@ STATIC arg_p use_label(arg,b)
|
|||
|
||||
|
||||
|
||||
STATIC case_flow(instr,desc,b)
|
||||
STATIC void case_flow(instr,desc,b)
|
||||
short instr;
|
||||
line_p desc;
|
||||
bblock_p b;
|
||||
|
@ -176,7 +177,7 @@ STATIC line_p case_descr(lnp)
|
|||
|
||||
|
||||
|
||||
STATIC last2_instrs(b,last_out,prev_out)
|
||||
STATIC void last2_instrs(b,last_out,prev_out)
|
||||
bblock_p b;
|
||||
line_p *last_out,*prev_out;
|
||||
{
|
||||
|
@ -205,7 +206,7 @@ STATIC last2_instrs(b,last_out,prev_out)
|
|||
|
||||
|
||||
|
||||
control_flow(head)
|
||||
void control_flow(head)
|
||||
bblock_p head;
|
||||
{
|
||||
/* compute the successor and predecessor relation
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
* S U C C E S S O R / P R E D E C E S S O R R E L A T I O N S
|
||||
*/
|
||||
|
||||
extern control_flow(); /* (bblock_p head)
|
||||
void control_flow(bblock_p head);
|
||||
/*
|
||||
* Compute for every basic block
|
||||
* its successors and predecessors
|
||||
* in the control flow graph.
|
||||
|
|
|
@ -134,7 +134,7 @@ STATIC bool is_desirable(text)
|
|||
}
|
||||
|
||||
|
||||
STATIC cp_loops(b1,b2)
|
||||
STATIC void cp_loops(b1,b2)
|
||||
bblock_p b1,b2;
|
||||
{
|
||||
/* Copy the loopset of b2 to b1 */
|
||||
|
@ -149,7 +149,7 @@ STATIC cp_loops(b1,b2)
|
|||
}
|
||||
|
||||
|
||||
STATIC jump_cross(l1,l2,b1,b2)
|
||||
STATIC void jump_cross(l1,l2,b1,b2)
|
||||
line_p l1,l2;
|
||||
bblock_p b1,b2;
|
||||
{
|
||||
|
@ -317,7 +317,7 @@ void cj_optimize(void *vp)
|
|||
}
|
||||
|
||||
|
||||
main(argc,argv)
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
|
|
|
@ -56,11 +56,11 @@ STATIC bool same_avail(byte kind, avail_p avp1, avail_p avp2)
|
|||
case BINAIR_OP:
|
||||
case REMAINDER:
|
||||
if (commutative(avp1->av_instr & BMASK))
|
||||
return avp1->av_oleft == avp2->av_oleft &&
|
||||
avp1->av_oright == avp2->av_oright
|
||||
return (avp1->av_oleft == avp2->av_oleft &&
|
||||
avp1->av_oright == avp2->av_oright)
|
||||
||
|
||||
avp1->av_oleft == avp2->av_oright &&
|
||||
avp1->av_oright == avp2->av_oleft
|
||||
(avp1->av_oleft == avp2->av_oright &&
|
||||
avp1->av_oright == avp2->av_oleft)
|
||||
;
|
||||
else
|
||||
return avp1->av_oleft == avp2->av_oleft &&
|
||||
|
@ -98,7 +98,8 @@ STATIC entity_p result_local(offset size, line_p l)
|
|||
if (l == (line_p) 0)
|
||||
return (entity_p) 0;
|
||||
|
||||
if (INSTR(l)==op_stl && size==ws || INSTR(l)==op_sdl && size==2*ws) {
|
||||
if ((INSTR(l)==op_stl && size==ws) ||
|
||||
(INSTR(l)==op_sdl && size==2*ws)) {
|
||||
enp = getentity(l, &dummy);
|
||||
if (is_regvar(enp->en_loc)) {
|
||||
OUTTRACE("save local found, %ld(LB)", enp->en_loc);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
optimizer itself one day ...
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -121,14 +122,15 @@ cleanup()
|
|||
}
|
||||
|
||||
/*VARARGS1*/
|
||||
static void
|
||||
fatal(s, s2) char* s;
|
||||
char* s2;
|
||||
static void fatal(const char *s, ...)
|
||||
{
|
||||
/* A fatal error occurred; exit gracefully */
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, s);
|
||||
|
||||
fprint(STDERR, "%s: ", prog_name);
|
||||
fprint(STDERR, s, s2);
|
||||
doprnt(STDERR, s, ap);
|
||||
fprint(STDERR, "\n");
|
||||
cleanup();
|
||||
sys_stop(S_EXIT);
|
||||
|
|
|
@ -52,12 +52,12 @@ lab_id lastlid = 0;
|
|||
offset mespar = UNKNOWN_SIZE;
|
||||
/* argumument of ps_par message of current procedure */
|
||||
|
||||
extern process_lines();
|
||||
extern int readline();
|
||||
extern line_p readoperand();
|
||||
extern line_p inpseudo();
|
||||
STATIC void process_lines(FILE *);
|
||||
STATIC int readline(short *, line_p *);
|
||||
STATIC line_p readoperand(short);
|
||||
STATIC line_p inpseudo(short);
|
||||
|
||||
main(argc, argv) int argc;
|
||||
int main(argc, argv) int argc;
|
||||
char* argv[];
|
||||
{
|
||||
/* The input files must be legal EM Compact
|
||||
|
@ -133,7 +133,7 @@ char* argv[];
|
|||
#define END_INSTR 4
|
||||
#define DELETED_INSTR 5
|
||||
|
||||
STATIC add_end()
|
||||
STATIC void add_end()
|
||||
{
|
||||
/* Add an end-pseudo to the current instruction list */
|
||||
|
||||
|
@ -142,7 +142,7 @@ STATIC add_end()
|
|||
lastline->l_instr = ps_end;
|
||||
}
|
||||
|
||||
process_lines(fout)
|
||||
STATIC void process_lines(fout)
|
||||
FILE* fout;
|
||||
{
|
||||
line_p lnp;
|
||||
|
@ -235,8 +235,7 @@ process_lines(fout)
|
|||
}
|
||||
}
|
||||
|
||||
int readline(instr_out, lnp_out) short* instr_out;
|
||||
line_p* lnp_out;
|
||||
STATIC int readline(short *instr_out, line_p *lnp_out)
|
||||
{
|
||||
register line_p lnp;
|
||||
short n;
|
||||
|
@ -310,7 +309,7 @@ line_p* lnp_out;
|
|||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
line_p readoperand(instr) short instr;
|
||||
STATIC line_p readoperand(short instr)
|
||||
{
|
||||
/* Read the operand of the given instruction.
|
||||
* Create a line struct and return a pointer to it.
|
||||
|
@ -432,7 +431,7 @@ static char* hol_label()
|
|||
return lastname;
|
||||
}
|
||||
|
||||
line_p inpseudo(n) short n;
|
||||
STATIC line_p inpseudo(short n)
|
||||
{
|
||||
int m;
|
||||
line_p lnp;
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
|
||||
/* opr_size */
|
||||
|
||||
offset opr_size(instr)
|
||||
short instr;
|
||||
offset opr_size(short instr)
|
||||
{
|
||||
switch(instr) {
|
||||
case op_loe:
|
||||
|
@ -96,9 +95,7 @@ STATIC offset argsize(arg)
|
|||
}
|
||||
|
||||
|
||||
STATIC offset blocksize(pseudo,args)
|
||||
byte pseudo;
|
||||
arg_p args;
|
||||
STATIC offset blocksize(byte pseudo, arg_p args)
|
||||
{
|
||||
/* Determine the number of bytes of a datablock */
|
||||
|
||||
|
@ -167,7 +164,7 @@ STATIC arg_p copy_rom(args)
|
|||
|
||||
|
||||
|
||||
dblockdef(db,n,lnp)
|
||||
void dblockdef(db,n,lnp)
|
||||
dblock_p db;
|
||||
int n;
|
||||
line_p lnp;
|
||||
|
@ -206,10 +203,7 @@ dblockdef(db,n,lnp)
|
|||
|
||||
/* combine */
|
||||
|
||||
combine(db,l1,l2,pseu)
|
||||
dblock_p db;
|
||||
line_p l1,l2;
|
||||
byte pseu;
|
||||
void combine(dblock_p db, line_p l1, line_p l2, byte pseu)
|
||||
{
|
||||
/* Combine two successive ROMs/CONs (without a data label
|
||||
* in between into a single ROM. E.g.:
|
||||
|
@ -258,7 +252,7 @@ combine(db,l1,l2,pseu)
|
|||
|
||||
/* arglist */
|
||||
|
||||
STATIC arg_string(length,abp)
|
||||
STATIC void arg_string(length,abp)
|
||||
offset length;
|
||||
register argb_p abp;
|
||||
{
|
||||
|
@ -447,10 +441,7 @@ STATIC obj_p make_object(dbl,off,size)
|
|||
|
||||
|
||||
|
||||
obj_p object(ident,off,size)
|
||||
char *ident;
|
||||
offset off;
|
||||
offset size;
|
||||
obj_p object(char *ident, offset off, offset size)
|
||||
{
|
||||
dblock_p dbl;
|
||||
|
||||
|
|
|
@ -10,35 +10,38 @@
|
|||
|
||||
|
||||
|
||||
extern offset opr_size(); /* ( short instr )
|
||||
offset opr_size(short instr); /*
|
||||
* size of operand of given instruction.
|
||||
* The operand is an object , so the
|
||||
* instruction can be loe, zre etc..
|
||||
*/
|
||||
extern dblockdef(); /* (dblock_p db, int n, line_p lnp)
|
||||
void dblockdef(dblock_p db, int n, line_p lnp);
|
||||
/*
|
||||
* Fill in d_pseudo, d_size and
|
||||
* d_values fields of db.
|
||||
*/
|
||||
extern combine(); /* (dblock_p db;line_p l1,l2;byte pseu)
|
||||
void combine(dblock_p db, line_p l1, line_p l2, byte pseu);
|
||||
/*
|
||||
* Combine two successive ROMs or CONs
|
||||
* (with no data label in between)
|
||||
* into one ROM or CON.
|
||||
*/
|
||||
extern line_p arglist(); /* ( int m)
|
||||
line_p arglist(int m); /*
|
||||
* Read a list of m arguments. If m
|
||||
* is 0, then the list is of
|
||||
* undetermined length; it is
|
||||
* then terminated by a cend symbol.
|
||||
*/
|
||||
extern bool is_datalabel(); /* ( line_p l)
|
||||
bool is_datalabel(line_p l); /*
|
||||
* TRUE if l is a data label defining
|
||||
* occurrence (i.e. its l_instr
|
||||
* field is ps_sym).
|
||||
*/
|
||||
extern dblock_p block_of_lab(); /* (char *ident)
|
||||
dblock_p block_of_lab(char *ident); /*
|
||||
* Find the datablock with
|
||||
* the given name.
|
||||
*/
|
||||
extern obj_p object(); /* (char *ident,offset off,short size)
|
||||
obj_p object(char *ident, offset off, offset size);
|
||||
/*
|
||||
* Create an object struct.
|
||||
*/
|
||||
|
|
|
@ -95,15 +95,15 @@ offset get_off() {
|
|||
}
|
||||
}
|
||||
|
||||
STATIC make_string(n) int n; {
|
||||
STATIC void make_string(n) int n; {
|
||||
|
||||
sprintf(string,".%u",n);
|
||||
}
|
||||
|
||||
STATIC inident() {
|
||||
register n;
|
||||
STATIC void inident() {
|
||||
register int n;
|
||||
register char *p = string;
|
||||
register c;
|
||||
register int c;
|
||||
|
||||
n = get_int();
|
||||
while (n--) {
|
||||
|
@ -140,7 +140,7 @@ int table3(n) int n; {
|
|||
}
|
||||
|
||||
int table1() {
|
||||
register n;
|
||||
register int n;
|
||||
|
||||
n = readbyte();
|
||||
if (n == EOF)
|
||||
|
@ -161,7 +161,7 @@ int table1() {
|
|||
}
|
||||
|
||||
int table2() {
|
||||
register n;
|
||||
register int n;
|
||||
|
||||
n = readbyte();
|
||||
if ((n < sp_fcst0 + sp_ncst0) && (n >= sp_fcst0)) {
|
||||
|
@ -174,10 +174,7 @@ int table2() {
|
|||
|
||||
|
||||
|
||||
file_init(f,state,length)
|
||||
FILE *f;
|
||||
short state;
|
||||
long length;
|
||||
void file_init(FILE *f, short state, long length)
|
||||
{
|
||||
short n;
|
||||
|
||||
|
@ -193,7 +190,7 @@ file_init(f,state,length)
|
|||
|
||||
|
||||
|
||||
arch_init(arch)
|
||||
void arch_init(arch)
|
||||
FILE *arch;
|
||||
{
|
||||
short n;
|
||||
|
|
|
@ -8,22 +8,24 @@
|
|||
* L O W L E V E L I / O R O U T I N E S
|
||||
*/
|
||||
|
||||
#include <stdio.h> /* FILE */
|
||||
|
||||
extern int table1(); /* ( )
|
||||
int table1(void); /*
|
||||
* Read an instruction from the
|
||||
* Compact Assembly Language input
|
||||
* file (in 'neutral state').
|
||||
*/
|
||||
extern int table2(); /* ( )
|
||||
int table2(void); /*
|
||||
* Read an instruction argument.
|
||||
*/
|
||||
extern int table3(); /* ( int )
|
||||
int table3(int); /*
|
||||
* Read 'Common Table' item.
|
||||
*/
|
||||
extern short get_int(); /* ( ) */
|
||||
extern offset get_off(); /* ( ) */
|
||||
extern char readchar(); /* ( ) */
|
||||
extern file_init(); /* (FILE *f, short state, long length)
|
||||
short get_int(void);
|
||||
offset get_off(void);
|
||||
char readchar(void);
|
||||
void file_init(FILE *f, short state, long length);
|
||||
/*
|
||||
* Input file initialization. All
|
||||
* following read operations will read
|
||||
* from the given file f. Also checks
|
||||
|
@ -32,7 +34,7 @@ extern file_init(); /* (FILE *f, short state, long length)
|
|||
* If the state is ARCHIVE, length
|
||||
* specifies the length of the module.
|
||||
*/
|
||||
extern arch_init(); /* (FILE *arch)
|
||||
void arch_init(FILE *arch); /*
|
||||
* Same as file_init,but opens an
|
||||
* archive file. So it checks the
|
||||
* magic number for archives.
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "../share/files.h"
|
||||
#include "ic_lib.h"
|
||||
|
||||
STATIC skip_string(n)
|
||||
STATIC void skip_string(n)
|
||||
offset n;
|
||||
{
|
||||
/* Read a string of length n and void it */
|
||||
|
@ -60,7 +60,7 @@ STATIC void skip_arguments()
|
|||
}
|
||||
}
|
||||
|
||||
STATIC bool proc_wanted(name) char* name;
|
||||
STATIC bool proc_wanted(const char *name)
|
||||
{
|
||||
/* See if 'name' is the name of an external procedure
|
||||
* that has been used before, but for which no body
|
||||
|
@ -79,7 +79,7 @@ STATIC bool proc_wanted(name) char* name;
|
|||
}
|
||||
}
|
||||
|
||||
STATIC bool data_wanted(name) char* name;
|
||||
STATIC bool data_wanted(const char *name)
|
||||
{
|
||||
/* See if 'name' is the name of an externally visible
|
||||
* data block that has been used before, but for which
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
*/
|
||||
|
||||
|
||||
extern FILE *next_file(); /* (int argc, char *argv[])
|
||||
FILE *next_file(int argc, char *argv[]);
|
||||
/*
|
||||
* See if there are any more EM input files.
|
||||
* 'argv' contains the names of the files
|
||||
* that are passed as arguments to ic.
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "../share/debug.h"
|
||||
#include "../share/map.h"
|
||||
#include "ic.h"
|
||||
#include "ic_io.h"
|
||||
#include "ic_lookup.h"
|
||||
#include "../share/alloc.h"
|
||||
|
||||
|
@ -43,8 +44,7 @@ char *lastname;
|
|||
|
||||
|
||||
|
||||
lab_id instr_lab(number)
|
||||
short number;
|
||||
lab_id instr_lab(short number)
|
||||
{
|
||||
register num_p *npp, np;
|
||||
|
||||
|
@ -82,7 +82,7 @@ lab_id instr_lab(number)
|
|||
|
||||
/* symlookup */
|
||||
|
||||
STATIC unsigned hash(string) char *string; {
|
||||
STATIC unsigned hash(const char *string) {
|
||||
register char *p;
|
||||
register unsigned i,sum;
|
||||
|
||||
|
@ -91,9 +91,7 @@ STATIC unsigned hash(string) char *string; {
|
|||
return(sum);
|
||||
}
|
||||
|
||||
dblock_p symlookup(name, status)
|
||||
char *name;
|
||||
int status;
|
||||
dblock_p symlookup(const char *name, int status)
|
||||
{
|
||||
/* Look up the name of a data block. The name can appear
|
||||
* in either a defining or applied occurrence (status is
|
||||
|
@ -206,9 +204,7 @@ proc_p getproc(status)
|
|||
|
||||
/* proclookup */
|
||||
|
||||
proc_p proclookup(name, status)
|
||||
char *name;
|
||||
int status;
|
||||
proc_p proclookup(const char *name, int status)
|
||||
{
|
||||
register prc_p *ppp, pp;
|
||||
register proc_p dp;
|
||||
|
@ -271,7 +267,7 @@ proc_p proclookup(name, status)
|
|||
|
||||
/* cleaninstrlabs */
|
||||
|
||||
cleaninstrlabs()
|
||||
void cleaninstrlabs()
|
||||
{
|
||||
register num_p *npp, np, next;
|
||||
|
||||
|
@ -290,7 +286,7 @@ cleaninstrlabs()
|
|||
|
||||
/* dump_procnames */
|
||||
|
||||
dump_procnames(hash,n,f)
|
||||
void dump_procnames(hash,n,f)
|
||||
prc_p hash[];
|
||||
int n;
|
||||
FILE *f;
|
||||
|
@ -328,7 +324,7 @@ dump_procnames(hash,n,f)
|
|||
|
||||
/* cleanprocs */
|
||||
|
||||
cleanprocs(hash,n,mask)
|
||||
void cleanprocs(hash,n,mask)
|
||||
prc_p hash[];
|
||||
int n,mask;
|
||||
{
|
||||
|
@ -372,7 +368,7 @@ cleanprocs(hash,n,mask)
|
|||
|
||||
/* dump_dblocknames */
|
||||
|
||||
dump_dblocknames(hash,n,f)
|
||||
void dump_dblocknames(hash,n,f)
|
||||
sym_p hash[];
|
||||
int n;
|
||||
FILE *f;
|
||||
|
@ -404,7 +400,7 @@ dump_dblocknames(hash,n,f)
|
|||
|
||||
/* cleandblocks */
|
||||
|
||||
cleandblocks(hash,n,mask)
|
||||
void cleandblocks(hash,n,mask)
|
||||
sym_p hash[];
|
||||
int n,mask;
|
||||
{
|
||||
|
|
|
@ -35,42 +35,52 @@ extern sym_p symhash[];
|
|||
extern prc_p prochash[];
|
||||
extern num_p numhash[];
|
||||
|
||||
extern lab_id instr_lab(); /* ( short number)
|
||||
lab_id instr_lab(short number); /*
|
||||
* Maps EM labels to sequential
|
||||
* integers.
|
||||
*/
|
||||
extern dblock_p symlookup(); /* (char *ident, int status)
|
||||
dblock_p symlookup(const char *ident, int status);
|
||||
/*
|
||||
* Look up the data block with
|
||||
* the given name.
|
||||
*/
|
||||
extern dblock_p getsym(); /* ( int status)
|
||||
dblock_p getsym(int status); /*
|
||||
* Read and look up a symbol.
|
||||
* If this is the first occurrence
|
||||
* of it, then make it external
|
||||
* (if status=OCCURRING) or
|
||||
* internal (if DEFINING).
|
||||
*/
|
||||
extern proc_p getproc(); /* (int status)
|
||||
proc_p getproc(int status); /*
|
||||
* Same as getsym, but for procedure
|
||||
* names.
|
||||
*/
|
||||
extern proc_p proclookup(); /* ( char *ident, int status)
|
||||
proc_p proclookup(const char *ident, int status);
|
||||
/*
|
||||
* Find (in the hashtable) the
|
||||
* procedure with the given name.
|
||||
*/
|
||||
extern cleaninstrlabs(); /* ( )
|
||||
void cleaninstrlabs(void); /*
|
||||
* Forget about all instruction labels.
|
||||
*/
|
||||
extern dump_procnames(); /* (prc_p hash[], int n, FILE *f)
|
||||
void dump_procnames(prc_p hash[], int n, FILE *f);
|
||||
/*
|
||||
* Save the names of the procedures
|
||||
* in file f; hash is the hashtable
|
||||
* used and n is its length.
|
||||
*/
|
||||
extern cleanprocs(); /* (prc_p hash[], int n,mask)
|
||||
void cleanprocs(prc_p hash[], int n, int mask);
|
||||
/*
|
||||
* Make the names of all procedures
|
||||
* for which p_flags1&mask = 0 invisible
|
||||
*/
|
||||
extern cleandblocks(); /* (sym_p hash[], int n)
|
||||
void dump_dblocknames(sym_p hash[], int n, FILE *f);
|
||||
/*
|
||||
* Save the names of the EM data
|
||||
* blocks in FILE f.
|
||||
*/
|
||||
void cleandblocks(sym_p hash[], int n, int mask);
|
||||
/*
|
||||
* Make the names of all data blocks
|
||||
* for which d_flags1&mask = 0 invisible
|
||||
*/
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <em_path.h>
|
||||
#include <em_mnem.h>
|
||||
#include <em_pseu.h>
|
||||
|
@ -21,7 +22,9 @@
|
|||
#include "../share/map.h"
|
||||
#include "il_aux.h"
|
||||
#include "il1_anal.h"
|
||||
#include "il1_aux.h"
|
||||
#include "il2_aux.h"
|
||||
#include "il3_change.h"
|
||||
#include "il3_subst.h"
|
||||
#include "../share/get.h"
|
||||
#include "../share/put.h"
|
||||
|
@ -56,7 +59,7 @@ int Sbig_caller, Sdispensable, Schangedcallee, Sbigcallee, Sspace, Szeroratio;
|
|||
* The call descriptors are put in a file (calfile).
|
||||
*/
|
||||
|
||||
pass1(lnam, bnam, cnam) char* lnam, *bnam, *cnam;
|
||||
STATIC void pass1(const char *lnam, const char *bnam, const char *cnam)
|
||||
{
|
||||
FILE* f, *gf, *cf, *ccf; /* The EM input, the basic block graph,
|
||||
* the call-list file and the calcnt file.
|
||||
|
@ -124,8 +127,7 @@ pass1(lnam, bnam, cnam) char* lnam, *bnam, *cnam;
|
|||
|
||||
STATIC char cname2[128] = TMP_DIR;
|
||||
|
||||
pass2(cnam, space) char* cnam;
|
||||
long space;
|
||||
STATIC void pass2(const char *cnam, long space)
|
||||
{
|
||||
FILE* cf, *cf2, *ccf;
|
||||
call_p c, a;
|
||||
|
@ -176,7 +178,7 @@ long space;
|
|||
* EM textfile.
|
||||
*/
|
||||
|
||||
pass3(lnam, lnam2) char* lnam, *lnam2;
|
||||
void pass3(const char *lnam, const char *lnam2)
|
||||
{
|
||||
bool verbose = TRUE;
|
||||
FILE* lfile, *lfilerand, *lfile2, *sfile;
|
||||
|
@ -244,7 +246,7 @@ pass3(lnam, lnam2) char* lnam, *lnam2;
|
|||
}
|
||||
}
|
||||
|
||||
STATIC il_extptab(ptab)
|
||||
STATIC void il_extptab(ptab)
|
||||
proc_p ptab;
|
||||
{
|
||||
/* Allocate space for extension of proctable entries.
|
||||
|
@ -261,7 +263,7 @@ STATIC il_extptab(ptab)
|
|||
}
|
||||
}
|
||||
|
||||
STATIC il_cleanptab(ptab)
|
||||
STATIC void il_cleanptab(ptab)
|
||||
proc_p ptab;
|
||||
{
|
||||
/* De-allocate space for extensions */
|
||||
|
@ -275,7 +277,7 @@ STATIC il_cleanptab(ptab)
|
|||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
Sdiagnostics()
|
||||
STATIC void Sdiagnostics()
|
||||
{
|
||||
/* print statictical information */
|
||||
|
||||
|
@ -324,7 +326,7 @@ void il_flags(void *vp)
|
|||
}
|
||||
}
|
||||
|
||||
main(argc, argv) int argc;
|
||||
int main(argc, argv) int argc;
|
||||
char* argv[];
|
||||
{
|
||||
struct files* files = findfiles(argc, argv);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "il.h"
|
||||
#include "../share/debug.h"
|
||||
#include "../share/alloc.h"
|
||||
#include "../share/cset.h"
|
||||
#include "../share/global.h"
|
||||
#include "../share/lset.h"
|
||||
#include "../share/utils.h"
|
||||
|
@ -38,7 +39,7 @@
|
|||
|
||||
|
||||
|
||||
apriori(proctab)
|
||||
void apriori(proctab)
|
||||
proc_p proctab;
|
||||
{
|
||||
/* For every procedure, see if we can determine
|
||||
|
@ -68,7 +69,7 @@ apriori(proctab)
|
|||
}
|
||||
|
||||
|
||||
STATIC check_labels(p,arglist)
|
||||
STATIC void check_labels(p,arglist)
|
||||
proc_p p;
|
||||
arg_p arglist;
|
||||
{
|
||||
|
@ -91,7 +92,7 @@ STATIC check_labels(p,arglist)
|
|||
|
||||
|
||||
|
||||
STATIC anal_instr(p,b,cf)
|
||||
STATIC void anal_instr(p,b,cf)
|
||||
proc_p p;
|
||||
bblock_p b;
|
||||
FILE *cf;
|
||||
|
@ -152,7 +153,7 @@ STATIC anal_instr(p,b,cf)
|
|||
|
||||
|
||||
|
||||
anal_proc(p,cf,ccf)
|
||||
void anal_proc(p,cf,ccf)
|
||||
proc_p p;
|
||||
FILE *cf,*ccf;
|
||||
{
|
||||
|
|
|
@ -8,14 +8,16 @@
|
|||
* I L 1 _ A N A L . H
|
||||
*/
|
||||
|
||||
extern apriori(); /* (proc_p proctab)
|
||||
void apriori(proc_p proctab);
|
||||
/*
|
||||
* For every procedure, see if we can determine
|
||||
* from the information provided by the previous
|
||||
* phases of the optimizer that it cannot or should not
|
||||
* be expanded in line. This will reduce the length
|
||||
* of the call list.
|
||||
*/
|
||||
extern anal_proc(); /* (proc_p p, FILE *cf, *cff)
|
||||
void anal_proc(proc_p p, FILE *cf, FILE *cff);
|
||||
/*
|
||||
* Analyse a procedure. See which formal parameters
|
||||
* it uses and which procedures it calls.
|
||||
* cf and ccf are the call-file and the call-count file.
|
||||
|
|
|
@ -57,7 +57,7 @@ STATIC bool is_reg(off,s)
|
|||
}
|
||||
|
||||
|
||||
rem_actuals(acts)
|
||||
void rem_actuals(acts)
|
||||
actual_p acts;
|
||||
{
|
||||
/* remove the actual-list */
|
||||
|
@ -73,7 +73,7 @@ rem_actuals(acts)
|
|||
|
||||
|
||||
|
||||
remov_formals(p)
|
||||
void remov_formals(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* Remove the list of formals of p */
|
||||
|
|
|
@ -8,34 +8,36 @@
|
|||
* I L 1 _ A U X . H
|
||||
*/
|
||||
|
||||
extern bool same_size(); /* (int t1,t2)
|
||||
bool same_size(int t1, int t2); /*
|
||||
* See if the two types t1 and t2 have
|
||||
* the same size.
|
||||
*/
|
||||
extern rem_actuals(); /* (actual_p atcs)
|
||||
void rem_actuals(actual_p acts);/*
|
||||
* remove an actual-list from core.
|
||||
*/
|
||||
extern remov_formals(); /* (proc_p p)
|
||||
void remov_formals(proc_p p); /*
|
||||
* Remove the formals-list of p from core.
|
||||
*/
|
||||
extern void rem_indir_acc(); /* (proc_p p)
|
||||
void rem_indir_acc(proc_p p); /*
|
||||
* Remove formal that may be accessed
|
||||
* indirectly from formal lists of p
|
||||
*/
|
||||
extern bool par_overlap(); /* (offset off1, int t1, offset off2, int t2)
|
||||
bool par_overlap(offset off1, int t1, offset off2, int t2);
|
||||
/*
|
||||
* See if the formal at offset off1 and type t1
|
||||
* overlaps the formal at offset off2
|
||||
* and type t2.
|
||||
*/
|
||||
extern short looplevel(); /* (bblock_p b)
|
||||
short looplevel(bblock_p b); /*
|
||||
* Determine the loop nesting level of b.
|
||||
*/
|
||||
extern int proclength(); /* (proc_p p)
|
||||
int proclength(proc_p p); /*
|
||||
* Determine the number of EM instructions
|
||||
* in p. Do not count pseudos.
|
||||
*/
|
||||
|
||||
extern line_p copy_code(); /* (line_p l1,l2)
|
||||
line_p copy_code(line_p l1, line_p l2);
|
||||
/*
|
||||
* copy the code between l1 and l2.
|
||||
* Pseudos may not be contained in
|
||||
* the list of instructions. If l1==l2
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <em_mnem.h>
|
||||
#include "../share/types.h"
|
||||
#include "il.h"
|
||||
#include "il_aux.h"
|
||||
#include "il1_cal.h"
|
||||
#include "../share/debug.h"
|
||||
#include "../share/alloc.h"
|
||||
|
@ -91,7 +92,7 @@ STATIC void inc_count(caller,callee)
|
|||
|
||||
|
||||
|
||||
anal_cal(p,call,b,cf)
|
||||
void anal_cal(p,call,b,cf)
|
||||
proc_p p;
|
||||
line_p call;
|
||||
bblock_p b;
|
||||
|
|
|
@ -29,7 +29,8 @@ extern struct class classtab[];
|
|||
#define CLASS9 9
|
||||
|
||||
|
||||
extern anal_cal(); /* (line_p call, bblock_p b)
|
||||
void anal_cal(proc_p p, line_p call, bblock_p b, FILE *cf);
|
||||
/*
|
||||
* analyze a call instruction;
|
||||
* try to recognize the actual parameter
|
||||
* expressions.
|
||||
|
|
|
@ -70,7 +70,7 @@ formal_p find_formal(p,type,off)
|
|||
|
||||
|
||||
|
||||
STATIC no_inl_pars(p)
|
||||
STATIC void no_inl_pars(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* p may not have any in line parameters */
|
||||
|
@ -81,7 +81,7 @@ STATIC no_inl_pars(p)
|
|||
|
||||
|
||||
|
||||
STATIC inc_use(f,b)
|
||||
STATIC void inc_use(f,b)
|
||||
formal_p f;
|
||||
bblock_p b;
|
||||
{
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
* I L 1 _ F O R M A L . C
|
||||
*/
|
||||
|
||||
extern void formal(); /* (proc_p p; bblock_p b; offset off;
|
||||
* int type, usage)
|
||||
void formal(proc_p p, bblock_p b, offset off, int type, int usage);
|
||||
/*
|
||||
* Analyze a reference to a parameter of p.
|
||||
* The type denotes its size (single,double,
|
||||
* pointer).
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "../share/debug.h"
|
||||
#include "../share/alloc.h"
|
||||
#include "../share/global.h"
|
||||
#include "../share/cset.h"
|
||||
#include "../share/lset.h"
|
||||
#include "il_aux.h"
|
||||
#include "il2_aux.h"
|
||||
|
@ -34,6 +35,9 @@
|
|||
#define CHANGED(p) p->p_flags2 |= PF_CHANGED
|
||||
#define IS_CHANGED(p) (p->p_flags2 & PF_CHANGED)
|
||||
|
||||
#ifdef VERBOSE
|
||||
STATIC void Sstat(proc_p proclist, long space);
|
||||
#endif
|
||||
|
||||
|
||||
STATIC bool match_pars(fm,act)
|
||||
|
@ -220,7 +224,7 @@ STATIC short param_score(c)
|
|||
|
||||
|
||||
|
||||
assign_ratio(c)
|
||||
void assign_ratio(c)
|
||||
call_p c;
|
||||
{
|
||||
/* This routine is one of the most important ones
|
||||
|
@ -289,7 +293,7 @@ call_p abstract(c)
|
|||
|
||||
|
||||
|
||||
STATIC adjust_counts(callee,ccf)
|
||||
STATIC void adjust_counts(callee,ccf)
|
||||
proc_p callee;
|
||||
FILE *ccf;
|
||||
{
|
||||
|
@ -389,7 +393,7 @@ STATIC call_p find_origin(c)
|
|||
|
||||
|
||||
|
||||
STATIC selected(a)
|
||||
STATIC void selected(a)
|
||||
call_p a;
|
||||
{
|
||||
/* The call a is selected for in line expansion.
|
||||
|
@ -406,7 +410,7 @@ STATIC selected(a)
|
|||
|
||||
|
||||
|
||||
STATIC compare(x,best,space)
|
||||
STATIC void compare(x,best,space)
|
||||
call_p x, *best;
|
||||
long space;
|
||||
{
|
||||
|
@ -450,7 +454,7 @@ STATIC call_p best_one(list,space)
|
|||
|
||||
|
||||
|
||||
STATIC singles(cals)
|
||||
STATIC void singles(cals)
|
||||
call_p cals;
|
||||
{
|
||||
/* If a procedure is only called once, this call
|
||||
|
@ -486,7 +490,7 @@ STATIC singles(cals)
|
|||
|
||||
|
||||
|
||||
STATIC single_calls(proclist)
|
||||
STATIC void single_calls(proclist)
|
||||
proc_p proclist;
|
||||
{
|
||||
proc_p p;
|
||||
|
@ -505,7 +509,7 @@ STATIC single_calls(proclist)
|
|||
|
||||
|
||||
|
||||
select_calls(proclist,ccf,space)
|
||||
void select_calls(proclist,ccf,space)
|
||||
proc_p proclist;
|
||||
FILE *ccf;
|
||||
long space ;
|
||||
|
@ -549,7 +553,7 @@ select_calls(proclist,ccf,space)
|
|||
|
||||
|
||||
|
||||
STATIC nonnested_calls(cfile)
|
||||
STATIC void nonnested_calls(cfile)
|
||||
FILE *cfile;
|
||||
{
|
||||
register call_p c,a;
|
||||
|
@ -569,7 +573,7 @@ STATIC nonnested_calls(cfile)
|
|||
|
||||
|
||||
|
||||
STATIC copy_pars(src,dest)
|
||||
STATIC void copy_pars(src,dest)
|
||||
call_p src, dest;
|
||||
{
|
||||
/* Copy the actual parameters of src to dest. */
|
||||
|
@ -589,7 +593,7 @@ STATIC copy_pars(src,dest)
|
|||
|
||||
|
||||
|
||||
STATIC nest_pars(cals)
|
||||
STATIC void nest_pars(cals)
|
||||
call_p cals;
|
||||
{
|
||||
/* Recursive auxiliary procedure of add_actuals. */
|
||||
|
@ -607,7 +611,7 @@ STATIC nest_pars(cals)
|
|||
|
||||
|
||||
|
||||
add_actuals(proclist,cfile)
|
||||
void add_actuals(proclist,cfile)
|
||||
proc_p proclist;
|
||||
FILE *cfile;
|
||||
{
|
||||
|
@ -633,7 +637,7 @@ add_actuals(proclist,cfile)
|
|||
|
||||
|
||||
|
||||
STATIC clean(cals)
|
||||
STATIC void clean(cals)
|
||||
call_p *cals;
|
||||
{
|
||||
call_p c,next,*cpp;
|
||||
|
@ -655,7 +659,7 @@ STATIC clean(cals)
|
|||
}
|
||||
|
||||
|
||||
cleancals(proclist)
|
||||
void cleancals(proclist)
|
||||
proc_p proclist;
|
||||
{
|
||||
/* Remove all calls in the P_CALS list of p
|
||||
|
@ -672,7 +676,7 @@ cleancals(proclist)
|
|||
|
||||
|
||||
|
||||
append_abstract(a,p)
|
||||
void append_abstract(a,p)
|
||||
call_p a;
|
||||
proc_p p;
|
||||
{
|
||||
|
@ -698,7 +702,7 @@ append_abstract(a,p)
|
|||
*/
|
||||
|
||||
|
||||
Sstatist(list,space)
|
||||
STATIC void Sstatist(list,space)
|
||||
call_p list;
|
||||
long space;
|
||||
{
|
||||
|
@ -717,7 +721,7 @@ Sstatist(list,space)
|
|||
}
|
||||
}
|
||||
|
||||
Sstat(proclist,space)
|
||||
STATIC void Sstat(proclist,space)
|
||||
proc_p proclist;
|
||||
long space;
|
||||
{
|
||||
|
|
|
@ -3,22 +3,23 @@
|
|||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
extern bool anal_params(); /* (call_p c)
|
||||
bool anal_params(call_p c); /*
|
||||
* See which parameters of the call
|
||||
* may be expanded in line.
|
||||
* If the formals and actuals do not
|
||||
* match, return FALSE
|
||||
*/
|
||||
extern assign_ratio(); /* (call_p c)
|
||||
void assign_ratio(call_p c); /*
|
||||
* Assigna ratio number to the call,
|
||||
* indicating how desirable it is to
|
||||
* expand the call in line.
|
||||
*/
|
||||
extern call_p abstract(); /* (call_p c)
|
||||
call_p abstract(call_p c); /*
|
||||
* Abstract essential information from
|
||||
* the call.
|
||||
*/
|
||||
extern select_calls(); /* (call_p alist; FILE *ccf;short space)
|
||||
void select_calls(proc_p proclist, FILE *ccf, long space);
|
||||
/*
|
||||
* Select the best calls to be expanded.
|
||||
* Every procedure gets a list of
|
||||
* selected calls appearing in it.
|
||||
|
@ -26,10 +27,11 @@ extern select_calls(); /* (call_p alist; FILE *ccf;short space)
|
|||
* program is allowed to grow
|
||||
* (expressed in number of EM instructions).
|
||||
*/
|
||||
extern cleancals(); /* (proc_p plist)
|
||||
void cleancals(proc_p alist); /*
|
||||
* Remove all calls that were not selected.
|
||||
*/
|
||||
extern add_actuals(); /* (proc_p plist; FILE *cfile)
|
||||
void add_actuals(proc_p plist, FILE *cfile);
|
||||
/*
|
||||
* Add the actual parameters to the descriptor abstracts
|
||||
* of the selected calls.
|
||||
* the calfile contains the full descriptors of all
|
||||
|
@ -37,7 +39,8 @@ extern add_actuals(); /* (proc_p plist; FILE *cfile)
|
|||
* These two are combined to yield a file of full
|
||||
* descriptors of the selected calls.
|
||||
*/
|
||||
extern append_abstract(); /* (call_p a; proc_p p)
|
||||
void append_abstract(call_p a, proc_p p);
|
||||
/*
|
||||
* Put the call-descriptor abstract in the p_cals
|
||||
* list of p.
|
||||
*/
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "../share/debug.h"
|
||||
#include "../share/alloc.h"
|
||||
#include "../share/global.h"
|
||||
#include "il_aux.h"
|
||||
#include "il3_aux.h"
|
||||
|
||||
|
||||
|
@ -33,7 +32,7 @@ line_p last_line(lines)
|
|||
|
||||
|
||||
|
||||
app_list(list,l)
|
||||
void app_list(list,l)
|
||||
line_p list,l;
|
||||
{
|
||||
/* Append the list after line l */
|
||||
|
@ -53,7 +52,7 @@ app_list(list,l)
|
|||
|
||||
|
||||
|
||||
rem_line(l)
|
||||
void rem_line(l)
|
||||
line_p l;
|
||||
{
|
||||
/* Remove a line from the list */
|
||||
|
|
|
@ -8,13 +8,14 @@
|
|||
* I L 3 _ A U X . H
|
||||
*/
|
||||
|
||||
extern line_p last_line(); /* (line_p list)
|
||||
line_p last_line(line_p list); /*
|
||||
* Find the last line of a list.
|
||||
*/
|
||||
extern app_list(); /* (line_p list,l)
|
||||
void app_list(line_p list, line_p l);
|
||||
/*
|
||||
* Put list after l
|
||||
*/
|
||||
extern rem_line(); /* (line_p l)
|
||||
void rem_line(line_p l); /*
|
||||
* Remove a line from a (doubly linked)
|
||||
* list.
|
||||
*/
|
||||
|
|
|
@ -54,7 +54,7 @@ STATIC line_p par_expr(l,expr)
|
|||
|
||||
|
||||
|
||||
STATIC rem_text(l1,l2)
|
||||
STATIC void rem_text(l1,l2)
|
||||
line_p l1,l2;
|
||||
{
|
||||
/* Remove the lines from l1 to l2 (inclusive) */
|
||||
|
@ -69,7 +69,7 @@ STATIC rem_text(l1,l2)
|
|||
|
||||
|
||||
|
||||
STATIC store_tmp(p,l,size)
|
||||
STATIC void store_tmp(p,l,size)
|
||||
proc_p p;
|
||||
line_p l;
|
||||
offset size;
|
||||
|
@ -103,7 +103,7 @@ STATIC store_tmp(p,l,size)
|
|||
|
||||
|
||||
|
||||
STATIC chg_actuals(c,cal)
|
||||
STATIC void chg_actuals(c,cal)
|
||||
call_p c;
|
||||
line_p cal;
|
||||
{
|
||||
|
@ -131,7 +131,7 @@ STATIC chg_actuals(c,cal)
|
|||
|
||||
|
||||
|
||||
STATIC rm_callpart(c,cal)
|
||||
STATIC void rm_callpart(c,cal)
|
||||
call_p c;
|
||||
line_p cal;
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ STATIC rm_callpart(c,cal)
|
|||
|
||||
|
||||
|
||||
chg_callseq(c,cal,l_out)
|
||||
void chg_callseq(c,cal,l_out)
|
||||
call_p c;
|
||||
line_p cal,*l_out;
|
||||
{
|
||||
|
@ -237,7 +237,7 @@ STATIC void act_info(off,acts,ab_off,act_out,off_out)
|
|||
|
||||
|
||||
|
||||
STATIC store_off(off,l)
|
||||
STATIC void store_off(off,l)
|
||||
offset off;
|
||||
line_p l;
|
||||
{
|
||||
|
@ -251,7 +251,7 @@ STATIC store_off(off,l)
|
|||
|
||||
|
||||
|
||||
STATIC inl_actual(l,expr)
|
||||
STATIC void inl_actual(l,expr)
|
||||
line_p l, expr;
|
||||
{
|
||||
/* Expand an actual parameter in line.
|
||||
|
@ -281,7 +281,7 @@ STATIC inl_actual(l,expr)
|
|||
|
||||
|
||||
|
||||
STATIC localref(l,c,ab_off,lb_off)
|
||||
STATIC void localref(l,c,ab_off,lb_off)
|
||||
line_p l;
|
||||
call_p c;
|
||||
offset ab_off, lb_off;
|
||||
|
@ -311,7 +311,7 @@ STATIC localref(l,c,ab_off,lb_off)
|
|||
|
||||
|
||||
|
||||
STATIC chg_mes(l,c,ab_off,lb_off)
|
||||
STATIC void chg_mes(l,c,ab_off,lb_off)
|
||||
line_p l;
|
||||
call_p c;
|
||||
offset ab_off, lb_off;
|
||||
|
@ -355,7 +355,7 @@ STATIC chg_mes(l,c,ab_off,lb_off)
|
|||
|
||||
|
||||
|
||||
STATIC chg_ret(l,c,lab)
|
||||
STATIC void chg_ret(l,c,lab)
|
||||
line_p l,lab;
|
||||
call_p c;
|
||||
{
|
||||
|
@ -379,7 +379,7 @@ STATIC chg_ret(l,c,lab)
|
|||
|
||||
|
||||
|
||||
STATIC mod_instr(l,c,lab,ab_off,lb_off,lab_off)
|
||||
STATIC void mod_instr(l,c,lab,ab_off,lb_off,lab_off)
|
||||
line_p l,lab;
|
||||
call_p c;
|
||||
offset ab_off,lb_off;
|
||||
|
@ -421,7 +421,7 @@ STATIC mod_instr(l,c,lab,ab_off,lb_off,lab_off)
|
|||
}
|
||||
|
||||
|
||||
modify(text,c,lab,ab_off,lb_off,lab_off)
|
||||
void modify(text,c,lab,ab_off,lb_off,lab_off)
|
||||
line_p text,lab;
|
||||
call_p c;
|
||||
offset ab_off,lb_off;
|
||||
|
@ -453,7 +453,7 @@ modify(text,c,lab,ab_off,lb_off,lab_off)
|
|||
|
||||
|
||||
|
||||
mod_actuals(nc,c,lab,ab_off,lb_off,lab_off)
|
||||
void mod_actuals(nc,c,lab,ab_off,lb_off,lab_off)
|
||||
call_p nc,c;
|
||||
line_p lab;
|
||||
offset ab_off,lb_off;
|
||||
|
@ -534,7 +534,7 @@ insert(text,l,firstline)
|
|||
|
||||
|
||||
|
||||
liquidate(p,text)
|
||||
void liquidate(p,text)
|
||||
proc_p p;
|
||||
line_p text;
|
||||
{
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
*/
|
||||
|
||||
|
||||
extern chg_callseq(); /* (call_p c; line_p cal, *l_out)
|
||||
void chg_callseq(call_p c, line_p cal, line_p *l_out);
|
||||
/*
|
||||
* Change the calling sequence of
|
||||
* the call c. The parameters are
|
||||
* changed and the sequence
|
||||
|
@ -19,28 +20,33 @@ extern chg_callseq(); /* (call_p c; line_p cal, *l_out)
|
|||
* text of the called routine must
|
||||
* be put.
|
||||
*/
|
||||
extern line_p make_label(); /* (line_p l; proc_p p)
|
||||
line_p make_label(line_p l, proc_p p);
|
||||
/*
|
||||
* Make sure that the instruction after
|
||||
* l contains a label. If this is not
|
||||
* already the case, create a new label.
|
||||
*/
|
||||
extern modify(); /* (line_p text; call_p c; line_p lab;
|
||||
* offset ab_off, lb_off; int lab_off)
|
||||
void modify(line_p text, call_p c, line_p lab, offset ab_off,
|
||||
offset lb_off, int lab_off);
|
||||
/*
|
||||
* Modify the EM text of the called
|
||||
* procedure.
|
||||
*/
|
||||
extern mod_actuals(); /* (call_p nc,c; line_p lab;
|
||||
* offset ab_off, lb_off; int lab_off)
|
||||
void mod_actuals(call_p nc, call_p c, line_p lab, offset ab_off,
|
||||
offset lb_off, int lab_off);
|
||||
/*
|
||||
* Modify the actual parameters of the
|
||||
* call nc the same way as the text of
|
||||
* call c would be modified.
|
||||
*/
|
||||
extern void insert(); /* (line_p text,l,firstline)
|
||||
void insert(line_p text, line_p l, line_p firstline);
|
||||
/*
|
||||
* Insert the modified EM text.
|
||||
* Pseudos are put after the pseudos
|
||||
* of the caller.
|
||||
*/
|
||||
extern liquidate(); /* (proc_p p; line_p text)
|
||||
void liquidate(proc_p p, line_p text);
|
||||
/*
|
||||
* All calls to p were expanded in line,
|
||||
* so p is no longer needed.
|
||||
*/
|
||||
|
|
|
@ -47,9 +47,7 @@ STATIC line_p fetch_text(lf,c)
|
|||
|
||||
|
||||
|
||||
line_p scan_to_cal(lines,n)
|
||||
line_p lines;
|
||||
short n;
|
||||
line_p scan_to_cal(line_p lines, short n)
|
||||
{
|
||||
/* Find the n-th CAL instruction */
|
||||
|
||||
|
@ -65,7 +63,7 @@ line_p scan_to_cal(lines,n)
|
|||
|
||||
|
||||
|
||||
substitute(lf,c,cal,firstline)
|
||||
void substitute(lf,c,cal,firstline)
|
||||
FILE *lf;
|
||||
call_p c;
|
||||
line_p cal,firstline;
|
||||
|
|
|
@ -9,10 +9,12 @@
|
|||
* I L 3 _ S U B S T . H
|
||||
*/
|
||||
|
||||
extern line_p scan_to_cal(); /* (line_p lines; short n)
|
||||
line_p scan_to_cal(line_p lines, short n);
|
||||
/*
|
||||
* Find the n-th cal instruction.
|
||||
*/
|
||||
extern substitute(); /* (FILE *lf;call_p c; line_ pcal,firstline)
|
||||
void substitute(FILE *lf, call_p c, line_p cal, line_p firstline);
|
||||
/*
|
||||
* Perform in line substitution of the call described
|
||||
* by c. The EM text of the called routine is fetched
|
||||
* and modified, the calling sequence is changed,
|
||||
|
|
|
@ -106,7 +106,7 @@ line_p copy_expr(l1)
|
|||
|
||||
|
||||
|
||||
rem_call(c)
|
||||
void rem_call(c)
|
||||
call_p c;
|
||||
{
|
||||
actual_p act, nexta;
|
||||
|
@ -132,7 +132,7 @@ rem_call(c)
|
|||
|
||||
|
||||
|
||||
/* rem_graph */
|
||||
/* remunit */
|
||||
|
||||
STATIC short remlines(l)
|
||||
line_p l;
|
||||
|
@ -149,11 +149,7 @@ STATIC short remlines(l)
|
|||
|
||||
|
||||
|
||||
void
|
||||
remunit(kind,p,l)
|
||||
short kind;
|
||||
proc_p p;
|
||||
line_p l;
|
||||
void remunit(short kind, proc_p p, line_p l)
|
||||
{
|
||||
register bblock_p b;
|
||||
bblock_p next;
|
||||
|
@ -176,12 +172,13 @@ remunit(kind,p,l)
|
|||
oldloop(Lelem(pi));
|
||||
}
|
||||
Ldeleteset(p->p_loops);
|
||||
oldmap(lmap,llength);
|
||||
oldmap(lbmap,llength);
|
||||
oldmap(bmap,blength);
|
||||
oldmap(lpmap,lplength);
|
||||
oldmap((void **) lmap,llength);
|
||||
oldmap((void **) lbmap,llength);
|
||||
oldmap((void **) bmap,blength);
|
||||
oldmap((void **) lpmap,lplength);
|
||||
}
|
||||
remcc(head)
|
||||
|
||||
void remcc(head)
|
||||
calcnt_p head;
|
||||
{
|
||||
calcnt_p cc, next;
|
||||
|
@ -271,8 +268,8 @@ line_p get_text(lf,p_out)
|
|||
* and labels to basic blocks are not used.
|
||||
*/
|
||||
if (*p_out != (proc_p) 0) {
|
||||
oldmap(lmap,llength);
|
||||
oldmap(lbmap,llength);
|
||||
oldmap((void **) lmap,llength);
|
||||
oldmap((void **) lbmap,llength);
|
||||
lmap = oldlmap;
|
||||
lpmap = oldlpmap;
|
||||
}
|
||||
|
@ -309,7 +306,7 @@ calcnt_p getcc(ccf,p)
|
|||
/* The following routines are only used by the Inline Substitution phase */
|
||||
|
||||
|
||||
STATIC putactuals(alist,cfile)
|
||||
STATIC void putactuals(alist,cfile)
|
||||
actual_p alist;
|
||||
FILE *cfile;
|
||||
{
|
||||
|
@ -336,10 +333,7 @@ STATIC putactuals(alist,cfile)
|
|||
|
||||
|
||||
|
||||
putcall(c,cfile,level)
|
||||
call_p c;
|
||||
FILE *cfile;
|
||||
short level;
|
||||
void putcall(call_p c, FILE *cfile, short level)
|
||||
{
|
||||
/* output a call */
|
||||
|
||||
|
|
|
@ -9,50 +9,57 @@
|
|||
* I L _ A U X . H
|
||||
*/
|
||||
|
||||
extern int tsize(); /* (int type)
|
||||
#include <stdio.h> /* FILE */
|
||||
|
||||
int tsize(int type); /*
|
||||
* Determine the size of a variable of
|
||||
* the given type.
|
||||
*/
|
||||
extern line_p duplicate(); /* (line_p lnp)
|
||||
line_p duplicate(line_p lnp); /*
|
||||
* Make a duplicate of the given EM
|
||||
* instruction. Pseudos may not be
|
||||
* passed as argumnets.
|
||||
*/
|
||||
extern line_p copy_expr(); /* (line_p l1)
|
||||
line_p copy_expr(line_p l1); /*
|
||||
* copy the expression l1.
|
||||
* Pseudos may not be contained in
|
||||
* the list of instructions.
|
||||
*/
|
||||
extern rem_call(); /* (call_p c)
|
||||
void rem_call(call_p c); /*
|
||||
* Remove a call from main memory.
|
||||
*/
|
||||
extern rem_graph(); /* (proc_p p)
|
||||
void remunit(short kind, proc_p p, line_p l);
|
||||
/*
|
||||
* Remove the CFG and EM text of
|
||||
* a procedure from core.
|
||||
*/
|
||||
extern remcc(); /* (calcnt_p head)
|
||||
void remcc(calcnt_p head); /*
|
||||
* Remove call-count info from core.
|
||||
*/
|
||||
extern call_p getcall(); /* (FILE *cf)
|
||||
call_p getcall(FILE *cf); /*
|
||||
* Read a call from the call-file
|
||||
*/
|
||||
extern line_p get_text(); /* (FILE *lf; proc_p *p_out)
|
||||
line_p get_text(FILE *lf, proc_p *p_out);
|
||||
/*
|
||||
* Read the EM text of one procedure.
|
||||
* The procedure read is returned via
|
||||
* p_out.
|
||||
*/
|
||||
extern calcnt_p getcc(); /* (FILE *ccf; proc_p p)
|
||||
calcnt_p getcc(FILE *ccf, proc_p p);
|
||||
/*
|
||||
* Read the call-count information
|
||||
* of procedure p.
|
||||
*/
|
||||
extern putcall(); /* (call_p call; FILE *cfile; short level)
|
||||
void putcall(call_p call, FILE *cfile, short level);
|
||||
/*
|
||||
* Write the call
|
||||
* with the given id to the given file.
|
||||
* The level is the nesting level, used by
|
||||
* putcall when it calls itself recurively.
|
||||
* It should be 0 on outer levels.
|
||||
*/
|
||||
extern long putcc(); /* (calcnt_p head; FILE *ccf)
|
||||
long putcc(calcnt_p head, FILE *ccf);
|
||||
/*
|
||||
* Write call-count information to
|
||||
* file ccf.
|
||||
*/
|
||||
|
|
|
@ -41,16 +41,16 @@ short nrvars;
|
|||
STATIC int Slv;
|
||||
STATIC bool mesgflag = FALSE; /* Suppress generation of live/dead info */
|
||||
|
||||
STATIC app_block();
|
||||
STATIC void app_block();
|
||||
|
||||
STATIC clean_up()
|
||||
STATIC void clean_up()
|
||||
{
|
||||
local_p *p;
|
||||
|
||||
for (p = &locals[1]; p <= &locals[nrlocals]; p++) {
|
||||
oldlocal(*p);
|
||||
}
|
||||
oldmap(locals,nrlocals);
|
||||
oldmap((void **) locals,nrlocals);
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,7 +137,7 @@ STATIC bool is_def(l)
|
|||
}
|
||||
|
||||
|
||||
STATIC def_use(p)
|
||||
STATIC void def_use(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* Compute DEF(b) and USE(b), for every basic block b
|
||||
|
@ -200,7 +200,7 @@ STATIC def_use(p)
|
|||
|
||||
|
||||
|
||||
STATIC unite_ins(bbset,setp)
|
||||
STATIC void unite_ins(bbset,setp)
|
||||
lset bbset;
|
||||
cset *setp;
|
||||
{
|
||||
|
@ -218,7 +218,7 @@ STATIC unite_ins(bbset,setp)
|
|||
|
||||
|
||||
|
||||
STATIC solve_lv(p)
|
||||
STATIC void solve_lv(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* Solve the data flow equations for Live Variables,
|
||||
|
@ -254,7 +254,7 @@ STATIC solve_lv(p)
|
|||
}
|
||||
|
||||
|
||||
STATIC live_variables_analysis(p)
|
||||
STATIC void live_variables_analysis(p)
|
||||
proc_p p;
|
||||
{
|
||||
make_localtab(p);
|
||||
|
@ -264,7 +264,7 @@ STATIC live_variables_analysis(p)
|
|||
}
|
||||
|
||||
|
||||
STATIC init_live_dead(b)
|
||||
STATIC void init_live_dead(b)
|
||||
bblock_p b;
|
||||
{
|
||||
/* For every register variable, see if it is
|
||||
|
@ -313,7 +313,7 @@ STATIC line_p make_mesg(mesg,loc)
|
|||
|
||||
|
||||
|
||||
STATIC block_entry(b,prev)
|
||||
STATIC void block_entry(b,prev)
|
||||
bblock_p b,prev;
|
||||
{
|
||||
short v,vn;
|
||||
|
@ -345,7 +345,7 @@ STATIC block_entry(b,prev)
|
|||
|
||||
|
||||
|
||||
STATIC app_block(l,b)
|
||||
STATIC void app_block(l,b)
|
||||
line_p l;
|
||||
bblock_p b;
|
||||
{
|
||||
|
@ -369,7 +369,7 @@ STATIC app_block(l,b)
|
|||
|
||||
|
||||
|
||||
STATIC definition(l,useless_out,v_out,mesgflag)
|
||||
STATIC void definition(l,useless_out,v_out,mesgflag)
|
||||
line_p l;
|
||||
bool *useless_out;
|
||||
short *v_out;
|
||||
|
@ -420,7 +420,7 @@ STATIC definition(l,useless_out,v_out,mesgflag)
|
|||
|
||||
|
||||
|
||||
STATIC use(l,mesgflag)
|
||||
STATIC void use(l,mesgflag)
|
||||
line_p l;
|
||||
bool mesgflag;
|
||||
{
|
||||
|
@ -451,7 +451,7 @@ STATIC use(l,mesgflag)
|
|||
STATIC void nothing(line_p l1, line_p l2, offset size)
|
||||
{ } /* No action to be undertaken at level 0 of parser */
|
||||
|
||||
STATIC rem_code(l1,l2,b)
|
||||
STATIC void rem_code(l1,l2,b)
|
||||
line_p l1,l2;
|
||||
bblock_p b;
|
||||
{
|
||||
|
@ -481,9 +481,7 @@ STATIC rem_code(l1,l2,b)
|
|||
|
||||
|
||||
|
||||
lv_mesg(p,mesgflag)
|
||||
proc_p p;
|
||||
bool mesgflag;
|
||||
STATIC void lv_mesg(proc_p p, bool mesgflag)
|
||||
{
|
||||
/* Create live/dead messages for every possible register
|
||||
* variable of p. A dead-message is put after a "use" of
|
||||
|
@ -553,8 +551,7 @@ OUTVERBOSE("useless assignment ,proc %d,local %d", curproc->p_id,
|
|||
}
|
||||
|
||||
|
||||
STATIC lv_extend(p)
|
||||
proc_p p;
|
||||
STATIC void lv_extend(proc_p p)
|
||||
{
|
||||
/* Allocate extended data structures for Use Definition analysis */
|
||||
|
||||
|
@ -566,8 +563,7 @@ STATIC lv_extend(p)
|
|||
}
|
||||
|
||||
|
||||
STATIC lv_cleanup(p)
|
||||
proc_p p;
|
||||
STATIC void lv_cleanup(proc_p p)
|
||||
{
|
||||
/* Deallocate extended data structures for Use Definition analysis */
|
||||
|
||||
|
@ -610,7 +606,7 @@ void lv_optimize(void *vp)
|
|||
|
||||
|
||||
|
||||
main(argc,argv)
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@ cprogram {
|
|||
"modules/src/em_data+lib",
|
||||
"h+emheaders",
|
||||
"+itemtab_h",
|
||||
"./ra*.h",
|
||||
},
|
||||
vars = {
|
||||
["+cflags"] = {"-DVERBOSE", "-DNOTCOMPACT"}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -20,16 +21,20 @@
|
|||
*/
|
||||
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
void error(const char *s)
|
||||
{
|
||||
fprintf(stderr,"%s\n",s);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
convert(mnemfile,itemfile)
|
||||
FILE *mnemfile, *itemfile;
|
||||
|
||||
void convert(FILE *mnemfile, FILE *itemfile)
|
||||
{
|
||||
char mnem1[20], mnem2[20],def[20],itemtype[20];
|
||||
int newcl,opc,index;
|
||||
int opc,index;
|
||||
bool newcl;
|
||||
|
||||
newcl = TRUE;
|
||||
newcl = true;
|
||||
printf("struct item_descr itemtab[] = {\n");
|
||||
for (;;) {
|
||||
fscanf(mnemfile,"%19s%19s%d",def,mnem1,&opc);
|
||||
|
@ -47,28 +52,17 @@ convert(mnemfile,itemfile)
|
|||
* it has no type.
|
||||
*/
|
||||
printf("{NO_ITEM,0}, /* %s */\n", mnem1);
|
||||
newcl = FALSE;
|
||||
newcl = false;
|
||||
} else {
|
||||
printf("{%s,%d}, /* %s */\n",itemtype,index, mnem1);
|
||||
newcl = TRUE;
|
||||
newcl = true;
|
||||
}
|
||||
}
|
||||
printf("};\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
error(s)
|
||||
char *s;
|
||||
{
|
||||
fprintf(stderr,"%s\n",s);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *f1,*f2;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "../share/files.h"
|
||||
#include "../share/get.h"
|
||||
#include "../share/put.h"
|
||||
#include "../share/cset.h"
|
||||
#include "../share/lset.h"
|
||||
#include "../share/map.h"
|
||||
#include "../share/alloc.h"
|
||||
|
@ -25,6 +26,7 @@
|
|||
#include "ra.h"
|
||||
#include "ra_items.h"
|
||||
#include "ra_allocl.h"
|
||||
#include "ra_lifet.h"
|
||||
#include "ra_profits.h"
|
||||
#include "ra_pack.h"
|
||||
#include "ra_xform.h"
|
||||
|
@ -35,6 +37,8 @@
|
|||
#define oldrabx(x) oldstruct(bext_ra,x)
|
||||
#define oldralpx(x) oldstruct(lpext_ra,x)
|
||||
|
||||
STATIC void stat_regusage(alloc_p list);
|
||||
|
||||
short alloc_id;
|
||||
static item_p items[NRITEMTYPES];
|
||||
int nrinstrs;
|
||||
|
@ -72,7 +76,7 @@ STATIC cond_p getcondtab(f)
|
|||
return tab;
|
||||
}
|
||||
|
||||
get_atab(f,tab)
|
||||
STATIC void get_atab(f,tab)
|
||||
FILE *f;
|
||||
cond_p tab[NRREGTYPES][NRREGTYPES];
|
||||
{
|
||||
|
@ -88,7 +92,7 @@ get_atab(f,tab)
|
|||
}
|
||||
|
||||
|
||||
get_otab(f,tab)
|
||||
STATIC void get_otab(f,tab)
|
||||
FILE *f;
|
||||
cond_p tab[NRREGTYPES];
|
||||
{
|
||||
|
@ -155,7 +159,7 @@ STATIC bblock_p header(lp)
|
|||
}
|
||||
|
||||
|
||||
STATIC ra_extproc(p)
|
||||
STATIC void ra_extproc(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* Allocate the extended data structures for procedure p */
|
||||
|
@ -178,7 +182,7 @@ STATIC ra_extproc(p)
|
|||
|
||||
|
||||
|
||||
STATIC ra_cleanproc(p)
|
||||
STATIC void ra_cleanproc(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* Allocate the extended data structures for procedure p */
|
||||
|
@ -199,7 +203,7 @@ STATIC ra_cleanproc(p)
|
|||
|
||||
|
||||
|
||||
STATIC loop_blocks(p)
|
||||
STATIC void loop_blocks(p)
|
||||
proc_p p;
|
||||
{
|
||||
/* Compute the LP_BLOCKS sets for all loops of p */
|
||||
|
@ -218,7 +222,7 @@ STATIC loop_blocks(p)
|
|||
|
||||
|
||||
|
||||
STATIC make_instrmap(p,map)
|
||||
STATIC void make_instrmap(p,map)
|
||||
proc_p p;
|
||||
line_p map[];
|
||||
{
|
||||
|
@ -253,7 +257,7 @@ STATIC bool useful_item(item)
|
|||
}
|
||||
|
||||
|
||||
STATIC cleantimeset(s)
|
||||
STATIC void cleantimeset(s)
|
||||
lset s;
|
||||
{
|
||||
register Lindex i;
|
||||
|
@ -300,7 +304,7 @@ STATIC item_p cat_items(items)
|
|||
|
||||
|
||||
|
||||
STATIC clean_interval(list)
|
||||
STATIC void clean_interval(list)
|
||||
interv_p list;
|
||||
{
|
||||
register interv_p x,next;
|
||||
|
@ -313,7 +317,7 @@ STATIC clean_interval(list)
|
|||
|
||||
|
||||
|
||||
STATIC clean_allocs(list)
|
||||
STATIC void clean_allocs(list)
|
||||
alloc_p list;
|
||||
{
|
||||
register alloc_p x,next;
|
||||
|
@ -331,7 +335,7 @@ STATIC clean_allocs(list)
|
|||
|
||||
|
||||
|
||||
STATIC cleanitems(list)
|
||||
STATIC void cleanitems(list)
|
||||
item_p list;
|
||||
{
|
||||
register item_p x,next;
|
||||
|
@ -390,13 +394,13 @@ void ra_optimize(void *vp)
|
|||
clean_allocs(unpacked);
|
||||
clean_allocs(packed);
|
||||
cleanitems(itemlist);
|
||||
oldmap(instrmap,nrinstrs-1);
|
||||
oldmap((void **) instrmap,nrinstrs-1);
|
||||
ra_cleanproc(p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
main(argc,argv)
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
|
@ -430,6 +434,10 @@ char *str_regtypes[] = {
|
|||
};
|
||||
|
||||
|
||||
/*
|
||||
* All calls to print_items() and print_allocs() are in comments!
|
||||
*/
|
||||
#if 0
|
||||
print_items(items,p)
|
||||
item_p items[];
|
||||
proc_p p;
|
||||
|
@ -510,10 +518,11 @@ print_allocs(list)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
short regs_needed[4];
|
||||
stat_regusage(list)
|
||||
STATIC short regs_needed[4];
|
||||
STATIC void stat_regusage(list)
|
||||
alloc_p list;
|
||||
{
|
||||
int i;
|
||||
|
@ -531,6 +540,10 @@ stat_regusage(list)
|
|||
|
||||
|
||||
|
||||
/*
|
||||
* All calls to statistics() are in comments!
|
||||
*/
|
||||
#if 0
|
||||
int cnt_regtypes[reg_float+1];
|
||||
|
||||
statistics(items)
|
||||
|
@ -557,3 +570,4 @@ statistics(items)
|
|||
fprintf(stderr, "#%s = %d\n",str_regtypes[r],cnt_regtypes[r]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "ra_allocl.h"
|
||||
#include "ra_interv.h"
|
||||
|
||||
STATIC count_usage(p,item,nrloops,sloopcnt,dloopcnt)
|
||||
STATIC void count_usage(p,item,nrloops,sloopcnt,dloopcnt)
|
||||
proc_p p;
|
||||
item_p item;
|
||||
short nrloops, sloopcnt[], dloopcnt[];
|
||||
|
@ -92,7 +92,7 @@ STATIC alloc_p cons_alloc(item,timespan,stat_usecount,
|
|||
}
|
||||
|
||||
|
||||
STATIC insert_alloc(alloc,list_p)
|
||||
STATIC void insert_alloc(alloc,list_p)
|
||||
alloc_p alloc, *list_p;
|
||||
{
|
||||
alloc->al_next = *list_p;
|
||||
|
@ -157,7 +157,7 @@ STATIC bblock_p init_point(item)
|
|||
}
|
||||
|
||||
|
||||
STATIC add_blocks(b,s,span)
|
||||
STATIC void add_blocks(b,s,span)
|
||||
bblock_p b;
|
||||
cset *s;
|
||||
interv_p *span;
|
||||
|
@ -176,7 +176,7 @@ STATIC add_blocks(b,s,span)
|
|||
|
||||
|
||||
|
||||
STATIC whole_lifetime(item,ini_out,span_out)
|
||||
STATIC void whole_lifetime(item,ini_out,span_out)
|
||||
item_p item;
|
||||
bblock_p *ini_out;
|
||||
interv_p *span_out;
|
||||
|
@ -267,12 +267,10 @@ STATIC short countuses(usage,b)
|
|||
|
||||
|
||||
|
||||
STATIC allocs_of_item(p,item,loops,sloopcnt,dloopcnt,alloc_list_p)
|
||||
proc_p p;
|
||||
item_p item;
|
||||
lset loops;
|
||||
short *sloopcnt,*dloopcnt; /* dynamic arrays */
|
||||
alloc_p *alloc_list_p;
|
||||
STATIC void
|
||||
allocs_of_item(proc_p p, item_p item, lset loops,
|
||||
short *sloopcnt, short *dloopcnt, /* dynamic arrays */
|
||||
alloc_p *alloc_list_p)
|
||||
{
|
||||
register Lindex li;
|
||||
loop_p lp;
|
||||
|
@ -328,10 +326,7 @@ STATIC allocs_of_item(p,item,loops,sloopcnt,dloopcnt,alloc_list_p)
|
|||
|
||||
|
||||
|
||||
alloc_p build_alloc_list(p,nrloops,itemlist)
|
||||
proc_p p;
|
||||
short nrloops;
|
||||
item_p itemlist;
|
||||
alloc_p build_alloc_list(proc_p p, short nrloops, item_p itemlist)
|
||||
{
|
||||
short *sloopcnt,*dloopcnt; /* dynamic arrays */
|
||||
register item_p item;
|
||||
|
@ -351,7 +346,7 @@ alloc_p build_alloc_list(p,nrloops,itemlist)
|
|||
|
||||
|
||||
|
||||
build_rivals_graph(alloclist)
|
||||
void build_rivals_graph(alloclist)
|
||||
alloc_p alloclist;
|
||||
{
|
||||
/* See which allocations in the list are rivals of each other,
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
* R A _ A L L O C L I S T . H
|
||||
*/
|
||||
|
||||
extern alloc_p build_alloc_list(); /* (proc_p p; short nrloops;
|
||||
* item_p itemlist)
|
||||
alloc_p build_alloc_list(proc_p p, short nrloops, item_p itemlist);
|
||||
/*
|
||||
* Build a list of possible allocations
|
||||
* for procedure p. An allocation
|
||||
* essentially is a pair (item,timespan)
|
||||
*/
|
||||
extern build_rivals_graph(); /* (alloc_p alloclist)
|
||||
void build_rivals_graph(alloc_p alloclist);
|
||||
/* See which allocations in the list are
|
||||
* rivals of each other, i.e. there is
|
||||
* some point of time, falling in both
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue