fitzgen opened PR #5647 from mul-pow-2
to main
:
Draft because this is hitting an ISLE codegen bug where the generated Rust code doesn't pass the borrow checker:
error[E0382]: use of moved value: `v26` --> | 577 | let mut v26 = v26; | ------- --- this reinitialization might get skipped | | | move occurs because `v26` has type `<C as opts::generated_code::Context>::inst_data_etor_iter`, which does not implement the `Copy` trait ... 598 | while let Some(v35) = v34.next(ctx) { | ----------------------------------- | | | inside of this loop | inside of this loop ... 606 | let v26 = v26; | --- value moved here, in previous iteration of loop ... 679 | let v26 = v26; | --- value moved here, in previous iteration of loop ... 723 | let v26 = v26; | ^^^ value used here after move For more information about this error, try `rustc --explain E0382`.
fitzgen updated PR #5647 from mul-pow-2
to main
.
fitzgen requested jameysharp for a review on PR #5647.
fitzgen has marked PR #5647 as ready for review.
jameysharp submitted PR review.
jameysharp submitted PR review.
jameysharp created PR review comment:
I'd be inclined to return
x.trailing_zeros()
here instead of justx
, and remove theu64_log2
extractor. When you're asking whether something's a power of two, it's natural to wonder which power of two it is. On the flip side, usingtrailing_zeros
to implementilog2
is safe _iff_x.is_power_of_two()
is true. So I think it makes the most sense to couple these two queries together pretty tightly. If somebody really just wants the original value after checking that it's a power of two, they can use at-patterns to bind the input instead of the result.I also wonder, should this extractor take
u64
as input instead ofImm64
? We have extractors for converting in either direction so I guess it doesn't matter too much which way we pick here.
jameysharp created PR review comment:
Is this debug log message generally useful, or a leftover?
fitzgen submitted PR review.
fitzgen created PR review comment:
It is generally useful. So hard to get the input that the patterns are being filechecked against, now we can always see it via
RUST_LOG=debug
.
fitzgen submitted PR review.
fitzgen created PR review comment:
Yeah, I like that!
I also wonder, should this extractor take u64 as input instead of Imm64? We have extractors for converting in either direction so I guess it doesn't matter too much which way we pick here.
Its just more wordy since we don't have automatic conversions between the two.
fitzgen submitted PR review.
fitzgen created PR review comment:
(And I don't think we necessarily should since
Imm64
is "signed" but also it kind of depends on how the value ends up being used.)
fitzgen updated PR #5647 from mul-pow-2
to main
.
fitzgen has enabled auto merge for PR #5647.
fitzgen merged PR #5647.
Last updated: Dec 23 2024 at 13:07 UTC