1984-05-19 11:42:19 +00:00
|
|
|
#ifndef NORCSID
|
1994-06-24 14:02:31 +00:00
|
|
|
static char rcsid[] = "$Id$";
|
1984-05-19 11:42:19 +00:00
|
|
|
#endif
|
|
|
|
|
1984-05-18 21:27:39 +00:00
|
|
|
#include "assert.h"
|
|
|
|
#include "equiv.h"
|
|
|
|
#include "param.h"
|
|
|
|
#include "tables.h"
|
|
|
|
#include "types.h"
|
|
|
|
#include <cg_pattern.h>
|
|
|
|
#include "data.h"
|
|
|
|
#include "result.h"
|
|
|
|
#include "extern.h"
|
|
|
|
|
|
|
|
/*
|
1987-03-10 01:26:51 +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".
|
1984-05-18 21:27:39 +00:00
|
|
|
*
|
|
|
|
* Author: Hans van Staveren
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern string myalloc();
|
|
|
|
|
|
|
|
int rar[MAXCREG];
|
2018-06-02 19:31:18 +00:00
|
|
|
rl_p* lar;
|
1984-05-18 21:27:39 +00:00
|
|
|
int maxindex;
|
|
|
|
int regclass[NREGS];
|
2018-06-02 19:31:18 +00:00
|
|
|
struct perm* perms;
|
1984-05-18 21:27:39 +00:00
|
|
|
|
2018-06-02 19:31:18 +00:00
|
|
|
void permute(int index);
|
|
|
|
|
|
|
|
struct perm* tuples(rl_p* regls, int nregneeded)
|
|
|
|
{
|
|
|
|
int class = 0;
|
|
|
|
register i, j;
|
1984-05-18 21:27:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First compute equivalence classes of registers.
|
|
|
|
*/
|
|
|
|
|
2018-06-02 19:31:18 +00:00
|
|
|
for (i = 0; i < NREGS; i++)
|
|
|
|
{
|
|
|
|
regclass[i] = class ++;
|
|
|
|
if (getrefcount(i, FALSE) == 0)
|
|
|
|
{
|
|
|
|
for (j = 0; j < i; j++)
|
|
|
|
{
|
|
|
|
if (eqregclass(i, j) && eqtoken(&machregs[i].r_contents,
|
|
|
|
&machregs[j].r_contents))
|
|
|
|
{
|
1984-05-18 21:27:39 +00:00
|
|
|
regclass[i] = regclass[j];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now create tuples through a recursive function
|
|
|
|
*/
|
|
|
|
|
|
|
|
maxindex = nregneeded;
|
|
|
|
lar = regls;
|
|
|
|
perms = 0;
|
|
|
|
permute(0);
|
2018-06-02 19:31:18 +00:00
|
|
|
return (perms);
|
1984-05-18 21:27:39 +00:00
|
|
|
}
|
|
|
|
|
2018-06-02 19:31:18 +00:00
|
|
|
void permute(int index)
|
|
|
|
{
|
|
|
|
register struct perm* pp;
|
1984-05-18 21:27:39 +00:00
|
|
|
register rl_p rlp;
|
2018-06-02 19:31:18 +00:00
|
|
|
register i, j;
|
1984-05-18 21:27:39 +00:00
|
|
|
|
2018-06-02 19:31:18 +00:00
|
|
|
if (index == maxindex)
|
|
|
|
{
|
|
|
|
for (pp = perms; pp != 0; pp = pp->p_next)
|
|
|
|
{
|
|
|
|
for (i = 0; i < maxindex; i++)
|
1984-05-18 21:27:39 +00:00
|
|
|
if (regclass[rar[i]] != regclass[pp->p_rar[i]])
|
|
|
|
goto diff;
|
2018-06-02 19:31:18 +00:00
|
|
|
for (i = 0; i < maxindex; i++)
|
|
|
|
for (j = 0; j < i; j++)
|
|
|
|
if (clash(rar[i], rar[j]) != clash(pp->p_rar[i], pp->p_rar[j]))
|
1984-05-18 21:27:39 +00:00
|
|
|
goto diff;
|
|
|
|
return;
|
2018-06-02 19:31:18 +00:00
|
|
|
diff:;
|
1984-05-18 21:27:39 +00:00
|
|
|
}
|
2018-06-02 19:31:18 +00:00
|
|
|
pp = (struct perm*)myalloc(sizeof(*pp));
|
1984-05-18 21:27:39 +00:00
|
|
|
pp->p_next = perms;
|
2018-06-02 19:31:18 +00:00
|
|
|
for (i = 0; i < maxindex; i++)
|
1984-05-18 21:27:39 +00:00
|
|
|
pp->p_rar[i] = rar[i];
|
|
|
|
perms = pp;
|
2018-06-02 19:31:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rlp = lar[index];
|
|
|
|
for (i = rlp->rl_n - 1; i >= 0; i--)
|
|
|
|
{
|
1984-05-18 21:27:39 +00:00
|
|
|
rar[index] = rlp->rl_list[i];
|
2018-06-02 19:31:18 +00:00
|
|
|
permute(index + 1);
|
1984-05-18 21:27:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|