-
Notifications
You must be signed in to change notification settings - Fork 404
[Moore] Add builtin for $urandom #8968
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
fabianschuiki
left a comment
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.
LGTM! Just a minor nit about moving the type constraint into MooreTypes.td. Thanks for adding this! 🙂
|
Move the new Type to |
This PR adds support for `$random` system calls and maps them to a new Moore builtin-op `RandomBIOp`. Implementation is very much along the lines of [the $urandom implementation](llvm#8968). I chose to not map $random and $urandom to the same builtin as they are semantically different, $urandom being pseudo-random, $random being true-random.
This PR adds support for `$random` system calls and maps them to a new Moore builtin-op `RandomBIOp`. Implementation is very much along the lines of [the $urandom implementation](#8968). I chose to not map $random and $urandom to the same builtin as they are semantically different, $urandom being pseudo-random, $random being true-random.
First time I try to add a new Op, so let me know if I went wrong somewhere!
This PR adds a new builtin in moore for the $urandom system call.
Per the newest version of the spec, $urandom may be called with or with a integer seed argument, and always returns an integer produced by a pseudo-random number generator.
As such I added an importer conversion and tests for both cases; the allowed expressions are
I struggled a bit with constraining the output type of
moore.builtin.urandom, since it is constant. I addedin place to constrain an IntType to be exactly a moore.i32 for this purpose, but please let me know if there is a smarter way; this seems a bit cumbersome.