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

compiler-rt: alu: add remainder for i8 #131

Merged
merged 2 commits into from
Jan 23, 2025
Merged

compiler-rt: alu: add remainder for i8 #131

merged 2 commits into from
Jan 23, 2025

Conversation

wzmuda
Copy link
Contributor

@wzmuda wzmuda commented Jan 23, 2025

Summary

Implement the following polyfills:

  • __llvm_urem_i8_i8
  • __llvm_srem_i8_i8

Details

srem is basically sdiv with an extra step so I abstracted division with remainder to a separate function and both polyfills are implemented with it.

Checklist

  • Code is formatted by Rustfmt or scarb fmt.
  • Documentation has been updated if necessary.

Implement the following polyfill:
- `__llvm_urem_i8_i8`

Signed-off-by: Wojciech Zmuda <zmuda.w@gmail.com>
@wzmuda wzmuda self-assigned this Jan 23, 2025
@wzmuda wzmuda requested a review from a team as a code owner January 23, 2025 22:42
Copy link
Collaborator

@iamrecursion iamrecursion left a comment

Choose a reason for hiding this comment

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

LGTM!

compiler-rt/src/alu/sdiv.cairo Show resolved Hide resolved
Implement the following polyfill:
- `__llvm_srem_i8_i8`

The implementation is done by extending the existing sdiv implementation
by the calculation of a remainder and then using that
division-with-reminder calculation for both `__llvm_srem_i8_i8` and
`__llvm_sdiv_i8_i8` to avoid code duplication.

Signed-off-by: Wojciech Zmuda <zmuda.w@gmail.com>
@wzmuda wzmuda merged commit f80196d into main Jan 23, 2025
10 checks passed
@wzmuda wzmuda deleted the wz/8b-arith-rem branch January 23, 2025 23:25
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