2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
6 static char rcsid[]= "$Id: instruct.c,v 0.5 1994/06/24 10:37:26 ceriel Exp $";
23 extern set_t l_sets[];
24 extern inst_t l_instances[];
26 extern expr_t subreg_expr(),regno_expr();
28 struct varinfo * setcoco(n) {
31 NEW(vi,struct varinfo);
32 vi->vi_next = VI_NULL;
33 vi->vi_int[0] = INSSETCC;
38 struct varinfo * generase(n) {
41 NEW(vi,struct varinfo);
42 vi->vi_next = VI_NULL;
43 vi->vi_int[0] = INSERASE;
48 struct varinfo * genremove(n) {
51 NEW(vi,struct varinfo);
52 vi->vi_next = VI_NULL;
53 vi->vi_int[0] = INSREMOVE;
63 sp = l_sets[tokpatset[argno-1]].set_val;
64 for(bitno=nregs;bitno<nregs+ntokens;bitno++)
74 if (tokpatro[argno-1])
75 error("Instruction destroys %%%d, not allowed here",argno);
76 s = l_sets[tokpatset[argno-1]];
78 tokpatset[argno-1] = setlookup(s);
81 struct varinfo *gen_inst(ident,star) char *ident; {
82 register struct varinfo *vi,*retval,*eravi;
84 register struct operand *op;
86 register inst_p insta;
89 error("Variable instruction only allowed inside proc");
90 for (ip=l_instr;ip<l_instr+ninstr;ip++) {
91 if(strcmp(ident,ip->i_name))
93 if (ip->i_nops!=niops)
95 for(i=0,op=ip->i_oplist;i<niops;i++,op=op->o_next) {
96 if (!subset(iops[i].in_set,l_sets[op->o_setno].set_val,SETSIZE))
99 goto found; /* oh well, one more won't hurt */
102 error("Such an \"%s\" does not exist",ident);
105 NEW(vi,struct varinfo);
106 vi->vi_int[0] = ip-l_instr;
107 vi->vi_int[1] = star;
110 for(i=0;i<niops;i++) {
111 NEW(vi->vi_vi,struct varinfo);
113 vi->vi_int[0] = iops[i].in_index;
117 for(i=0,op=ip->i_oplist;i<niops;i++,op=op->o_next) {
118 if(op->o_adorn&AD_CC) {
119 vi->vi_next = setcoco(iops[i].in_index);
122 switch(op->o_adorn&AD_RWMASK) {
124 /* Nothing possible to do */
127 /* It might be possible to do something
133 /* Treated the same for now */
134 insta = &l_instances[iops[i].in_index];
135 switch(insta->in_which) {
137 if(insta->in_info[1]==0 && !onlyreg(insta->in_info[0]))
139 makescratch(insta->in_info[0]);
140 vi->vi_next = generase(
142 EX_SUBREG,insta->in_info[0],
149 vi->vi_next = generase(
151 EX_TOKFIELD,insta->in_info[0],
158 vi->vi_next = generase(
160 EX_REG,insta->in_info[0],0
166 vi->vi_next = generase(
168 EX_ALLREG,insta->in_info[0]+1,
178 temp=ex_lookup(EX_REGVAR,insta->in_info[1],0);
179 vi->vi_next = generase(temp);
181 vi->vi_next = genremove(temp);
189 for (eravi=ip->i_erases;eravi != VI_NULL;eravi=eravi->vi_next) {
190 if (eravi->vi_int[0] < 0)
191 vi->vi_next = setcoco(0);
193 vi->vi_next = generase(eravi->vi_int[0]);
195 vi->vi_next = genremove(eravi->vi_int[0]);