Use a SmallVec in CastTarget#157130
Conversation
This commit switches a fixed-size list of `[Option<Reg>; 8]` to instead holding `SmallVec<[Reg; 8]>` in the `CastTarget` type used when calculating ABIs. This is inspired by [discussion on Zulip][link] where I'm hoping to in the near future extend the usage of this to possibly beyond 8 elements for a new WebAssembly ABI taking advantage of multi-value. [link]: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Using.20.60ArgAbi.3A.3Amake_direct_deprecated.60/with/598607139
|
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
|
r? @nnethercote rustbot has assigned @nnethercote. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
The Cranelift subtree was changed cc @bjorn3 |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
| /// (and all data in the padding between the registers is dropped). | ||
| #[derive(Clone, PartialEq, Eq, Hash, Debug, StableHash)] | ||
| pub struct CastTarget { | ||
| pub prefix: [Option<Reg>; 8], |
There was a problem hiding this comment.
[Option<Reg>; 8], lol, what an awful representation.
If you wanted a nicer representation while still retaining the "at most 8 elements" constraint you could use ArrayVec<[Reg; 8]> instead. That would be very similar to the code you've written, and get the nicer iterations/pushes/etc. Then the change to allow more than 8 elements (later) would just be a conversion to SmallVec.
| #[derive(Clone, PartialEq, Eq, Hash, Debug, StableHash)] | ||
| pub struct CastTarget { | ||
| pub prefix: [Option<Reg>; 8], | ||
| pub prefix: SmallVec<[Reg; 8]>, |
There was a problem hiding this comment.
It would be nice to have a comment explaining the 8 here.
This commit switches a fixed-size list of
[Option<Reg>; 8]to instead holdingSmallVec<[Reg; 8]>in theCastTargettype used when calculating ABIs. This is inspired by discussion on Zulip where I'm hoping to in the near future extend the usage of this to possibly beyond 8 elements for a new WebAssembly ABI taking advantage of multi-value.