2 static char rcsid[] = "$Id: reg.c,v 0.11 1994/06/24 13:27:53 ceriel Exp $";
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;
29 if (rp->r_members[0]==0) {
31 rp->r_refcount += amount;
33 rp->r_tcount += amount;
34 assert(rp->r_refcount >= 0);
37 for (i=0;i<MAXMEMBERS;i++)
38 if ((tmp = rp->r_members[i])!=0)
39 chrefcount(tmp,amount,tflag);
43 getrefcount(regno, tflag) {
44 register struct reginfo *rp;
46 register i,maxcount, tmp;
51 if (rp->r_members[0]==0)
53 return(rp->r_refcount - (tflag ? rp->r_tcount : 0));
57 for (i=0;i<MAXMEMBERS;i++)
58 if ((tmp=rp->r_members[i])!=0) {
59 tmp = getrefcount(tmp, tflag);
60 if (tmp > maxcount) maxcount = tmp;
68 register struct reginfo *rp = &machregs[regno];
73 rp->r_contents.t_token = 0;
74 for (i=TOKENSIZE-1;i>=0;i--)
75 rp->r_contents.t_att[i].aw = 0;
77 /* Now erase recursively all registers containing
78 * something using this one
80 for (rp=machregs;rp<machregs+NREGS;rp++) {
81 if (rp->r_contents.t_token == -1) {
82 if (rp->r_contents.t_att[0].ar == regno) {
83 /* erasereg(rp-machregs);
84 replaced by the following three
87 rp->r_contents.t_token = 0;
88 for (i=TOKENSIZE-1;i>=0;i--)
89 rp->r_contents.t_att[i].aw = 0;
91 } else if (rp->r_contents.t_token > 0) {
92 tdpb= & (tokens[rp->r_contents.t_token].t_type[0]);
93 for (i=0;i<TOKENSIZE;i++)
94 if (*tdpb++ == EV_REG &&
95 rp->r_contents.t_att[i].ar == regno) {
96 /* erasereg(rp-machregs);
97 replaced by the following three
100 rp->r_contents.t_token = 0;
101 for (i=TOKENSIZE-1;i>=0;i--)
102 rp->r_contents.t_att[i].aw = 0;
108 extern short clashlist[];
109 register short *sp = &clashlist[rp->r_iclash];
111 rp->r_contents.t_token = 0;
114 rp->r_contents.t_token = 0;
115 for (i=TOKENSIZE-1;i>=0;i--)
116 rp->r_contents.t_att[i].aw = 0;
118 /* Now erase recursively all registers containing
119 * something using this one
121 for (rp=machregs;rp<machregs+NREGS;rp++) {
122 if (rp->r_contents.t_token == -1) {
123 if (rp->r_contents.t_att[0].ar == regno) {
124 /* erasereg(rp-machregs);
125 replaced by the following three
128 rp->r_contents.t_token = 0;
129 for (i=TOKENSIZE-1;i>=0;i--)
130 rp->r_contents.t_att[i].aw = 0;
132 } else if (rp->r_contents.t_token > 0) {
133 tdpb= & (tokens[rp->r_contents.t_token].t_type[0]);
134 for (i=0;i<TOKENSIZE;i++)
135 if (*tdpb++ == EV_REG &&
136 rp->r_contents.t_att[i].ar == regno) {
137 /* erasereg(rp-machregs);
138 replaced by the following three
141 rp->r_contents.t_token = 0;
142 for (i=TOKENSIZE-1;i>=0;i--)
143 rp->r_contents.t_att[i].aw = 0;
153 register struct reginfo *rp;
156 for (rp=machregs;rp<machregs+NREGS;rp++) {
157 rp->r_contents.t_token = 0;
158 for (i=TOKENSIZE-1;i>=0;i--)
159 rp->r_contents.t_att[i].aw = 0;
165 register struct reginfo *rp;
168 rp = &machregs[regno];
170 if (rp->r_members[0] == 0) {
175 for (i=0;i<MAXMEMBERS;i++)
176 if (rp->r_members[i] != 0)
177 inctcount(rp->r_members[i]);
183 register struct reginfo *rp;
188 for (rp=machregs+1;rp<machregs+NREGS;rp++) {
189 assert(rp->r_tcount==0);
191 for (tp=fakestack;tp<fakestack+stackheight;tp++) {
192 if (tp->t_token == -1)
193 inctcount(tp->t_att[0].ar);
195 tdpb = &(tokens[tp->t_token].t_type[0]);
196 for (i=0;i<TOKENSIZE;i++)
198 inctcount(tp->t_att[i].ar);
203 for(i=reg_any;i<=reg_float;i++) {
205 for(j=0;j<nregvar[i];j++)
206 inctcount(rvnumbers[i][j]);
209 for (rp=machregs+1;rp<machregs+NREGS;rp++) {
210 assert(rp->r_refcount==rp->r_tcount);