Removes upper bits from `a` and `b` for operations with partial constants. Handles cases like: ```pcode value:4 = load(value_addr) mask:1 = load(mask_addr); mask_zxt:4 = zext(mask); output = value & mask_zxt; ```
(op: pcode::Op, a: &'a [Bit], b: &'b [Bit])
| 462 | /// output = value & mask_zxt; |
| 463 | /// ``` |
| 464 | fn resize_used_bits<'a, 'b>(op: pcode::Op, a: &'a [Bit], b: &'b [Bit]) -> (&'a [Bit], &'b [Bit]) { |
| 465 | /// We didn't support this in the original implementation, so this flag can be set to enable |
| 466 | /// compatability with old traces. |
| 467 | const SKIP_AND_USAGE_ADJUSTMENT: bool = false; |
| 468 | if SKIP_AND_USAGE_ADJUSTMENT { |
| 469 | return (a, b); |
| 470 | } |
| 471 | |
| 472 | match op { |
| 473 | pcode::Op::IntAnd => { |
| 474 | let a_zeros = a.known_leading_zeros(); |
| 475 | let b_zeros = b.known_leading_zeros(); |
| 476 | (&a[..a.len() - b_zeros], &b[..b.len() - a_zeros]) |
| 477 | } |
| 478 | |
| 479 | // TODO: add additional operations (e.g., IntOr with upper ones, Bool* operations, shift |
| 480 | // operations). |
| 481 | _ => (a, b), |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | impl icicle_vm::CodeInjector for LoadResizeInjector { |
| 486 | fn inject(&mut self, cpu: &mut Cpu, group: &BlockGroup, code: &mut BlockTable) { |
no test coverage detected