-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add value<->native_pointer intrinsics #855
Conversation
Co-authored-by: Xavier Clerc <[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.
I think we may need to update Selectgen.oper_result_type
Wouldn't the typing come from the |
no, that's wrong. |
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.
@TheNumbat you were right, we do need some conversion operation in Cmm.transl_builtin because the type changes between int and val need to be recorded (to correctly hanlde them in the frametable). We should add Cmm.valuofint and Cmm.intofval (similar to Cmm.intoffloat and inttofloat) and the important case to implement is in Selectgen.oper_result_type.
I added valueofint and intofvalue throughout the backend, and confirmed it still works with my updated intrinsics. They're mostly handled like intoffloat and floatofint, but are treated like opaque_identity for the purposes of register allocation and code emission. I don't have a test case checking that this fixes an issue with frametable handling, though, so not entirely sure if this is what we want yet. Can someone suggest how to test that? Also, the upstream build CI check fails now - how should I apply these changes to ocaml/? |
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.
Looks good, I just have a few comments.
- Please make the PR "ready for review" (not draft).
- fixing 32-bit builds: the new operations should only be added in backend subdirectory, don't don't change anything in ocaml/asmcomp
- adjust testsuite/tool/parsecmm.mly and lexcmm.mll (it is probably not necessary for the tests in testsuite/tests/asmgen/ to pass because they don't use the new primitives yet, but adding a little test there would be nice).
- we don't need to add clambda primitives, there should be no changes in middle_end subdirectory. The only way the new operations can be created is via the new intrinsic. So, no need to change
cmmgen.ml
either (onlycmm_helpers.ml
). - update backend/CSEgen similarly to floatofint and intoffloat (it's missing probably because warning 8 exhaustive match isn't on in that file).
- No need to expose the new functions in
cmm_helpers.mli
, they are not used outside ofcmm_helpers.ml
Hmm I don't understand the |
I don't think so, I also have a comment about it. |
I've addressed the comments, though I believe backend/CSEgen.ml was already updated (?). |
yes, I somehow missed it, sorry. |
I don't have a good way to test that, and it is a bit worrying |
We can already see from |
Although, fundamentally, having a way |
(to be clear, I am not saying that |
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.
The purity-related changes should happen
in this PR, but the rest can be delayed.
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.
The current version looks good to me.
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.
The arm64 concern should be addressed
(or proved wrong); the rest looks good.
@xclerc this has been addressed |
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.
The code duplication introduced by the last commit
is a bit unfortunate, but can be addressed in another
pull request.
Implements builtins
caml_native_pointer_of_value
andcaml_native_pointer_to_value
.I've confirmed this passes the tests in my version of the intrinsics library.