2 static char rcsid[] = "$Id: reg.c,v 2.12 1994/06/24 13:24:06 ceriel Exp $";
9 #include <cg_pattern.h>
15 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
16 * See the copyright notice in the ACK home directory, in the file "Copyright".
18 * Author: Hans van Staveren
21 chrefcount(regno,amount,tflag) {
22 register struct reginfo *rp;
27 if (rp->r_members[0]==0) {
29 rp->r_refcount += amount;
31 rp->r_tcount += amount;
32 assert(rp->r_refcount >= 0);
35 for (i=0;i<MAXMEMBERS;i++)
36 if (rp->r_members[i]!=0)
37 chrefcount(rp->r_members[i],amount,tflag);
41 getrefcount(regno, tflag) {
42 register struct reginfo *rp;
47 if (rp->r_members[0]==0)
49 return(rp->r_refcount - (tflag ? rp->r_tcount : 0));
53 for (i=0;i<MAXMEMBERS;i++)
54 if (rp->r_members[i]!=0)
55 maxcount=max(maxcount,getrefcount(rp->r_members[i], tflag));
62 register struct reginfo *rp;
65 rp = &machregs[regno];
66 rp->r_contents.t_token = 0;
67 for (i=0;i<TOKENSIZE;i++)
68 rp->r_contents.t_att[i].aw = 0;
74 if (regno == 1) { /* condition codes */
76 for (rp=machregs;rp<machregs+NREGS;rp++)
77 if (rp->r_clash[regno>>4]&(1<<(regno&017))) {
78 rp->r_contents.t_token = 0;
79 for (i=0;i<TOKENSIZE;i++)
80 rp->r_contents.t_att[i].aw = 0;
81 awayreg((int)(rp-machregs));
87 register struct reginfo *rp;
91 /* Now erase recursively all registers containing
92 * something using this one
94 for (rp=machregs;rp<machregs+NREGS;rp++) {
95 if (rp->r_contents.t_token == -1) {
96 if (rp->r_contents.t_att[0].ar == regno)
97 erasereg((int)(rp-machregs));
98 } else if (rp->r_contents.t_token > 0) {
99 tdp= & tokens[rp->r_contents.t_token];
100 for (i=0;i<TOKENSIZE;i++)
101 if (tdp->t_type[i] == EV_REG &&
102 rp->r_contents.t_att[i].ar == regno) {
103 erasereg((int)(rp-machregs));
111 register struct reginfo *rp;
114 for (rp=machregs;rp<machregs+NREGS;rp++) {
115 rp->r_contents.t_token = 0;
116 for (i=0;i<TOKENSIZE;i++)
117 rp->r_contents.t_att[i].aw = 0;
123 register struct reginfo *rp;
126 rp = &machregs[regno];
128 if (rp->r_members[0] == 0) {
133 for (i=0;i<MAXMEMBERS;i++)
134 if (rp->r_members[i] != 0)
135 inctcount(rp->r_members[i]);
141 register struct reginfo *rp;
143 register tkdef_p tdp;
146 for (rp=machregs;rp<machregs+NREGS;rp++) {
147 assert(rp->r_tcount==0);
149 for (tp=fakestack;tp<fakestack+stackheight;tp++) {
150 if (tp->t_token == -1)
151 inctcount(tp->t_att[0].ar);
153 tdp = &tokens[tp->t_token];
154 for (i=0;i<TOKENSIZE;i++)
155 if (tdp->t_type[i]==EV_REG)
156 inctcount(tp->t_att[i].ar);
161 for(i=reg_any;i<=reg_float;i++) {
163 for(j=0;j<nregvar[i];j++)
164 inctcount(rvnumbers[i][j]);
167 for (rp=machregs;rp<machregs+NREGS;rp++) {
168 assert(rp->r_refcount==rp->r_tcount);