From 2a92f9bf4d02577cf2b39557d8f468a8a33d8bb8 Mon Sep 17 00:00:00 2001 From: George Koehler Date: Wed, 18 Oct 2017 22:00:12 -0400 Subject: [PATCH] Add a few more error checks and adjustments to reglap. In util/ncgg, add two more errors for tables using reglap: - "Two sizes of reg_float can't be same size" - "Missing reg_float of size %d to contain %s" In mach/proto/ncg, rename macro isregvar_size() to PICK_REGVAR(), so the macro doesn't look like a function. This macro sometimes doesn't evaluate its second argument. In mach/powerpc/ncg/mach.c, change type of lfs_set to uint32_t, and change the left shifts from 1U< +#include static long framesize; @@ -106,7 +107,7 @@ char *segname[] = { static long savedf[32]; static long savedi[32]; static int savedtop; -static unsigned long lfs_set; +static uint32_t lfs_set; /* Calculate the register score of a local variable. */ int @@ -172,7 +173,7 @@ regsave(const char* regname, long offset, int size) savedf[regnum] = offset; framesize += 8; if (size == 4) - lfs_set |= (1U << regnum); + lfs_set |= ((uint32_t)1<= 0; reg--) if (savedf[reg] >= 0) fprintf(codefile, "%s f%d, %ld(fp)\n", - (lfs_set & (1U << reg)) ? "lfs" : "lfd", + (lfs_set & ((uint32_t)1<= 0; reg--) diff --git a/mach/proto/ncg/compute.c b/mach/proto/ncg/compute.c index 926ffeb3c..41e159f04 100644 --- a/mach/proto/ncg/compute.c +++ b/mach/proto/ncg/compute.c @@ -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_size((long) leaf1.e_v.e_con, node->ex_rnode); + i = PICK_REGVAR((long) leaf1.e_v.e_con, node->ex_rnode); if (i<=0) { presult->e_typ = EV_UNDEF; return; diff --git a/mach/proto/ncg/regvar.h b/mach/proto/ncg/regvar.h index cd7da216f..089bd72b1 100644 --- a/mach/proto/ncg/regvar.h +++ b/mach/proto/ncg/regvar.h @@ -28,8 +28,12 @@ void fixregvars(int); int isregvar(long); #ifdef REGLAP int isregvar_size(long, int); -#else -#define isregvar_size(off, size) isregvar(off) #endif int isregtyp(long); void unlinkregs(void); + +#ifdef REGLAP +#define PICK_REGVAR(off, size) isregvar_size(off, size) +#else +#define PICK_REGVAR(off, size) isregvar(off) +#endif diff --git a/mach/proto/ncg/subr.c b/mach/proto/ncg/subr.c index 4540d8b00..fd6b72718 100644 --- a/mach/proto/ncg/subr.c +++ b/mach/proto/ncg/subr.c @@ -121,8 +121,8 @@ instance(instno,token) register token_p token; { case IN_D_DESCR: compute(&enodes[inp->in_info[1]], &result); assert(result.e_typ==EV_INT); - regno = isregvar_size(result.e_v.e_con, - tokens[inp->in_info[0]].t_size); + regno = PICK_REGVAR(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; @@ -211,8 +211,8 @@ 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); - regno = isregvar_size(result.e_v.e_con, - tokens[inp->in_info[0]].t_size); + regno = PICK_REGVAR(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; diff --git a/util/ncgg/cgg.y b/util/ncgg/cgg.y index d2f1532b3..c77f566d7 100644 --- a/util/ncgg/cgg.y +++ b/util/ncgg/cgg.y @@ -130,8 +130,9 @@ machtable : constants properties registers + { check_reglap(); } tokens - { make_std_sets(); } + { make_std_sets(); } sets instructions moves diff --git a/util/ncgg/subr.c b/util/ncgg/subr.c index 89b2b0917..7fc0cdd48 100644 --- a/util/ncgg/subr.c +++ b/util/ncgg/subr.c @@ -254,9 +254,11 @@ add_regvar(int rvnum, reginfo *regp, int rv) wrong = 0; if (overlap) { /* reglap = size of overlap float */ - if (reglap==0) + if (reglap==0) { reglap = regp->ri_size; - else if (reglap!=regp->ri_size) + if (reglap == rvsize[reg_float]) + error("Two sizes of reg_float can't be same size"); + } else if (reglap!=regp->ri_size) wrong = 1; } else { if (nregvar[rv]==0) @@ -322,6 +324,23 @@ regline(rl,pl,rv) varinfo *rl,*pl; { regclass++; } +void +check_reglap() { + reginfo *regp; + int i; + + if (reglap == 0) + return; + + /* reglap: Check that every reg_float has size == reglap. */ + for (i = 0; i < nregvar[reg_float]; i++) { + regp = &l_regs[rvnumbers[reg_float][i]]; + if (regp->ri_size != reglap) + error("Missing reg_float of size %d to contain %s", + reglap, regp->ri_name); + } +} + setallreg(vi) struct varinfo *vi; { nallreg=0;