Skip to content

WASM and SSA form? #151

Closed
Closed

Description

@drom

May be a question here? Can WebAssembly format hold Static Single Assignment (SSA) based representation? Does it have opcode for the Phi function?

Activity

  1. sunfishcode commented on Oct 24, 2015

    @sunfishcode
    Member

    WebAssembly's local variables are not in SSA form; one can use set_local to reassign them new values at any time. SSA-based compilers can lower into non-SSA form when targeting WebAssembly. Many existing SSA-based compilers that target machine code will already have the ability to do this.

    WebAssembly's expression trees do effectively provide a form of SSA, but they are limited to values that are only used once.

  2. drom commented on Oct 24, 2015

    @drom
    Author

    @sunfishcode I guess my question is: does WASM has all needed opcodes to store SSA formed code, if someone need to? And will it be beneficial to have such option?

  3. sunfishcode commented on Oct 24, 2015

    @sunfishcode
    Member

    @drom WebAssembly does not have phi functions. Compilers will need to lower these as part of lowering into non-SSA form. As I mentioned above, compilers built to target machine code will usually have support for doing this already, so there isn't a strong producer-side motivation to add phi functions to WebAssembly.

    WebAssembly does have all the operators needed to support code lowered from SSA form though. I am building a WebAssembly backend for an SSA-based compiler, for example. It relies on the compiler's existing platform-independent support for lowering SSA form, including phi functions, into non-SSA form.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions