Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class local_update : public branch_update
- {
- public:
- unsigned int counter;
- };
- class local_predictor : public branch_predictor
- {
- public:
- local_update u;
- branch_info binfo;
- local_predictor (void)
- {
- }
- branch_update *predict (branch_info & b)
- {
- binfo = b;
- if (b.br_flags & BR_CONDITIONAL)
- {
- u.direction_prediction ((u.counter) >> 1);
- }
- else u.direction_prediction(true);
- u.target_prediction (0);
- return &u;
- }
- void update (branch_update *u, bool taken, unsigned int target)
- {
- unsigned int *c = &((local_update*)u)->counter;
- if (binfo.br_flags & BR_CONDITIONAL)
- {
- if (taken)
- {
- if (*c < 3)
- (*c)++;
- }
- else
- {
- if (*c > 0)
- (*c)--;
- }
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment