Skip to content

wasm2c: Support saturating-float-to-int #1680

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

Conversation

SoniEx2
Copy link
Collaborator

@SoniEx2 SoniEx2 commented Jun 26, 2021

No description provided.

@SoniEx2
Copy link
Collaborator Author

SoniEx2 commented Jun 28, 2021

(Same caveats with --disable-* flags as #1679 apply. This was fairly trivial tho, it was basically a matter of copy-paste.)

#define I32_TRUNC_SAT_S_F64(x) TRUNC_SAT_S(u32, s32, f64, -2147483649., INT32_MIN, >, 2147483648., INT32_MAX, x)
#define I64_TRUNC_SAT_S_F64(x) TRUNC_SAT_S(u64, s64, f64, (f64)INT64_MIN, INT64_MIN, >=, (f64)INT64_MAX, INT64_MAX, x)

#define TRUNC_SAT_U(ut, ft, max, smax, x) \
Copy link
Member

Choose a reason for hiding this comment

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

what does s mean in smax? from the code it looks like the integer / non-float maximum, but I'm not able to guess at what s is an abbreviation of...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

saturated was what we were thinking at the time.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see.. yes, that makes sense!

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Looks correct to me. Corner cases with this stuff are pretty tricky to review for, but as the spec tests pass this should be good, and it will also get fuzzed.

#define I32_TRUNC_SAT_S_F64(x) TRUNC_SAT_S(u32, s32, f64, -2147483649., INT32_MIN, >, 2147483648., INT32_MAX, x)
#define I64_TRUNC_SAT_S_F64(x) TRUNC_SAT_S(u64, s64, f64, (f64)INT64_MIN, INT64_MIN, >=, (f64)INT64_MAX, INT64_MAX, x)

#define TRUNC_SAT_U(ut, ft, max, smax, x) \
Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see.. yes, that makes sense!

@kripken kripken merged commit b97dd59 into WebAssembly:main Jun 29, 2021
@SoniEx2 SoniEx2 deleted the feature/wasm2c-satuaring-float-to-int branch June 29, 2021 01:32
SoniEx2 added a commit to SoniEx2/wasm2kotlin that referenced this pull request Feb 22, 2022
sbc100 pushed a commit that referenced this pull request Feb 22, 2022
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