void train_predictor (unsigned int pc, bool outcome) { int outInt = (int)outcome; int choosePC =Choose[address&BMASK]; if(Gpredict!=BMpredict) { if(Gpredict==outcome) choosePC = (choosePC>2)?3:choosePC+1; else if(BMpredict==outcome) choosePC = (choosePC<1)?0:choosePC-1; Choose[address&BMASK] = choosePC; } sr_add(outInt); if(outcome==0) { PTable[address] = ((Gsharevalue-1)<0)?0:Gsharevalue-1; BMT[BMAddress] = ((BMvalue-1)<0)?0:BMvalue-1; } else { PTable[address] = ((Gsharevalue+1)>3)?3:Gsharevalue+1; BMT[BMAddress] = ((BMvalue+1)>3)?3:BMvalue+1; } }
err_t sr_test_eval(sx_t * sx, sr_t * ret) { sr_t a[1] = {{0,1}}, b[1] = {{0,1}}; err_t err; if (!sx) return ERR_IN_NULL_POINTER; if (sx->islist) { sx_t * sn, * sd; signed n = 0; unsigned d = 1; /* is rational tuple ? */ if (sx->list) { sn = sx->list; if (sn->issint || sn->isuint) { if (sn->issint) n = (int16_t)sn->atom.sint; else if (sn->isuint) n = (uint16_t)sn->atom.uint; else return ERR_FAILURE; if (sn->next) { sd = sn->next; if (sd->isuint) d = (uint16_t)sd->atom.uint; else return ERR_FAILURE; } err = sr_set(ret, n, d); if (err) return err; return 0; } else if (sn->isplain) { if (strncmp(sn->atom.string->buffer, "add", sn->atom.string->used) == 0) { if (sn->next && sn->next->next) { err = sr_test_eval(sn->next, a); if (err) return err; sn = sn->next->next; while (sn) { err = sr_test_eval(sn, b); if (err) return err; if (err) return err; err = sr_add(a, b, a); sn = sn->next; } *ret = *a; } } else if (strncmp(sn->atom.string->buffer, "sub", sn->atom.string->used) == 0) { if (sn->next && sn->next->next) { err = sr_test_eval(sn->next, a); if (err) return err; sn = sn->next->next; while (sn) { err = sr_test_eval(sn, b); if (err) return err; if (err) return err; err = sr_sub(a, b, a); sn = sn->next; } *ret = *a; } } else if (strncmp(sn->atom.string->buffer, "mul", sn->atom.string->used) == 0) { if (sn->next && sn->next->next) { err = sr_test_eval(sn->next, a); if (err) return err; sn = sn->next->next; while (sn) { err = sr_test_eval(sn, b); if (err) return err; if (err) return err; err = sr_mul(a, b, a); sn = sn->next; } *ret = *a; } } else if (strncmp(sn->atom.string->buffer, "div", sn->atom.string->used) == 0) { if (sn->next && sn->next->next) { err = sr_test_eval(sn->next, a); if (err) return err; sn = sn->next->next; while (sn) { err = sr_test_eval(sn, b); if (err) return err; if (err) return err; err = sr_div(a, b, a); sn = sn->next; } *ret = *a; } } else return ERR_FAILURE; } } } return 0; }