force certain regions of bits to match
| 2478 | |
| 2479 | // force certain regions of bits to match |
| 2480 | uint32_t enforce_bit_match(uint32_t inp, unsigned bit, vector<match> matches) |
| 2481 | { |
| 2482 | for(auto iter=matches.begin(); iter != matches.end(); ++iter) { |
| 2483 | struct match m = *iter; |
| 2484 | |
| 2485 | /* did we change a bit in the source region? */ |
| 2486 | if(bit >= m.src_lo && bit <= m.src_hi) { |
| 2487 | /* compute masks */ |
| 2488 | uint32_t a = 1<<m.src_hi; |
| 2489 | uint32_t b = 1<<m.src_lo; |
| 2490 | uint32_t src_mask = (a|(a-1)) ^ (b-1); |
| 2491 | |
| 2492 | a = 1<<m.dst_hi; |
| 2493 | b = 1<<m.dst_lo; |
| 2494 | uint32_t dst_mask = (a|(a-1)) ^ (b-1); |
| 2495 | |
| 2496 | /* mask and shift */ |
| 2497 | inp = (inp & (~dst_mask)); |
| 2498 | if(m.src_hi > m.dst_hi) { |
| 2499 | inp |= ((inp & src_mask) >> (m.src_hi - m.dst_hi)); |
| 2500 | } |
| 2501 | else { |
| 2502 | inp |= ((inp & src_mask) << (m.dst_hi - m.src_hi)); |
| 2503 | } |
| 2504 | } |
| 2505 | } |
| 2506 | |
| 2507 | return inp; |
| 2508 | } |
| 2509 | |
| 2510 | // for certain instructions with difficult inter-field dependencies |
| 2511 | // inputs: |
no test coverage detected