Add regvar_w() and regvar_d() for use with reglap.

If the ncg table uses reglap, then regvar($1, reg_float) would have
two sizes of registers.  An error from ncgg would happen if regvar()
was in a token that allows only one size.  Now one can pick a size
with regvar_w() for word size or regvar_d() for double-word size.

Add regvar_d and regvar_w as keywords in ncgg.  Modify EX_REGVAR to
include the register size.  In ncg, add some checks for the register
size.  In tables without reglap, regvar() works as before, and ncg
ignores the register size in EX_REGVAR.
This commit is contained in:
George Koehler 2017-10-17 12:05:41 -04:00
parent 5432bd03d6
commit 307a8b996e
6 changed files with 44 additions and 17 deletions

View file

@ -385,7 +385,7 @@ compute(node, presult) register node_p node; register result_t *presult; {
return;
case EX_REGVAR:
assert(leaf1.e_typ == EV_INT);
i = isregvar((long) leaf1.e_v.e_con);
i = isregvar_size((long) leaf1.e_v.e_con, node->ex_rnode);
if (i<=0) {
presult->e_typ = EV_UNDEF;
return;
@ -393,7 +393,7 @@ compute(node, presult) register node_p node; register result_t *presult; {
presult->e_typ = EV_REG;
presult->e_v.e_reg=i;
return;
#endif
#endif /* REGVARS */
case EX_UMINUS:
assert(leaf1.e_typ == EV_INT);
presult->e_v.e_con = -leaf1.e_v.e_con;

View file

@ -211,7 +211,9 @@ cinstance(instno,token,tp,regno) register token_p token,tp; {
compute(&enodes[inp->in_info[1]], &result);
curtoken = ct;
assert(result.e_typ==EV_INT);
if ((regno=isregvar(result.e_v.e_con)) > 0) {
regno = isregvar_size(result.e_v.e_con,
tokens[inp->in_info[0]].t_size);
if (regno > 0) {
token->t_token = -1;
token->t_att[0].ar = regno;
for (i=TOKENSIZE-1;i>0;i--)

View file

@ -78,7 +78,8 @@ iocc_t iops[20];
%token PATTERNS PAT WITH EXACT KILLS USES REUSING GEN YIELDS LEAVING
%token DEFINED SAMESIGN SFIT UFIT ROM LOWW HIGHW ISROM
%token CMPEQ CMPNE CMPLT CMPGT CMPLE CMPGE OR2 AND2 LSHIFT RSHIFT NOT COMP
%token INREG REGVAR REG_ANY REG_FLOAT REG_LOOP REG_POINTER
%token INREG REGVAR REGVAR_W REGVAR_D
%token REG_ANY REG_FLOAT REG_LOOP REG_POINTER
%token <yy_int> ADORNACCESS
%token <yy_int> ADORNCC
%token INT
@ -1086,7 +1087,11 @@ expr
regvarexpr
: REGVAR '(' expr optregvartype ')'
{ $$ = regvar_expr($3,$4); }
{ $$ = regvar_expr($3,$4,-1); }
| REGVAR_W '(' expr optregvartype ')'
{ $$ = regvar_expr($3,$4,wordsize); }
| REGVAR_D '(' expr optregvartype ')'
{ $$ = regvar_expr($3,$4,2*wordsize); }
;
optregvartype

View file

@ -274,22 +274,36 @@ expr_t iextoaddr(e) expr_t e; {
return(result);
}
expr_t regvar_expr(e,regtyp) expr_t e; {
expr_t regvar_expr(e,regtyp,regsiz) expr_t e; {
expr_t result;
register i;
int i, regno, s, two_sizes;
result = make_expr(TYPREG,EX_REGVAR,i_expr(e),0);
two_sizes = (regtyp == reg_float && reglap != 0);
if (regsiz == -1) {
/* reglap: Can't guess between 2 sizes of reg_float. */
if (two_sizes && regsiz == -1)
error("Must use regvar_w() or regvar_d()");
else
regsiz = rvsize[regtyp];
}
result = make_expr(TYPREG,EX_REGVAR,i_expr(e),regsiz);
for(i=0;i<SZOFSET(MAXREGS);i++)
result.ex_regset[i]=0;
for(i=0;i<nregvar[regtyp];i++)
BIS(result.ex_regset,rvnumbers[regtyp][i]);
/* reglap: float may overlap with one subregister */
if (reglap!=0 && regtyp==reg_float) {
/* s = the size of the registers in rvnumbers[regtyp] */
s = two_sizes ? reglap : rvsize[regtyp];
if (s == regsiz) {
for(i=0;i<nregvar[regtyp];i++)
BIS(result.ex_regset,rvnumbers[regtyp][i]);
}
/* reglap: Also check the 2nd size of reg_float. */
if (two_sizes && rvsize[regtyp] == regsiz) {
for(i=0;i<nregvar[regtyp];i++) {
/* reg = first subregister */
int reg = l_regs[rvnumbers[regtyp][i]].ri_memb[0];
if (reg!=0)
BIS(result.ex_regset,reg);
/* regno = first subregister */
regno = l_regs[rvnumbers[regtyp][i]].ri_memb[0];
if (regno != 0)
BIS(result.ex_regset, regno);
}
}
return(result);

View file

@ -175,7 +175,11 @@ found:
case IN_D_DESCR:
{ int temp;
temp=ex_lookup(EX_REGVAR,insta->in_info[1],0);
if (insta->in_which == IN_S_DESCR)
temp = wordsize;
else
temp = 2 * wordsize;
temp=ex_lookup(EX_REGVAR,insta->in_info[1],temp);
vi->vi_next = generase(temp);
vi = vi->vi_next;
vi->vi_next = genremove(temp);

View file

@ -38,6 +38,8 @@ reg_float REG_FLOAT
reg_loop REG_LOOP
reg_pointer REG_POINTER
regvar REGVAR
regvar_d REGVAR_D
regvar_w REGVAR_W
return RETURN
reusing REUSING
rom ROM