Skip to content

WASM: complex numbers #1519

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

Closed
Tracked by #1485
certik opened this issue Feb 14, 2023 · 1 comment · Fixed by #1527
Closed
Tracked by #1485

WASM: complex numbers #1519

certik opened this issue Feb 14, 2023 · 1 comment · Fixed by #1527
Labels

Comments

@certik
Copy link
Contributor

certik commented Feb 14, 2023

Add complex numbers and operations on them.

@certik certik added the wasm label Feb 14, 2023
@certik certik mentioned this issue Feb 14, 2023
23 tasks
@certik
Copy link
Contributor Author

certik commented Feb 14, 2023

There are several ways to implement it.

In the backend

Just create a WASM function complex_add(), which accepts the two operands a,b on stack and returns the result on stack (this function is implemented in asr_to_wasm directly using wasm instructions). Each complex number is represented by two floating point numbers on stack.

Using ASR->ASR pass

This pass would work similarly to pass_compare.cpp which inserts new ASR functions (to global scope) to implement a given operation (and only inserts it once and reuses it everywhere).

Surface language

The code for complex operations can also be implemented in the surface language. This approach is almost equivalent to the previous ASR->ASR pass approach, except that the operations are not implemented directly in ASR but rather in the surface language and compiled to ASR. We can for example maintain a precompiled version of such functions in the .mod file format that is just serialized ASR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant