1994-06-24 11:31:16 +00:00
|
|
|
/* $Id$ */
|
1991-03-04 12:59:46 +00:00
|
|
|
|
1991-03-04 15:00:54 +00:00
|
|
|
/* Driver program for the global optimizer. It might even become the global
|
|
|
|
optimizer itself one day ...
|
|
|
|
*/
|
|
|
|
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
#include <stdarg.h>
|
2016-08-21 20:01:19 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <unistd.h>
|
1991-03-04 12:59:46 +00:00
|
|
|
#include <signal.h>
|
2016-08-21 20:01:19 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "em_path.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "print.h"
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
NONE = 0,
|
|
|
|
IC,
|
|
|
|
CF,
|
|
|
|
IL,
|
|
|
|
CS,
|
|
|
|
SR,
|
|
|
|
UD,
|
|
|
|
LV,
|
|
|
|
RA,
|
|
|
|
SP,
|
|
|
|
BO,
|
|
|
|
CJ,
|
|
|
|
CA
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const char* name;
|
|
|
|
bool needsdescr;
|
|
|
|
|
|
|
|
} phase_data[] = {
|
|
|
|
{},
|
|
|
|
{ "ic" },
|
|
|
|
{ "cf" },
|
|
|
|
{ "il" },
|
|
|
|
{ "cs", true },
|
|
|
|
{ "sr" },
|
|
|
|
{ "ud", true },
|
|
|
|
{ "lv" },
|
|
|
|
{ "ra" },
|
|
|
|
{ "sp" },
|
|
|
|
{ "bo" },
|
|
|
|
{ "cj" },
|
|
|
|
{ "ca" },
|
1991-03-04 12:59:46 +00:00
|
|
|
};
|
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
#define MAXUPHASES 64 /* max # of phases to be run */
|
|
|
|
#define MAXARGS 1024 /* mar # of args */
|
|
|
|
#define NTEMPS 4 /* # of temporary files; not tunable */
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2017-08-06 12:25:12 +00:00
|
|
|
static char tmpbase[] = TMP_DIR "/ego.XXXXXX";
|
2016-08-21 16:45:25 +00:00
|
|
|
static char ddump[128] = TMP_DIR; /* data label dump file */
|
|
|
|
static char pdump[128] = TMP_DIR; /* procedure name dump file */
|
|
|
|
static char tmpbufs[NTEMPS * 2][128] = {
|
|
|
|
TMP_DIR
|
1991-03-05 12:16:17 +00:00
|
|
|
};
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
static int O2phases[] = { /* Passes for -O2 */
|
|
|
|
CJ, BO, SP, 0
|
1991-03-04 12:59:46 +00:00
|
|
|
};
|
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
static int O3phases[] = { /* Passes for -O3 */
|
|
|
|
CS, SR, CJ, BO, SP, UD, LV, RA, 0
|
1991-03-04 12:59:46 +00:00
|
|
|
};
|
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
static int O4phases[] = { /* Passes for -O4 */
|
|
|
|
IL, CF, CS, SR, CJ, BO, SP, UD, LV, RA, 0
|
1991-03-04 12:59:46 +00:00
|
|
|
};
|
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
static int* Ophase = &O2phases[0]; /* default : -O2 */
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
static int nuphases; /* # of phases specified by user */
|
|
|
|
static int uphases[MAXUPHASES + 1]; /* phases to be run */
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
static int nfiles = NTEMPS * 2 + 1; /* leave space for tempfilenames */
|
|
|
|
static char* phargs[MAXARGS + 1];
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
static int keeptemps = 0;
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
static char** phase_args;
|
|
|
|
static int nphase_args;
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 20:01:19 +00:00
|
|
|
static const char* descr_file;
|
|
|
|
static const char* opt_dir;
|
|
|
|
static const char* prog_name;
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
static int v_flag;
|
1991-06-26 17:28:15 +00:00
|
|
|
|
1991-03-04 12:59:46 +00:00
|
|
|
static void
|
|
|
|
cleanup()
|
|
|
|
{
|
2016-08-21 16:45:25 +00:00
|
|
|
/* Cleanup temporaries */
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
if (!keeptemps)
|
|
|
|
{
|
|
|
|
register int i;
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
for (i = NTEMPS * 2; i > 0; i--)
|
|
|
|
{
|
2016-08-21 20:01:19 +00:00
|
|
|
const char* f = phargs[i];
|
2016-08-21 16:45:25 +00:00
|
|
|
if (f != 0 && *f != '\0' && *f != '-')
|
|
|
|
(void)unlink(f);
|
|
|
|
}
|
|
|
|
if (ddump[0] != '\0')
|
|
|
|
(void)unlink(ddump);
|
|
|
|
if (pdump[0] != '\0')
|
|
|
|
(void)unlink(pdump);
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
2017-08-06 12:25:12 +00:00
|
|
|
|
|
|
|
(void)unlink(tmpbase);
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*VARARGS1*/
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
static void fatal(const char *s, ...)
|
1991-03-04 12:59:46 +00:00
|
|
|
{
|
2016-08-21 16:45:25 +00:00
|
|
|
/* A fatal error occurred; exit gracefully */
|
|
|
|
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, s);
|
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
fprint(STDERR, "%s: ", prog_name);
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
doprnt(STDERR, s, ap);
|
2016-08-21 16:45:25 +00:00
|
|
|
fprint(STDERR, "\n");
|
|
|
|
cleanup();
|
|
|
|
sys_stop(S_EXIT);
|
|
|
|
/*NOTREACHED*/
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-21 16:45:25 +00:00
|
|
|
add_file(s) char* s;
|
1991-03-04 12:59:46 +00:00
|
|
|
{
|
2016-08-21 16:45:25 +00:00
|
|
|
/* Add an input file to the list */
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
if (nfiles >= MAXARGS)
|
|
|
|
fatal("too many files");
|
|
|
|
phargs[nfiles++] = s;
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-21 16:45:25 +00:00
|
|
|
add_uphase(p) int p;
|
1991-03-04 12:59:46 +00:00
|
|
|
{
|
2016-08-21 16:45:25 +00:00
|
|
|
/* Add an optimizer phase to the list of phases to run */
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
if (nuphases >= MAXUPHASES)
|
|
|
|
fatal("too many phases");
|
|
|
|
uphases[nuphases++] = p;
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
static void catch ()
|
1991-03-04 12:59:46 +00:00
|
|
|
{
|
2016-08-21 16:45:25 +00:00
|
|
|
/* Catch interrupts and exit gracefully */
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
cleanup();
|
|
|
|
sys_stop(S_EXIT);
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
old_infiles()
|
|
|
|
{
|
2016-08-21 16:45:25 +00:00
|
|
|
/* Remove old input files unless we have to keep them around. */
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
register int i;
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
if (phargs[1] == pdump || keeptemps)
|
|
|
|
return;
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
for (i = 1; i <= NTEMPS; i++)
|
|
|
|
(void)unlink(phargs[i]);
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_infiles()
|
|
|
|
{
|
2016-08-21 16:45:25 +00:00
|
|
|
/* Make output temps from previous phase input temps of next phase. */
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
register int i;
|
2016-08-21 20:01:19 +00:00
|
|
|
char** dst = &phargs[1];
|
|
|
|
char** src = &phargs[NTEMPS + 1];
|
1991-03-04 12:59:46 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
for (i = 1; i <= NTEMPS; i++)
|
|
|
|
{
|
|
|
|
*dst++ = *src++;
|
|
|
|
}
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
new_outfiles()
|
|
|
|
{
|
2016-08-21 16:45:25 +00:00
|
|
|
static int tmpindex = 0;
|
|
|
|
static int Bindex = 0;
|
|
|
|
static char dig1 = '1';
|
|
|
|
static char dig2 = '0';
|
|
|
|
register int i;
|
2016-08-21 20:01:19 +00:00
|
|
|
char** dst = &phargs[NTEMPS + 1];
|
2016-08-21 16:45:25 +00:00
|
|
|
|
|
|
|
if (!Bindex)
|
2017-08-06 12:25:12 +00:00
|
|
|
Bindex = strlen(tmpbufs[0]) - 2;
|
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
for (i = 1; i <= NTEMPS; i++)
|
|
|
|
{
|
|
|
|
*dst = tmpbufs[tmpindex];
|
|
|
|
(*dst)[Bindex - 1] = dig2;
|
|
|
|
(*dst)[Bindex] = dig1;
|
|
|
|
tmpindex++;
|
|
|
|
dst++;
|
|
|
|
}
|
|
|
|
if (tmpindex >= 2 * NTEMPS)
|
|
|
|
tmpindex = 0;
|
|
|
|
if (++dig1 > '9')
|
|
|
|
{
|
|
|
|
++dig2;
|
|
|
|
dig1 = '0';
|
|
|
|
}
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-21 16:45:25 +00:00
|
|
|
run_phase(phase) int phase;
|
1991-03-04 12:59:46 +00:00
|
|
|
{
|
2016-08-21 16:45:25 +00:00
|
|
|
/* Run one phase of the global optimizer; special cases are
|
1991-03-04 12:59:46 +00:00
|
|
|
IC and CA.
|
|
|
|
*/
|
2016-08-21 16:45:25 +00:00
|
|
|
static int flags_added;
|
|
|
|
register int argc;
|
|
|
|
register int i;
|
|
|
|
char buf[256];
|
|
|
|
int pid, status;
|
|
|
|
|
2016-08-21 20:01:19 +00:00
|
|
|
/* Skip this phase if it requires a descr file and one hasn't been
|
|
|
|
* provided. */
|
|
|
|
|
|
|
|
if (phase_data[phase].needsdescr && !descr_file)
|
|
|
|
return;
|
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
phargs[0] = buf;
|
|
|
|
(void)strcpy(buf, opt_dir);
|
|
|
|
(void)strcat(buf, "/");
|
2016-08-21 20:01:19 +00:00
|
|
|
(void)strcat(buf, phase_data[phase].name);
|
2016-08-21 16:45:25 +00:00
|
|
|
|
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case IC:
|
2016-08-21 20:01:19 +00:00
|
|
|
/* always first */
|
2016-08-21 16:45:25 +00:00
|
|
|
phargs[1] = pdump;
|
|
|
|
phargs[2] = ddump;
|
|
|
|
for (i = 3; i <= NTEMPS; i++)
|
|
|
|
phargs[i] = "-";
|
|
|
|
new_outfiles();
|
|
|
|
argc = nfiles;
|
|
|
|
phargs[argc] = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CA:
|
2016-08-21 20:01:19 +00:00
|
|
|
/* always last */
|
2016-08-21 16:45:25 +00:00
|
|
|
old_infiles();
|
|
|
|
get_infiles();
|
|
|
|
phargs[NTEMPS + 1] = pdump;
|
|
|
|
phargs[NTEMPS + 2] = ddump;
|
|
|
|
for (i = NTEMPS + 3; i <= 2 * NTEMPS; i++)
|
|
|
|
phargs[i] = "-";
|
|
|
|
argc = 2 * NTEMPS + 1;
|
|
|
|
phargs[argc] = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-08-21 20:01:19 +00:00
|
|
|
{
|
2016-08-21 16:45:25 +00:00
|
|
|
old_infiles();
|
|
|
|
get_infiles();
|
|
|
|
new_outfiles();
|
2016-08-21 20:01:19 +00:00
|
|
|
|
|
|
|
argc = 2 * NTEMPS + 1;
|
|
|
|
if (descr_file)
|
2016-08-21 16:45:25 +00:00
|
|
|
{
|
2016-08-21 20:01:19 +00:00
|
|
|
phargs[argc++] = "-M";
|
|
|
|
phargs[argc++] = descr_file;
|
2016-08-21 16:45:25 +00:00
|
|
|
}
|
2017-08-06 11:22:05 +00:00
|
|
|
|
2016-08-21 20:01:19 +00:00
|
|
|
for (i=0; i<nphase_args; i++)
|
|
|
|
phargs[argc++] = phase_args[i];
|
|
|
|
|
|
|
|
phargs[argc] = NULL;
|
2016-08-21 16:45:25 +00:00
|
|
|
break;
|
2016-08-21 20:01:19 +00:00
|
|
|
}
|
1991-06-26 17:28:15 +00:00
|
|
|
}
|
2016-08-21 16:45:25 +00:00
|
|
|
if ((pid = fork()) < 0)
|
|
|
|
{
|
|
|
|
fatal("Could not fork");
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
2016-08-21 16:45:25 +00:00
|
|
|
else if (pid == 0)
|
|
|
|
{
|
|
|
|
if (v_flag)
|
|
|
|
{
|
|
|
|
register int i = 0;
|
|
|
|
|
|
|
|
while (phargs[i])
|
|
|
|
{
|
|
|
|
fprint(STDERR, "%s ", phargs[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
fprint(STDERR, "\n");
|
|
|
|
}
|
|
|
|
(void)execv(phargs[0], phargs);
|
|
|
|
fatal("Could not exec %s", phargs[0]);
|
1991-03-04 12:59:46 +00:00
|
|
|
sys_stop(S_EXIT);
|
|
|
|
}
|
2016-08-21 16:45:25 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
while (wait(&status) != pid) /* nothing */
|
|
|
|
;
|
|
|
|
if ((status & 0177) != 0)
|
|
|
|
{
|
|
|
|
fatal("%s got a unix signal", phargs[0]);
|
|
|
|
}
|
|
|
|
if (((status >> 8) & 0377) != 0)
|
|
|
|
{
|
|
|
|
cleanup();
|
|
|
|
sys_stop(S_EXIT);
|
|
|
|
}
|
|
|
|
}
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
|
|
|
|
2016-08-21 20:01:19 +00:00
|
|
|
int main(int argc, char* argv[])
|
1991-03-04 12:59:46 +00:00
|
|
|
{
|
2016-08-21 20:01:19 +00:00
|
|
|
int opt;
|
|
|
|
int i;
|
2016-08-21 16:45:25 +00:00
|
|
|
|
|
|
|
if (signal(SIGHUP, catch) == SIG_IGN)
|
|
|
|
(void)signal(SIGHUP, SIG_IGN);
|
|
|
|
if (signal(SIGQUIT, catch) == SIG_IGN)
|
|
|
|
(void)signal(SIGQUIT, SIG_IGN);
|
|
|
|
if (signal(SIGINT, catch) == SIG_IGN)
|
|
|
|
(void)signal(SIGINT, SIG_IGN);
|
|
|
|
prog_name = argv[0];
|
2016-08-21 20:01:19 +00:00
|
|
|
|
|
|
|
nphase_args = 0;
|
2016-08-21 16:45:25 +00:00
|
|
|
phase_args = &argv[1];
|
2016-08-21 20:01:19 +00:00
|
|
|
|
|
|
|
opterr = 0;
|
|
|
|
for (;;)
|
2016-08-21 16:45:25 +00:00
|
|
|
{
|
2017-10-30 02:00:43 +00:00
|
|
|
int opt = getopt(argc, argv, "M:P:O:vt");
|
2016-08-21 20:01:19 +00:00
|
|
|
if (opt == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (opt)
|
2016-08-21 16:45:25 +00:00
|
|
|
{
|
2016-08-21 20:01:19 +00:00
|
|
|
case 'M':
|
|
|
|
descr_file = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'P':
|
|
|
|
opt_dir = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'O':
|
2016-08-21 16:45:25 +00:00
|
|
|
{
|
2016-08-21 20:01:19 +00:00
|
|
|
int o = atoi(optarg);
|
|
|
|
if (o <= 2)
|
2017-10-30 02:00:43 +00:00
|
|
|
Ophase = &O2phases[0];
|
|
|
|
else if (o == 3)
|
2016-08-21 20:01:19 +00:00
|
|
|
Ophase = &O3phases[0];
|
2017-10-30 02:00:43 +00:00
|
|
|
else
|
|
|
|
Ophase = &O4phases[0];
|
2016-08-21 20:01:19 +00:00
|
|
|
break;
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
2016-08-21 20:01:19 +00:00
|
|
|
|
|
|
|
case 't':
|
|
|
|
keeptemps = 1;
|
|
|
|
goto addopt;
|
|
|
|
|
|
|
|
case 'v':
|
|
|
|
v_flag = 1;
|
|
|
|
goto addopt;
|
|
|
|
|
|
|
|
case '?':
|
|
|
|
addopt:
|
|
|
|
phase_args[nphase_args++] = argv[optind - 1];
|
|
|
|
break;
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-21 20:01:19 +00:00
|
|
|
|
2017-10-30 02:00:43 +00:00
|
|
|
for (i = optind; i < argc; i++)
|
|
|
|
add_file(argv[i]);
|
|
|
|
|
2016-08-21 20:01:19 +00:00
|
|
|
phase_args[nphase_args] = 0;
|
2016-08-21 16:45:25 +00:00
|
|
|
if (nuphases)
|
|
|
|
Ophase = uphases;
|
|
|
|
|
|
|
|
if (nfiles == 2 * NTEMPS + 1)
|
|
|
|
{
|
|
|
|
/* 2*NTEMPS+1 was the starting value; nothing to do */
|
|
|
|
sys_stop(S_END);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!opt_dir)
|
|
|
|
{
|
|
|
|
fatal("no correct -P flag given");
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|
|
|
|
|
2017-08-06 12:25:12 +00:00
|
|
|
close(mkstemp(tmpbase));
|
|
|
|
strcpy(ddump, tmpbase);
|
|
|
|
strcpy(pdump, tmpbase);
|
|
|
|
strcpy(tmpbufs[0], tmpbase);
|
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
if (keeptemps)
|
|
|
|
{
|
|
|
|
(void)strcpy(ddump, ".");
|
|
|
|
(void)strcpy(pdump, ".");
|
|
|
|
(void)strcpy(tmpbufs[0], ".");
|
|
|
|
}
|
2017-08-06 12:25:12 +00:00
|
|
|
(void)strcat(ddump, "dd");
|
|
|
|
(void)strcat(pdump, "pd");
|
|
|
|
|
|
|
|
(void)strcat(tmpbufs[0], "A.BB");
|
|
|
|
for (i=1; i<(2 * NTEMPS); i++)
|
2016-08-21 16:45:25 +00:00
|
|
|
(void)strcpy(tmpbufs[i], tmpbufs[0]);
|
2017-08-06 12:25:12 +00:00
|
|
|
|
|
|
|
i = strlen(tmpbufs[0]) - 4;
|
2016-08-21 16:45:25 +00:00
|
|
|
tmpbufs[0][i] = 'p';
|
|
|
|
tmpbufs[NTEMPS + 0][i] = 'p';
|
|
|
|
tmpbufs[1][i] = 'd';
|
|
|
|
tmpbufs[NTEMPS + 1][i] = 'd';
|
|
|
|
tmpbufs[2][i] = 'l';
|
|
|
|
tmpbufs[NTEMPS + 2][i] = 'l';
|
|
|
|
tmpbufs[3][i] = 'b';
|
|
|
|
tmpbufs[NTEMPS + 3][i] = 'b';
|
2017-08-06 12:25:12 +00:00
|
|
|
|
2016-08-21 16:45:25 +00:00
|
|
|
run_phase(IC);
|
|
|
|
run_phase(CF);
|
|
|
|
while (*Ophase)
|
|
|
|
{
|
|
|
|
run_phase(*Ophase++);
|
|
|
|
}
|
|
|
|
run_phase(CA);
|
|
|
|
cleanup();
|
1991-03-04 12:59:46 +00:00
|
|
|
sys_stop(S_END);
|
2016-08-21 16:45:25 +00:00
|
|
|
/*NOTREACHED*/
|
1991-03-04 12:59:46 +00:00
|
|
|
}
|