Skip to content

Conversation

@braw-lee
Copy link
Contributor

fixes #3111

added some comments on both rust and cpp side
i am not sure about the terminology used in bit manipulation, pls suggest improvements if any
i didn't name the hard-coded constants (1 and 0x7FFF) yet
do we need to name them or the explanation in comments seems enough?
@P-E-P

gcc/rust/ChangeLog:

	* checks/errors/borrowck/polonius/rust-polonius.h (struct FullPoint):
	Added comments and made extraction of statement more verbose for
	better understanding.
	* checks/errors/borrowck/ffi-polonius/src/lib.rs: Likewise.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
@P-E-P
Copy link
Member

P-E-P commented Jul 31, 2024

added some comments on both rust and cpp side

Nice, it really lacked some

i am not sure about the terminology used in bit manipulation, pls suggest improvements if any

Looks fine, probably a tiny teensy overly verbose but I still like it like that.

i didn't name the hard-coded constants (1 and 0x7FFF) yet do we need to name them or the explanation in comments seems enough? @P-E-P

It is already clear enough with the comments, I'll put here what I would have written myself but this is meant as an example for you to get a rough idea, not because I want you to change your code. This is a community project, not @P-E-P 's personal project 😄

// probably in a namespace or something so those values don't slip everywhere in the project
constexpr uint32_t BASIC_BLOCK_OFFSET = 16;
constexpr uint32_t BASIC_BLOCK_MASK = 0xFFFF;

constexpr uint32_t STATEMENT_OFFSET = 1;
constexpr uint32_t STATEMENT_MASK = 0x7FFF;

// [...]

return (point >> STATEMENT_OFFSET) & STATEMENT_MASK;

What you've written is fine, that's just a different way of doing it. Some people would probably have written a union over Point and a bitfield struct or something.

@P-E-P P-E-P requested review from CohenArthur and P-E-P July 31, 2024 12:00
@P-E-P P-E-P added this pull request to the merge queue Jul 31, 2024
Merged via the queue into Rust-GCC:master with commit d6a7e71 Jul 31, 2024
@braw-lee
Copy link
Contributor Author

braw-lee commented Aug 1, 2024

ah that looks much better, now I feel like copy pasting this 😄

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.

Improve compressed point bit manipulation

2 participants