2019-05-10 17:17:40 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*
|
|
|
|
* Author: Hans van Staveren
|
|
|
|
*/
|
2017-11-10 03:22:13 +00:00
|
|
|
#include <assert.h>
|
1984-05-17 13:42:36 +00:00
|
|
|
#include "param.h"
|
|
|
|
#include "types.h"
|
|
|
|
#include "line.h"
|
1990-09-04 16:42:43 +00:00
|
|
|
#include "tes.h"
|
1984-05-17 13:42:36 +00:00
|
|
|
#include "proinf.h"
|
|
|
|
#include "alloc.h"
|
2019-05-10 17:17:40 +00:00
|
|
|
#include "putline.h"
|
|
|
|
#include "reg.h"
|
1988-09-12 09:13:49 +00:00
|
|
|
#include <em_spec.h>
|
|
|
|
#include <em_pseu.h>
|
|
|
|
#include <em_mes.h>
|
1984-05-17 13:42:36 +00:00
|
|
|
#include "ext.h"
|
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
void regvar(register arg_p ap)
|
|
|
|
{
|
1984-05-17 13:42:36 +00:00
|
|
|
register reg_p rp;
|
2019-05-10 17:17:40 +00:00
|
|
|
register int i;
|
1984-05-17 13:42:36 +00:00
|
|
|
|
|
|
|
rp = newreg();
|
2019-05-10 17:17:40 +00:00
|
|
|
i = 0;
|
|
|
|
while (ap != (arg_p) 0 && ap->a_typ == ARGOFF && i < 4)
|
|
|
|
{
|
|
|
|
rp->r_par[i++] = ap->a_a.a_offset;
|
|
|
|
ap = ap->a_next;
|
1984-05-17 13:42:36 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Omit incomplete messages
|
|
|
|
*/
|
2019-05-10 17:17:40 +00:00
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
assert(FALSE);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
oldreg(rp);
|
|
|
|
return;
|
|
|
|
case 3:
|
|
|
|
rp->r_par[3] = (offset) 0;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
break;
|
1984-05-17 13:42:36 +00:00
|
|
|
}
|
|
|
|
rp->r_next = curpro.freg;
|
|
|
|
curpro.freg = rp;
|
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
int inreg(offset off)
|
|
|
|
{
|
1984-05-17 13:42:36 +00:00
|
|
|
register reg_p rp;
|
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
for (rp = curpro.freg; rp != (reg_p) 0; rp = rp->r_next)
|
|
|
|
if (rp->r_par[0] == off)
|
|
|
|
return (TRUE);
|
|
|
|
return (FALSE);
|
1984-05-17 13:42:36 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
void outregs(void)
|
|
|
|
{
|
|
|
|
register reg_p rp, tp;
|
|
|
|
register int i;
|
1984-05-17 13:42:36 +00:00
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
for (rp = curpro.freg; rp != (reg_p) 0; rp = tp)
|
|
|
|
{
|
1984-05-17 13:42:36 +00:00
|
|
|
tp = rp->r_next;
|
1989-06-05 15:47:53 +00:00
|
|
|
outinst(ps_mes);
|
2019-05-10 17:17:40 +00:00
|
|
|
outoff((offset) ms_reg);
|
|
|
|
for (i = 0; i < 4; i++)
|
1989-06-05 15:47:53 +00:00
|
|
|
outoff(rp->r_par[i]);
|
|
|
|
outinst(sp_cend);
|
1984-05-17 13:42:36 +00:00
|
|
|
oldreg(rp);
|
|
|
|
}
|
1984-05-17 13:56:00 +00:00
|
|
|
/* List of register messages is followed by an empty ms_reg
|
|
|
|
* unless an ms_gto was in this procedure, then the ms_gto
|
|
|
|
* will be output. Kludgy.
|
|
|
|
*/
|
1984-05-17 13:42:36 +00:00
|
|
|
outinst(ps_mes);
|
2019-05-10 17:17:40 +00:00
|
|
|
outoff((offset) (curpro.gtoproc ? ms_gto : ms_reg));
|
1984-05-17 13:42:36 +00:00
|
|
|
outinst(sp_cend);
|
|
|
|
curpro.freg = (reg_p) 0;
|
|
|
|
}
|
|
|
|
|
1990-09-04 16:42:43 +00:00
|
|
|
/* outtes() handles the output of the top elt. messages */
|
2019-05-10 17:17:40 +00:00
|
|
|
void outtes(void)
|
|
|
|
{
|
1991-01-31 15:17:04 +00:00
|
|
|
register num_p *npp, np;
|
1990-07-18 14:33:07 +00:00
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
for (npp = curpro.numhash; npp < &curpro.numhash[NNUMHASH]; npp++)
|
|
|
|
{
|
|
|
|
for (np = *npp; np != (num_p) 0; np = np->n_next)
|
|
|
|
{
|
|
|
|
if (!(np->n_flags & NUMSET) || np->n_size == 0
|
|
|
|
|| (np->n_flags & NUMCOND))
|
|
|
|
continue;
|
1990-09-04 16:42:43 +00:00
|
|
|
outinst(ps_mes);
|
2019-05-10 17:17:40 +00:00
|
|
|
outoff((offset) ms_tes);
|
|
|
|
outoff((offset) np->n_number);
|
|
|
|
outoff((offset) np->n_size);
|
|
|
|
outoff((offset) ((np->n_flags & NUMFALLTHROUGH) ? 1 : 0));
|
1990-09-04 16:42:43 +00:00
|
|
|
outinst(sp_cend);
|
|
|
|
}
|
1990-07-18 14:33:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
void incregusage(offset off)
|
|
|
|
{
|
1984-05-17 13:42:36 +00:00
|
|
|
register reg_p rp;
|
|
|
|
|
1984-09-14 10:25:07 +00:00
|
|
|
#ifndef GLOBAL_OPT
|
|
|
|
/* If we're optimizing the output of the global optimizer
|
|
|
|
* we must not change the count fields of the register messages.
|
|
|
|
*/
|
2019-05-10 17:17:40 +00:00
|
|
|
for (rp = curpro.freg; rp != (reg_p) 0; rp = rp->r_next)
|
|
|
|
if (rp->r_par[0] == off)
|
|
|
|
{
|
1984-05-17 13:42:36 +00:00
|
|
|
rp->r_par[3]++;
|
|
|
|
return;
|
|
|
|
}
|
1984-09-14 10:25:07 +00:00
|
|
|
#endif
|
1984-05-17 13:42:36 +00:00
|
|
|
}
|