Skip to content

Conversation

burrbull
Copy link
Member

@therealprof

Can you tests this change. It adds offset into proxy structure according #115 and can reduce code size in some cases.
It's interesting how debug builds react on this.

@rust-highfive
Copy link

r? @Emilgardis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-tools labels Jul 27, 2019
@burrbull
Copy link
Member Author

r? @therealprof

изображение

@therealprof
Copy link
Contributor

Sure, I'll give it a shot.

@therealprof
Copy link
Contributor

Increases code size on dev builds usually by around 10 percent, no change on release builds.

@burrbull
Copy link
Member Author

So we have to wait const generics for third part from #331 (comment)

@therealprof
Copy link
Contributor

Have you tried factoring the bits function into a generic bits function, à la:

fn bits_u32 (self, value: u32, field: u32, mask: u32, offset: usize) -> u32 {
    value &= !(mask << offset);
    value |= ((field as u32) & mask) << offset;
    value
}

and calling that instead?

@burrbull
Copy link
Member Author

I don't see how this can help.

@therealprof
Copy link
Contributor

Well, we're trying to find a solution for two different problems:

  1. For dev builds we need to have the least amount of code because it won't be optimised away under any circumstance; huge amounts of could and also repetitive code are very bad here
  2. For release builds we're interested in having code which the compiler can properly optimise; repetitive code doesn't matter but if we get rid of it it must be done in a way that the compiler can still see how to get rid of it again

@burrbull
Copy link
Member Author

I agree with the goals. It is easy to implement generic code for readers as they don't have feedback with registers, but it’s harder for writers.
Field writers produce register writers and have different offsets.

@burrbull burrbull closed this Jul 29, 2019
@burrbull burrbull deleted the offset-in-proxy branch August 1, 2019 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants