-
Notifications
You must be signed in to change notification settings - Fork 242
implement floor
and ceil
in assembly on i586
#976
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
base: master
Are you sure you want to change the base?
Conversation
b202474
to
159feb2
Compare
159feb2
to
e04e38d
Compare
This is awesome, thank you for implementing it! There is one problem, our |
Fix for the red CI in #979 btw |
Well, I don't know this target and its assembly that well. So using I think the only downside is that the symbols might be visible from the outside? Is that a problem? |
actually we can prevent even that with a trick that Björn showed me recently using |
e04e38d
to
1680fd8
Compare
from what I can find this is a 2024 edition thing
but rust 1.63 won't compile |
I think it may be, also conflicts (though we could make it weak). But this should be pretty easy to move to inline asm; I think something like this would work https://rust.godbolt.org/z/P98rKEW7P, which is reasonably close to the original (not sure if there's a way to turn pointers to locals into stack offsets, to avoid the |
1680fd8
to
1766d1e
Compare
That's probably fine, we can fix that properly once naked functions are available we now get errors like this?
|
You're clobbering the saved control word on the stack with the modified one, so it isn't restored correctly. I think there's an argument for using a fixed control word for the |
"movw %dx, ({cw_ptr})", // Apply cw | ||
"fldcw ({cw_ptr})", // ... |
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.
Sorry, yeah, as @quaternic mentioned this needs a second stack slot. As a microopt this could be let mut cw_stash = [0u16; 2];
and then these accesses can be -4({stash_ptr})
so we save a register vs. two different u16
locals
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.
Actually even better, let mut cw_stash = MaybeUninit::<[u16; 2]>::uninit();
to save the zero init instruction
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 got this to work
https://rust.godbolt.org/z/44Tjcx3bb
the -4
stuff didn't work (also, for u16
, why -4
?)
1766d1e
to
8dd28c9
Compare
fixes #837
The assembly is based on
Which both state
Which I believe means we're good in terms of licensing.