ego now builds and is used.
This needed lots of refactoring to ego --- not all platforms have ego descr files, and ego will just crash if you invoke it without one. I think originally it was never intended that these platforms would be used at -O2 or above. Plats now only specify the ego descr file if they have one.
This commit is contained in:
@@ -9,9 +9,45 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "files.h"
|
||||
|
||||
FILE *openfile(name,mode)
|
||||
char *name,*mode;
|
||||
struct files* findfiles(int argc, const char** argv)
|
||||
{
|
||||
static struct files files;
|
||||
|
||||
/* The names of the input files of every phase are passed as
|
||||
* arguments to the phase. First come the input file names,
|
||||
* then the output file names. We use a one-letter convention
|
||||
* to denote the type of file:
|
||||
* p: procedure table file
|
||||
* d: data table file
|
||||
* l: EM text file (lines of EM instructions)
|
||||
* b: basic block file (Control Flow Graph file)
|
||||
*/
|
||||
|
||||
/* The input file names */
|
||||
|
||||
files.pname_in = argv[1];
|
||||
files.dname_in = argv[2];
|
||||
files.lname_in = argv[3];
|
||||
files.bname_in = argv[4];
|
||||
|
||||
/* The output file names */
|
||||
|
||||
files.pname_out = argv[5];
|
||||
files.dname_out = argv[6];
|
||||
files.lname_out = argv[7];
|
||||
files.bname_out = argv[8];
|
||||
|
||||
/* The rest of the arguments. */
|
||||
|
||||
files.argv = argv + 8;
|
||||
files.argc = argc - 8;
|
||||
|
||||
return &files;
|
||||
}
|
||||
|
||||
FILE *openfile(char* name, char* mode)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
|
||||
@@ -15,21 +15,29 @@
|
||||
* b: basic block file (Control Flow Graph file)
|
||||
*/
|
||||
|
||||
/* The input file names */
|
||||
struct files
|
||||
{
|
||||
/* Input files */
|
||||
|
||||
#define pname argv[1]
|
||||
#define dname argv[2]
|
||||
#define lname argv[3]
|
||||
#define bname argv[4]
|
||||
const char* pname_in;
|
||||
const char* dname_in;
|
||||
const char* lname_in;
|
||||
const char* bname_in;
|
||||
|
||||
/* The output file names */
|
||||
/* Output files */
|
||||
|
||||
#define pname2 argv[5]
|
||||
#define dname2 argv[6]
|
||||
#define lname2 argv[7]
|
||||
#define bname2 argv[8]
|
||||
const char* pname_out;
|
||||
const char* dname_out;
|
||||
const char* lname_out;
|
||||
const char* bname_out;
|
||||
|
||||
#define ARGSTART 9
|
||||
/* The rest of the arguments. */
|
||||
|
||||
const char** argv;
|
||||
int argc;
|
||||
};
|
||||
|
||||
extern struct files* findfiles(int argc, const char** argv);
|
||||
|
||||
extern FILE *openfile(); /* (char *name, *mode)
|
||||
* Open a file with the given name
|
||||
|
||||
@@ -10,24 +10,24 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "types.h"
|
||||
#include "debug.h"
|
||||
#include "global.h"
|
||||
#include "files.h"
|
||||
#include "get.h"
|
||||
#include "put.h"
|
||||
#include "lset.h"
|
||||
#include "map.h"
|
||||
#include "alloc.h"
|
||||
#include "go.h"
|
||||
#include "files.h"
|
||||
|
||||
STATIC bool report_flag = FALSE; /* report #optimizations found? */
|
||||
#ifdef DEBUG
|
||||
STATIC bool core_flag = FALSE; /* report core usage? */
|
||||
#endif
|
||||
|
||||
STATIC mach_init(machfile, phase_machinit) char* machfile;
|
||||
int (*phase_machinit)();
|
||||
static mach_init(char* machfile, int (*phase_machinit)())
|
||||
{
|
||||
/* Read target machine dependent information */
|
||||
|
||||
@@ -42,13 +42,10 @@ int (*phase_machinit)();
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
go(argc, argv, initialize, optimize, phase_machinit, proc_flag) int argc;
|
||||
char* argv[];
|
||||
int (*initialize)();
|
||||
int (*optimize)();
|
||||
int (*phase_machinit)();
|
||||
int (*proc_flag)();
|
||||
void go(int argc, const char** argv,
|
||||
int (*initialize)(), int (*optimize)(), int (*phase_machinit)(), int (*proc_flag)())
|
||||
{
|
||||
struct files* files = findfiles(argc, argv);
|
||||
FILE* f, *gf, *f2, *gf2; /* The EM input and output and
|
||||
* the basic block graphs input and output
|
||||
*/
|
||||
@@ -60,49 +57,56 @@ int (*proc_flag)();
|
||||
bool time_opt = TRUE;
|
||||
|
||||
linecount = 0;
|
||||
for (i = ARGSTART; i < argc; i++)
|
||||
opterr = 0;
|
||||
for (;;)
|
||||
{
|
||||
p = argv[i];
|
||||
if (*p++ != '-')
|
||||
error("illegal argument");
|
||||
switch (*p)
|
||||
int opt = getopt(files->argc, files->argv, "STM:CQV");
|
||||
if (opt == -1)
|
||||
break;
|
||||
|
||||
switch (opt)
|
||||
{
|
||||
case 'S':
|
||||
time_opt = FALSE;
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
time_opt = TRUE;
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
p++;
|
||||
mach_init(p, phase_machinit);
|
||||
mach_init(optarg, phase_machinit);
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
#ifdef DEBUG
|
||||
core_flag = TRUE;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 'Q':
|
||||
report_flag = TRUE;
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
verbose_flag = TRUE;
|
||||
break;
|
||||
default:
|
||||
(*proc_flag)(p);
|
||||
|
||||
case '?':
|
||||
proc_flag(argv[optind - 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
time_space_ratio = (time_opt ? 100 : 0);
|
||||
fproc = getptable(pname); /* proc table */
|
||||
fdblock = getdtable(dname); /* data block table */
|
||||
fproc = getptable(files->pname_in); /* proc table */
|
||||
fdblock = getdtable(files->dname_in); /* data block table */
|
||||
(*initialize)();
|
||||
if (optimize == no_action)
|
||||
return;
|
||||
f = openfile(lname, "r");
|
||||
gf = openfile(bname, "r");
|
||||
f2 = openfile(lname2, "w");
|
||||
gf2 = openfile(bname2, "w");
|
||||
f = openfile(files->lname_in, "r");
|
||||
gf = openfile(files->bname_in, "r");
|
||||
f2 = openfile(files->lname_out, "w");
|
||||
gf2 = openfile(files->bname_out, "w");
|
||||
mesregs = Lempty_set();
|
||||
while (getunit(gf, f, &kind, &g, &l, &curproc, TRUE))
|
||||
{
|
||||
@@ -130,18 +134,18 @@ int (*proc_flag)();
|
||||
fclose(f2);
|
||||
fclose(gf);
|
||||
fclose(gf2);
|
||||
f = openfile(dname2, "w");
|
||||
f = openfile(files->dname_out, "w");
|
||||
putdtable(fdblock, f);
|
||||
/* fclose(f); done by putdtable */
|
||||
f = openfile(pname2, "w");
|
||||
f = openfile(files->pname_out, "w");
|
||||
putptable(fproc, f, TRUE);
|
||||
/* fclose(f); done by putptable */
|
||||
core_usage();
|
||||
}
|
||||
|
||||
no_action() {}
|
||||
int no_action() {}
|
||||
|
||||
core_usage()
|
||||
void core_usage(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (core_flag)
|
||||
@@ -151,8 +155,7 @@ core_usage()
|
||||
#endif
|
||||
}
|
||||
|
||||
report(s, n) char* s;
|
||||
int n;
|
||||
void report(char* s, int n)
|
||||
{
|
||||
/* Report number of optimizations found, if report_flag is set */
|
||||
|
||||
|
||||
@@ -9,30 +9,33 @@
|
||||
*
|
||||
*/
|
||||
|
||||
extern go(); /* ( int argc; char *argv[];
|
||||
* int (*initialize)(); int (*optimize)();
|
||||
* int (*phase_machinit)(); int (*proc_flag)() )
|
||||
* This is the main driving routine of the optimizer.
|
||||
* It first processes the flags given as argument;
|
||||
* for every flag it does not recognize itself, it
|
||||
* calls 'proc_flag'; as soon as the -M flag is seen,
|
||||
* it opens the machine descriptor file and
|
||||
* reads phase-independend information (notably the
|
||||
* wordsize and pointersize of the target machine);
|
||||
* next it calls 'phase_machinit' with this file as
|
||||
* parameter. Subsequently it calls 'initialize'.
|
||||
* Finally, all procedures are read, one at a time,
|
||||
* and 'optimize' is called with the current procedure
|
||||
* as parameter.
|
||||
*/
|
||||
extern no_action(); /* ()
|
||||
* Parameter to be supplied for e.g. 'initialize' if
|
||||
* no action is required.
|
||||
*/
|
||||
extern core_usage(); /* ()
|
||||
* Report core usage, if core_flag is set.
|
||||
*/
|
||||
extern report(); /* ( char *s; int n)
|
||||
* Report number of optimizations found, if
|
||||
* report_flag is set
|
||||
*/
|
||||
/* This is the main driving routine of the optimizer.
|
||||
* It first processes the flags given as argument;
|
||||
* for every flag it does not recognize itself, it
|
||||
* calls 'proc_flag'; as soon as the -M flag is seen,
|
||||
* it opens the machine descriptor file and
|
||||
* reads phase-independend information (notably the
|
||||
* wordsize and pointersize of the target machine);
|
||||
* next it calls 'phase_machinit' with this file as
|
||||
* parameter. Subsequently it calls 'initialize'.
|
||||
* Finally, all procedures are read, one at a time,
|
||||
* and 'optimize' is called with the current procedure
|
||||
* as parameter.
|
||||
*/
|
||||
extern void go(int argc, const char** argv,
|
||||
int (*initialize)(), int (*optimize)(),
|
||||
int (*phase_machinit)(), int (*proc_flag)());
|
||||
|
||||
/*
|
||||
* Parameter to be supplied for e.g. 'initialize' if
|
||||
* no action is required.
|
||||
*/
|
||||
extern int no_action();
|
||||
|
||||
/* Report core usage, if core_flag is set. */
|
||||
extern void core_usage(void);
|
||||
|
||||
/* Report number of optimizations found, if
|
||||
* report_flag is set
|
||||
*/
|
||||
extern void report(char* s, int n);
|
||||
|
||||
Reference in New Issue
Block a user