1985-01-08 15:34:54 +00:00
|
|
|
#ifndef NORCSID
|
1994-06-24 14:02:31 +00:00
|
|
|
static char rcsid[] = "$Id$";
|
1985-01-08 15:34:54 +00:00
|
|
|
#endif
|
|
|
|
|
2017-11-12 00:35:48 +00:00
|
|
|
#include <assert.h>
|
2013-05-07 23:48:48 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
1985-01-08 15:34:54 +00:00
|
|
|
#include "equiv.h"
|
|
|
|
#include "param.h"
|
|
|
|
#include "tables.h"
|
|
|
|
#include "types.h"
|
|
|
|
#include <cgg_cg.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".
|
1985-01-08 15:34:54 +00:00
|
|
|
*
|
|
|
|
* Author: Hans van Staveren
|
|
|
|
*/
|
|
|
|
|
2017-11-12 16:25:18 +00:00
|
|
|
static int rar[MAXCREG];
|
|
|
|
static rl_p *lar;
|
|
|
|
static int maxindex;
|
|
|
|
static int regclass[NREGS];
|
|
|
|
static struct perm *perms;
|
1985-01-08 15:34:54 +00:00
|
|
|
|
2017-11-12 16:25:18 +00:00
|
|
|
static void permute(int);
|
2016-11-10 21:04:18 +00:00
|
|
|
|
1985-01-08 15:34:54 +00:00
|
|
|
struct perm *
|
|
|
|
tuples(regls,nregneeded) rl_p *regls; {
|
|
|
|
int class=0;
|
|
|
|
register i,j;
|
1991-01-11 10:54:03 +00:00
|
|
|
register struct reginfo *rp;
|
1985-01-08 15:34:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First compute equivalence classes of registers.
|
|
|
|
*/
|
|
|
|
|
1991-01-11 10:54:03 +00:00
|
|
|
for (i=NREGS, rp = &machregs[NREGS-1];--i>=0;rp--) {
|
1985-01-08 15:34:54 +00:00
|
|
|
regclass[i] = class++;
|
1988-07-15 11:12:13 +00:00
|
|
|
if (getrefcount(i, FALSE) == 0) {
|
1989-03-17 16:49:58 +00:00
|
|
|
for (j=NREGS;--j>i;) {
|
1985-01-08 15:34:54 +00:00
|
|
|
if (eqregclass(i,j) &&
|
1991-01-11 10:54:03 +00:00
|
|
|
eqtoken(&rp->r_contents,
|
1985-01-08 15:34:54 +00:00
|
|
|
&machregs[j].r_contents)) {
|
|
|
|
regclass[i] = regclass[j];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now create tuples through a recursive function
|
|
|
|
*/
|
|
|
|
|
|
|
|
maxindex = nregneeded;
|
|
|
|
lar = regls;
|
|
|
|
perms = 0;
|
|
|
|
permute(0);
|
|
|
|
return(perms);
|
|
|
|
}
|
|
|
|
|
2017-11-12 16:25:18 +00:00
|
|
|
static void permute(int index) {
|
|
|
|
struct perm *pp;
|
|
|
|
rl_p rlp;
|
|
|
|
int i,j;
|
1985-01-08 15:34:54 +00:00
|
|
|
|
|
|
|
if (index == maxindex) {
|
|
|
|
for (pp=perms; pp != 0; pp=pp->p_next) {
|
|
|
|
for (i=0; i<maxindex; i++)
|
|
|
|
if (regclass[rar[i]] != regclass[pp->p_rar[i]])
|
|
|
|
goto diff;
|
1991-01-11 10:54:03 +00:00
|
|
|
for (i=0; i<maxindex; i++) {
|
|
|
|
int rari = rar[i], p_rari = pp->p_rar[i];
|
1985-01-08 15:34:54 +00:00
|
|
|
for (j=0; j<i; j++)
|
1991-01-11 10:54:03 +00:00
|
|
|
if (clash(rari,rar[j]) !=
|
|
|
|
clash(p_rari,pp->p_rar[j]))
|
1985-01-08 15:34:54 +00:00
|
|
|
goto diff;
|
1991-01-11 10:54:03 +00:00
|
|
|
}
|
1985-01-08 15:34:54 +00:00
|
|
|
return;
|
|
|
|
diff: ;
|
|
|
|
}
|
|
|
|
pp = (struct perm *) myalloc(sizeof ( *pp ));
|
|
|
|
pp->p_next = perms;
|
|
|
|
for (i=0; i<maxindex; i++)
|
|
|
|
pp->p_rar[i] = rar[i];
|
|
|
|
perms = pp;
|
|
|
|
} else {
|
|
|
|
rlp=lar[index];
|
1989-03-17 16:49:58 +00:00
|
|
|
for (i=rlp->rl_n; i>0; i--) {
|
|
|
|
rar[index] = rlp->rl_list[rlp->rl_n-i];
|
1985-01-08 15:34:54 +00:00
|
|
|
permute(index+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|