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

Gekko: Migrate register structs over to Common::BitField #10064

Merged
merged 17 commits into from Aug 30, 2021

Conversation

lioncash
Copy link
Member

Provides the same behavior, while also preventing undesirable type conversions and promotions on bitfield members in certain cases.

e.g.

union Thing
{
  u32 hex = 0;

  struct
  {
    u32 value_1 : 5;
    u32 padding : 27;
  };
};

void SomeFunction(const Thing& thing)
{
  // Assume the encoding stores some value - 1, so we add to get the full value
  const u32 data = thing.value_1 + 1;
}

The intuitive (and completely expected most of the time) reading of this would be to think that value_1 undergoes no type promotions or conversions, since everything is unsigned, however, this line:

  const u32 data = thing.value_1 + 1;

Actually results in value_1 being converted to an int, incremented, and then assigned to data, implicitly converting it back to a u32

UGQR was already using this as well, so this keeps the register layouts consistent as well.

Copy link
Member

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, 1 of 1 files at r2, 2 of 2 files at r3, 1 of 1 files at r4, 1 of 1 files at r5, 1 of 1 files at r6, 1 of 1 files at r7, 1 of 1 files at r8, 1 of 1 files at r9, 1 of 1 files at r10, 1 of 1 files at r11, 1 of 1 files at r12, 1 of 1 files at r13, 1 of 1 files at r14, 1 of 1 files at r15, 1 of 1 files at r16, 1 of 1 files at r17, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @lioncash)

@leoetlino leoetlino merged commit 271612f into dolphin-emu:master Aug 30, 2021
11 checks passed
@lioncash lioncash deleted the regs branch August 31, 2021 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants