Skip to content
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

Define pads with absolute register addresses #22

Merged
merged 2 commits into from
Jan 2, 2022

Conversation

mciantyre
Copy link
Member

We used to describe a pad with

  • two absolute addresses to the start of the MUX and PAD group, collectively called a "base"
  • an offset into the group block

We did this with custom types and typenums. The pad types are unique, because the (base, offset) type pairings are unique. But, there's the chance for a runtime op to compute a pointer offset. And when erasing the types, we need to maintain three pieces of information: two pointers for the base, and one offset.

In this PR, we use const generics to describe absolute MUX and PAD register addresses in Pad types. The types are still unique, since the absolute addresses are unique. There's less chance for a runtime cost for pointer offset, and we can reduce the size of all erased pads by four bytes.

Use tests from #21 and the doctests to show that most documented APIs are unchanged. Note that this PR targets #21's branch.

Drop the hidden Base trait; it's no longer necessary for describing the
start of a group range. We now fully compute the MUX and PAD address in
the type signature.

Since we represent absolute addresses in the type system, we can drop
the 'offset' memory in ErasedPads, gaining back four bytes.

Permit identity (multiply by 1), erasing (multiply by 0) operations in
auto-generated code.
We might have been able to marked this `const` the whole time. If the
parent commit is rejected, see if this could be backported.
@mciantyre mciantyre force-pushed the const-generic-padd-address branch from 8d50e33 to 323fbf6 Compare January 2, 2022 13:22
@mciantyre mciantyre mentioned this pull request Jan 2, 2022
Base automatically changed from pad-bound-tests to master January 2, 2022 22:52
@teburd
Copy link
Member

teburd commented Jan 2, 2022

very nice

@teburd teburd merged commit 1fe6126 into master Jan 2, 2022
@teburd teburd deleted the const-generic-padd-address branch January 2, 2022 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants