Skip to content

stage2,aarch64: basic overflow arithmetic support #11574

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

Merged
merged 9 commits into from
May 5, 2022
Merged

Conversation

kubkon
Copy link
Member

@kubkon kubkon commented May 3, 2022

In collaboration with @joachimschmidt557

Checklist:

  • add_with_overflow
  • sub_with_overflow
  • shl_with_overflow
  • mul_with_overflow

@joachimschmidt557 and @Luukdegram - seems I have given our three more work as now only aarch64 backend (excluding LLVM ofc) passes extended @mulWithOverflow tests ;-)

Unblocks the aarch64 part of @wsengir's #11316

@kubkon kubkon force-pushed the stage2-aarch64 branch from 385c492 to 6a78a14 Compare May 3, 2022 18:53
@kubkon kubkon marked this pull request as ready for review May 4, 2022 21:13
@kubkon kubkon force-pushed the stage2-aarch64 branch from 06f58fc to 0995143 Compare May 4, 2022 22:11
@Luukdegram
Copy link
Contributor

Great work on the extended test. I will do my best to make them pass for the Wasm backend on Friday.

@kubkon kubkon force-pushed the stage2-aarch64 branch from 0995143 to eab5a1b Compare May 5, 2022 19:43
Copy link
Contributor

@joachimschmidt557 joachimschmidt557 left a comment

Choose a reason for hiding this comment

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

Looks good to me, apart from some suspicious to32() and to64()s

Comment on lines 1063 to 1066
.smulh => try emit.writeInstruction(Instruction.smulh(rrr.rd.to64(), rrr.rn.to64(), rrr.rm.to64())),
.smull => try emit.writeInstruction(Instruction.smull(rrr.rd.to64(), rrr.rn.to32(), rrr.rm.to32())),
.umulh => try emit.writeInstruction(Instruction.umulh(rrr.rd.to64(), rrr.rn.to64(), rrr.rm.to64())),
.umull => try emit.writeInstruction(Instruction.umull(rrr.rd.to64(), rrr.rn.to32(), rrr.rm.to32())),
Copy link
Contributor

Choose a reason for hiding this comment

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

The to32()s and to64()s should not be here. Mir should always consist of valid assembly instructions with valid register sizes and it should be CodeGens job to ensure that. Emit can assume that the register sizes are all valid and shouldn't need to change them

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed 100%! Lemme fix this!

try self.spillCompareFlagsIfOccupied();
self.compare_flags_inst = null;

// TODO this should really be put in a helper similar to `binOpRegister`
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed 👍

@kubkon kubkon merged commit 13d1798 into master May 5, 2022
@kubkon kubkon deleted the stage2-aarch64 branch May 5, 2022 20:50
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.

3 participants