-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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 module to the stdlib with wrapper functions for common (all?) opcodes #1074
Comments
I'm not a huge fan of ASM blocks in general, but especially in the core & std libs. They definitely have their place, but they end up being black boxes as far as non-trivial optimisations go (i.e., in the IR stage). They can be quite buggy too, as they're not type checked and make assumptions about compiler codegen, which could change in the future (and probably should change as Sway matures) but we wouldn't necessarily notice them breaking if they did. Introducing compiler 'intrinsics' -- typed functions which are axiomatically provided by the compiler -- which essentially wrap around useful special case opcodes, like those for hashing or copying memory, would prevent breaks based on assumptions and allow the IR to do its job. Some GCC examples to illustrate what I mean: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Other-Builtins.html#Other-Builtins |
@otrho Should we move this issue to the sway repo if the idea is to implement as part of the compile rather than as std-lib functions? |
We could have a twin in the Sway repo I think. It doesn't make as much sense to have these until we've switched to IR as the default, so yeah, high priority but pretty much blocked until then. |
I'm thinking we should start by transforming the implementation of all core ops into intrinsics (instead of asm blocks) that become IR instructions such as |
|
I'm going to close this given that we have such wrappers in the form of intrinsics for most of the useful opcodes that need them. We are now adding new intrinsics as the need arises. |
Like FuelLabs/sway-lib-std#38 , the goal here would be to minimize the usage of assembly needed while building out the stdlib (and other libraries) by providing utilities for calling opcodes in a simpler way (in terms of writing , reviewing and reading/maintaining).
wrapper functions could be chained together to achieve whatever is needed for the current task at hand.
Idea by @otrho .
enable_overfow()
anddisable_overflow()
fromU128
type module.The text was updated successfully, but these errors were encountered: