Skip to content

Conversation

@mkj
Copy link
Contributor

@mkj mkj commented Feb 28, 2025

This saves ~800 bytes of code size from a current project (cortex M7, opt "s" or "z"), and uses a lot fewer cycles.
I'm pushing this as a draft PR, if you like the approach I could change the other bitfields similarly.

This does change the API a bit, instead of hdr.0 you use hdr.to_bytes(), and the MCTPTransportHeader no longer has the type parameter MCTPTransportHeader<[u8; 4]>.

This compiles to much more efficient code in the bitfield operations.

The code I'm testing with is fairly simple, setting a few headers similar to:

        let mut header = MCTPTransportHeader::new(1);
        header.set_dest_endpoint_id(dest);
        header.set_source_endpoint_id(src);
        header.set_pkt_seq(seq);
        if self.first {
            header.set_som(first);
        }
        header.set_msg_tag(tag);
        header.set_to(is_owner);

This compiles to much more efficient code in the bitfield operations.
@alistair23
Copy link
Collaborator

I'm fine with the change. Saving code size is great!

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