-
Notifications
You must be signed in to change notification settings - Fork 8
feat!: Generalise array op builers to arbitrary array kinds #2119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feat/arrays #2119 +/- ##
==============================================
Coverage ? 83.32%
==============================================
Files ? 226
Lines ? 42847
Branches ? 38900
==============================================
Hits ? 35703
Misses ? 5289
Partials ? 1855
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR contains breaking changes to the public Rust API. cargo-semver-checks summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Nice solutions to the duplicated impl problem :)
Feature branch for improved array lowering. * The old `array` type is now called `value_array` and lives in a separate extension * The default `array` is now a linear type with additional `clone` and `discard` operations * To avoid code duplication, array operations and values are now defined generically over a new `ArrayKind` trait that is instantiated with `Array` (the linear one) and `VArray` (the copyable one) to generate the `array` and `value_array` extensions * An `array<n, T>` is now lowered to a fat pointer `{ptr, usize}` where `ptr` is a heap allocated pointer of size at least `n * sizeof(T)` and the `usize` is an offset pointing to the first element (i.e. the first element is at `ptr + offset * sizeof(T)`). The rational behind the additional offset is the `pop_left` operation which bumps the offset instead of mutating the pointer. This way, we can still free the original pointer when the array is discarded after a pop. Tracked PRs: * #2097 (closes #2066) * #2100 * #2101 * #2110 * #2112 (closes #2067) * #2119 * #2125 (closes #2124) BREAKING CHANGE: `std.collections.array` is now a linear type, even if the contained elements are copyable. Use the new `std.collections.value_array` for an array with the previous copyable semantics. BREAKING CHANGE: `std.collections.array.get` now also returns the passed array as an extra output BREAKING CHANGE: `ArrayOpBuilder` was moved from `hugr_core::std_extensions::collections::array::op_builder` to `hugr_core::std_extensions::collections::array`.
ArrayOpBuilder
trait toGenericOpBuilder
whose methods are generic over the array implementationArrayOpBuilder
andVArrayOpBuilder
traits that are implemented in terms of the generic version. I moved those into thearray
andvalue_array
modules respectively, so they don't come into scope at the same timeall_array_ops
ops function out of the tests module so we can reuse it across other tests (in particular getting rid of the code duplication inhugr-llvm::extension::collections::array::test
BREAKING CHANGE:
ArrayOpBuilder
was moved fromhugr_core::std_extensions::collections::array::op_builder
tohugr_core::std_extensions::collections::array