-
Notifications
You must be signed in to change notification settings - Fork 227
avr: implement unsigned division intrinsics #816
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
Conversation
d05d6cd
to
cef6cac
Compare
Pinging @Patryk27 for testing assistance. As indicated in the description, I've validated the algorithm with |
cef6cac
to
bea0c78
Compare
Ok, I've checked the code under avr-tester's testsuite and it seems to work, nice job! One thing left to check is whether all AVRs support the instructions here (don't know by heart which ones belong to the base instruction set). |
Thanks for testing @Patryk27 . I referenced Microchip's AVR ISA for the opcodes. I think we should be good since none of the instructions used are listed as "N/A" in the chapter 5 tables. The gcc implementation uses macros to conditionally switch between If you're willing to mentor a bit I'd be interested in trying to help improve the AVR codegen (but don't have any LLVM-specific dev experience). |
That'd be nice, but I think it's sort of gray area in this specific case - I'm pretty sure that So even if there was an AVR peephole optimization pass within LLVM, I'm pretty sure it wouldn't / couldn't be activated in this case; if we want to handle it, we should probably do it explicitly in here (using |
bea0c78
to
d8276bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I double checked the clobbers and they seem to line up for both the default calling convention and for reduced tiny. I didn't check the routines in depth but they look reasonable to me.
Thanks for getting this started!
This PR adds a missing AVR intrinsic for 8-bit unsigned division (see #711) and is based on the popular [long division](https://en.wikipedia.org/wiki/Divisio n_algorithm#Long_division) algorithm.
GCC uses a special calling convention for multiplication and division primitives, requiring a
naked_asm
implementation.This implementation attempts to be an assembly port of the following Rust implementation of the long division algorithm.