1987-03-09 19:15:41 +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".
|
|
|
|
*/
|
1985-01-08 09:59:28 +00:00
|
|
|
#ifndef NORCSID
|
2019-05-10 17:17:24 +00:00
|
|
|
static char rcsid[] = "$Id$";
|
1985-01-08 09:59:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "param.h"
|
|
|
|
#include "property.h"
|
|
|
|
#include "set.h"
|
|
|
|
#include "token.h"
|
|
|
|
#include "lookup.h"
|
1987-01-26 16:16:12 +00:00
|
|
|
#include "reg.h"
|
2019-05-10 17:17:24 +00:00
|
|
|
#include "subr.h"
|
1985-01-08 09:59:28 +00:00
|
|
|
#include <cgg_cg.h>
|
|
|
|
#include "extern.h"
|
|
|
|
|
|
|
|
extern set_t l_sets[];
|
2019-05-10 17:17:24 +00:00
|
|
|
set_t emptyset;
|
|
|
|
|
1985-01-08 09:59:28 +00:00
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
int setlookup(set_t s)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
register set_p p;
|
2019-05-10 17:17:24 +00:00
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
int setno;
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
for (p = l_sets; p < &l_sets[nsets]; p++)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
if (p->set_size != s.set_size)
|
|
|
|
continue;
|
2019-05-10 17:17:24 +00:00
|
|
|
for (i = 0; i < SETSIZE; i++)
|
1985-01-08 09:59:28 +00:00
|
|
|
if (p->set_val[i] != s.set_val[i])
|
|
|
|
goto cont;
|
2019-05-10 17:17:24 +00:00
|
|
|
return (p - l_sets);
|
|
|
|
cont: ;
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
2019-05-10 17:17:24 +00:00
|
|
|
setno = NEXT(nsets, MAXSETS, "Sets");
|
1985-01-08 09:59:28 +00:00
|
|
|
l_sets[setno] = s;
|
2019-05-10 17:17:24 +00:00
|
|
|
return (setno);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
void make_std_sets(void)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
set_t s;
|
2019-05-10 17:17:24 +00:00
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
for (i = 0; i < SETSIZE; i++)
|
|
|
|
s.set_val[i] = 0;
|
|
|
|
for (i = 0; i < nregs + ntokens; i++)
|
|
|
|
BIS(s.set_val, i);
|
1985-01-08 09:59:28 +00:00
|
|
|
s.set_size = 0;
|
|
|
|
allsetno = setlookup(s);
|
2019-05-10 17:17:24 +00:00
|
|
|
n_set("ALL", allsetno);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
set_t ident_to_set(char *name)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
register symbol *sy_p;
|
2019-05-10 17:17:24 +00:00
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
register struct propinfo *pp;
|
|
|
|
int bitno;
|
|
|
|
set_t result;
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
sy_p = lookup(name, symany, mustexist);
|
|
|
|
switch (sy_p->sy_type)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
error("%s is wrong kind of symbol", name);
|
|
|
|
return (emptyset);
|
|
|
|
case symprop:
|
|
|
|
pp = &l_props[sy_p->sy_value.syv_propno];
|
|
|
|
result.set_size = pp->pr_size;
|
|
|
|
for (i = 0; i < SZOFSET(MAXREGS); i++)
|
|
|
|
result.set_val[i] = pp->pr_regset[i];
|
|
|
|
BIS(result.set_val, 0);
|
|
|
|
for (; i < SETSIZE; i++)
|
|
|
|
result.set_val[i] = 0;
|
|
|
|
break;
|
|
|
|
case symtok:
|
|
|
|
bitno = sy_p->sy_value.syv_tokno + nregs;
|
|
|
|
for (i = 0; i < SETSIZE; i++)
|
|
|
|
result.set_val[i] = 0;
|
|
|
|
BIS(result.set_val, bitno);
|
|
|
|
result.set_size = l_tokens[sy_p->sy_value.syv_tokno]->tk_size;
|
|
|
|
break;
|
|
|
|
case symset:
|
|
|
|
return (l_sets[sy_p->sy_value.syv_setno]);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
2019-05-10 17:17:24 +00:00
|
|
|
return (result);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
static void checksize(register set_p s)
|
1987-01-26 16:16:12 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
register int size = -1;
|
|
|
|
|
|
|
|
s->set_size = 0;
|
2019-05-10 17:17:24 +00:00
|
|
|
for (i = 1; i <= nregs; i++)
|
|
|
|
{
|
|
|
|
if (BIT(s->set_val, i))
|
|
|
|
{
|
1987-01-26 16:16:12 +00:00
|
|
|
register int sz = l_regs[i].ri_size;
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
if (size == -1)
|
|
|
|
size = sz;
|
|
|
|
else if (size != sz)
|
|
|
|
return;
|
1987-01-26 16:16:12 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-10 17:17:24 +00:00
|
|
|
for (i = 1; i <= ntokens; i++)
|
|
|
|
{
|
|
|
|
if (BIT(s->set_val, i + nregs))
|
|
|
|
{
|
1987-01-26 16:16:12 +00:00
|
|
|
register int sz = l_tokens[i]->tk_size;
|
2019-05-10 17:17:24 +00:00
|
|
|
if (size == -1)
|
|
|
|
size = sz;
|
|
|
|
else if (size != sz)
|
|
|
|
return;
|
1987-01-26 16:16:12 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-10 17:17:24 +00:00
|
|
|
if (size != -1)
|
|
|
|
s->set_size = size;
|
1987-01-26 16:16:12 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
set_t setproduct(set_t s1, set_t s2)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
set_t result;
|
2019-05-10 17:17:24 +00:00
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
for (i = 0; i < SETSIZE; i++)
|
1985-01-08 09:59:28 +00:00
|
|
|
result.set_val[i] = s1.set_val[i] & s2.set_val[i];
|
1987-01-26 16:16:12 +00:00
|
|
|
checksize(&result);
|
2019-05-10 17:17:24 +00:00
|
|
|
return (result);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
set_t setsum(set_t s1, set_t s2)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
set_t result;
|
2019-05-10 17:17:24 +00:00
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
|
|
|
|
if (s1.set_size == s2.set_size)
|
|
|
|
result.set_size = s1.set_size;
|
|
|
|
else
|
|
|
|
result.set_size = 0;
|
2019-05-10 17:17:24 +00:00
|
|
|
for (i = 0; i < SETSIZE; i++)
|
1985-01-08 09:59:28 +00:00
|
|
|
result.set_val[i] = s1.set_val[i] | s2.set_val[i];
|
2019-05-10 17:17:24 +00:00
|
|
|
return (result);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
set_t setdiff(set_t s1, set_t s2)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
set_t result;
|
2019-05-10 17:17:24 +00:00
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
for (i = 0; i < SETSIZE; i++)
|
|
|
|
result.set_val[i] = s1.set_val[i] & ~s2.set_val[i];
|
1987-01-16 13:51:42 +00:00
|
|
|
/* make sure that we don't loose the lowest bit of the set, which
|
2019-05-10 17:17:24 +00:00
|
|
|
indicates that it contains registers
|
|
|
|
*/
|
|
|
|
for (i = 1; i <= nregs; i++)
|
|
|
|
{
|
|
|
|
if (BIT(result.set_val, i))
|
|
|
|
{
|
|
|
|
BIS(result.set_val, 0);
|
1987-01-16 13:51:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1987-01-26 16:16:12 +00:00
|
|
|
checksize(&result);
|
2019-05-10 17:17:24 +00:00
|
|
|
return (result);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|