-
Notifications
You must be signed in to change notification settings - Fork 232
WIP: Implement signed/unsigned Integer convertion to single/double precision float #121
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
Signed-off-by: Wilfried Chauveau <[email protected]>
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.
Awesome! LGTM. Travis is having some problems today but I'll r+ this tomorrow or whenever that's fixed.
P.S. The aeabi_ui2d function should use the AAPCS calling convention but we can do that change in a follow up PR (there are a bunch of symbols that use the wrong calling convention on ARM cf #116. We should do all those in a single PR)
@@ -6,30 +6,63 @@ pub mod udiv; | |||
|
|||
/// Trait for some basic operations on integers | |||
pub trait Int { | |||
type UnsignedInt; |
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.
Could you add a comment here? "Unsigned version of Self" or something
/// Returns the bitwidth of the int type | ||
fn bits() -> u32; | ||
fn init_float(self) -> (bool, Self::UnsignedInt); |
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.
Could you add a comment here as well? What does this do and where it's used.
Hi, I am currently testing the float->(u)int conversions and will push them on another PR. |
Won't this cause issues with licensing and GPL? :/ https://www.gnu.org/licenses/gpl-faq.html#TranslateCode The reason this project is under the "University of Illinois/NCSA Open Source License" is because we're translating code from compiler-rt which has that license. |
Hm, well, I learnt how the conversion is made the hard way (by reading the macro-ception in GCC). I can still make an update to remove any ambiguity and even use the same variables' names. EDIT: I noticed that I also forgot to check u64 to f32 conversion. |
☔ The latest upstream changes (presumably #128) made this pull request unmergeable. Please resolve the merge conflicts. |
Hi, sorry, I'm working on this impl : https://github.com/ithinuel/compiler-builtins/tree/conv_from_llvm?files=1 |
Hi there, just so you know, I'm back online. |
@japaric yes I do! Right now this PR adds int -> float which is great (Can't tell yet whether it works yet, will know when I've tried...). I would need float -> int as well. |
@est31 That is actually what I am adding to this PR (with an approch closer to the compiler-rt's algorithm). Though, i am facing an issue with float->int. |
Is that on some specific architecture? ARM? And how off is the result? few bits? |
It is my VM
(( I still can't use ci/run-docker.sh for some reason, probably a missing package on my setup )). EDIT: Actually I dont understand (yet) what are the rules to handle values that are out of (u)integer's ranges. |
signature:
This value doesn't fit in a 64-bit integer. I don't know how your implementation handles it but this kind of conversion is currently UB in Rust. I'm not sure how GCC handles it; it seems it's returing I think that we should reduce the input test range to |
According to C99 clause 6.3.1.4
GCC seems to be returning |
I don't think the intrinsics are the correct place to fix this UB because not all platforms use the intrinsics to do int <-> float conversion so panicking inside the intrinsics would lead to the inconsistency where some platforms are protected and others simply end up hitting UB which can lead to sense of false confidence (e.g. you only test on a protected platform but also deploy on one of the UB platforms without testing it). This UB problem has to be fixed in |
New version on #139. |
121: Implement atan r=japaric a=derekdreery New version of PR Co-authored-by: Richard Dodd <[email protected]>
Implements :
add the "alias" __aeabi_ui2d -> __floatunsidf