Skip to content

WASM: complex numbers #1519

Closed
Closed

Description

@certik

Add complex numbers and operations on them.

Activity

  1. certik commented on Feb 14, 2023

    @certik
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions