An Intermediate Representation which can be compiled into WebAssembly

Related tags

WebAssembly wasm-ir
Overview

WebAssembly Intermediate Representation

License Maintenance Stability Crates.io latest version Crates.io total downloads Liberapay receiving

This is an Intermediate Representation which can be compiled into WebAssembly.

The source code is in an experimental state and will be fully documented in its final version.

Warning : we do not recommend to use this code in a production environment, even if it theoretically works we haven't finished writing tests to make sure everything works and avoid regressions.

The codebase is licensed under GNU Affero General Public License v3, you have the right to exploit this source code but it must remain open-source and under the same license, thanks for your support !

If you want to join the development and contribute to the project, please reach us at [email protected].

Todo

Values

  • u32
  • u64
  • s32
  • s64
  • f32
  • f64
  • v128
  • name

Types

  • u32
  • u64
  • s32
  • s64
  • f32
  • f64
  • v128
  • name
  • reference
    • function
    • extern
  • limit
  • function

Instructions

Control

  • unreachable
  • nop
  • block
  • if
  • else
  • br
  • br_if
  • br_table
  • return
  • call
  • call_indirect

Reference

  • ref.null
  • ref.is_null
  • ref.func

Parametric

  • drop
  • select
  • select t

Variable

  • local.get
  • local.set
  • local.tee
  • global.get
  • global.set

Table

  • table.get
  • table.set
  • table.init
  • elem.drop
  • table.copy
  • table.grow
  • table.size
  • table.fill

Memory

  • i32.load
  • i64.load
  • f32.load
  • f64.load
  • i32.load8_s
  • i32.load8_u
  • i32.load16_s
  • i32.load16_u
  • i64.load8_s
  • i64.load8_u
  • i64.load16_s
  • i64.load16_u
  • i64.load32_s
  • i64.load32_u
  • i32.store
  • i64.store
  • f32.store
  • f64.store
  • i32.store8
  • i32.store16
  • i64.store8
  • i64.store16
  • i64.store32
  • memory.size
  • memory.grow
  • memory.init
  • data.drop
  • memory.copy
  • memory.fill

Numeric

  • i32.const
  • i64.const
  • f32.const
  • f64.const
  • i32.eqz
  • i32.eq
  • i32.ne
  • i32.lt_s
  • i32.lt_u
  • i32.gt_s
  • i32.gt_u
  • i32.le_s
  • i32.le_u
  • i32.ge_s
  • i32.ge_u
  • i64.eqz
  • i64.eq
  • i64.ne
  • i64.lt_s
  • i64.lt_u
  • i64.gt_s
  • i64.gt_u
  • i64.le_s
  • i64.le_u
  • i64.ge_s
  • i64.ge_u
  • f32.eq
  • f32.ne
  • f32.lt
  • f32.gt
  • f32.le
  • f32.ge
  • f64.eq
  • f64.ne
  • f64.lt
  • f64.gt
  • f64.le
  • f64.ge
  • i32.clz
  • i32.ctz
  • i32.popcnt
  • i32.add
  • i32.sub
  • i32.mul
  • i32.div_s
  • i32.div_u
  • i32.rem_s
  • i32.rem_u
  • i32.and
  • i32.or
  • i32.xor
  • i32.shl
  • i32.shr_s
  • i32.shr_u
  • i32.rotl
  • i32.rotr
  • i64.clz
  • i64.ctz
  • i64.popcnt
  • i64.add
  • i64.sub
  • i64.mul
  • i64.div_s
  • i64.div_u
  • i64.rem_s
  • i64.rem_u
  • i64.and
  • i64.or
  • i64.xor
  • i64.shl
  • i64.shr_s
  • i64.shr_u
  • i64.rotl
  • i64.rotr
  • f32.abs
  • f32.neg
  • f32.ceil
  • f32.floor
  • f32.trunc
  • f32.nearest
  • f32.sqrt
  • f32.add
  • f32.sub
  • f32.mul
  • f32.div
  • f32.min
  • f32.max
  • f32.copysign
  • f64.abs
  • f64.neg
  • f64.ceil
  • f64.floor
  • f64.trunc
  • f64.nearest
  • f64.sqrt
  • f64.add
  • f64.sub
  • f64.mul
  • f64.div
  • f64.min
  • f64.max
  • f64.copysign
  • i32.wrap_i64
  • i32.trunc_f32_s
  • i32.trunc_f32_u
  • i32.trunc_f64_s
  • i32.trunc_f64_u
  • i64.extend_i32_s
  • i64.extend_i32_u
  • i64.trunc_f32_s
  • i64.trunc_f32_u
  • i64.trunc_f64_s
  • i64.trunc_f64_u
  • f32.convert_i32_s
  • f32.convert_i32_u
  • f32.convert_i64_s
  • f32.convert_i64_u
  • f32.demote_f64
  • f64.convert_i32_s
  • f64.convert_i32_u
  • f64.convert_i64_s
  • f64.convert_i64_u
  • f64.promote_f32
  • i32.reinterpret_f32
  • i64.reinterpret_f64
  • f32.reinterpret_i32
  • f64.reinterpret_i64
  • i32.extend8_s
  • i32.extend16_s
  • i64.extend8_s
  • i64.extend16_s
  • i64.extend32_s
  • i32.trunc_sat_f32_s
  • i32.trunc_sat_f32_u
  • i32.trunc_sat_f64_s
  • i32.trunc_sat_f64_u
  • i64.trunc_sat_f32_s
  • i64.trunc_sat_f32_u
  • i64.trunc_sat_f64_s
  • i64.trunc_sat_f64_u
  • v128.load
  • v128.load8x8_s
  • v128.load8x8_u
  • v128.load16x4_s
  • v128.load16x4_u
  • v128.load32x2_s
  • v128.load32x2_u
  • v128.load8_splat
  • v128.load16_splat
  • v128.load32_splat
  • v128.load64_splat
  • v128.load32_zero
  • v128.load64_zero
  • v128.store
  • v128.load8_lane
  • v128.load16_lane
  • v128.load32_lane
  • v128.load64_lane
  • v128.store8_lane
  • v128.store16_lane
  • v128.store32_lane
  • v128.store64_lane
  • v128.const
  • i8x16.shuffle
  • i8x16.extract_lane_s
  • i8x16.extract_lane_u
  • i8x16.replace_lane
  • i16x8.extract_lane_s
  • i16x8.extract_lane_u
  • i16x8.replace_lane
  • i32x4.extract_lane
  • i32x4.replace_lane
  • i64x2.extract_lane
  • i64x2.replace_lane
  • f32x4.extract_lane
  • f32x4.replace_lane
  • f64x2.extract_lane
  • f64x2.replace_lane
  • i8x16.swizzle
  • i8x16.splat
  • i16x8.splat
  • i32x4.splat
  • i64x2.splat
  • f32x4.splat
  • f64x2.splat
  • i8x16.eq
  • i8x16.ne
  • i8x16.lt_s
  • i8x16.lt_u
  • i8x16.gt_s
  • i8x16.gt_u
  • i8x16.le_s
  • i8x16.le_u
  • i8x16.ge_s
  • i8x16.ge_u
  • i16x8.eq
  • i16x8.ne
  • i16x8.lt_s
  • i16x8.lt_u
  • i16x8.gt_s
  • i16x8.gt_u
  • i16x8.le_s
  • i16x8.le_u
  • i16x8.ge_s
  • i16x8.ge_u
  • i32x4.eq
  • i32x4.ne
  • i32x4.lt_s
  • i32x4.lt_u
  • i32x4.gt_s
  • i32x4.gt_u
  • i32x4.le_s
  • i32x4.le_u
  • i32x4.ge_s
  • i32x4.ge_u
  • i64x2.eq
  • i64x2.ne
  • i64x2.lt_s
  • i64x2.gt_s
  • i64x2.le_s
  • i64x2.ge_s
  • f32x4.eq
  • f32x4.ne
  • f32x4.lt
  • f32x4.gt
  • f32x4.le
  • f32x4.ge
  • f64x2.eq
  • f64x2.ne
  • f64x2.lt
  • f64x2.gt
  • f64x2.le
  • f64x2.ge
  • v128.not
  • v128.and
  • v128.andnot
  • v128.or
  • v128.xor
  • v128.bitselect
  • v128.any_true
  • i8x16.abs
  • i8x16.neg
  • i8x16.popcnt
  • i8x16.all_true
  • i8x16.bitmask
  • i8x16.narrow_i16x8_s
  • i8x16.narrow_i16x8_u
  • i8x16.shl
  • i8x16.shr_s
  • i8x16.shr_u
  • i8x16.add
  • i8x16.add_sat_s
  • i8x16.add_sat_u
  • i8x16.sub
  • i8x16.sub_sat_s
  • i8x16.sub_sat_u
  • i8x16.min_s
  • i8x16.min_u
  • i8x16.max_s
  • i8x16.max_u
  • i8x16.avgr_u
  • i16x8.extadd_pairwise_i8x16_s
  • i16x8.extadd_pairwise_i8x16_u
  • i16x8.abs
  • i16x8.neg
  • i16x8.q15mulr_sat_s
  • i16x8.all_true
  • i16x8.bitmask
  • i16x8.narrow_i32x4_s
  • i16x8.narrow_i32x4_u
  • i16x8.extend_low_i8x16_s
  • i16x8.extend_high_i8x16_s
  • i16x8.extend_low_i8x16_u
  • i16x8.extend_high_i8x16_u
  • i16x8.shl
  • i16x8.shr_s
  • i16x8.shr_u
  • i16x8.add
  • i16x8.add_sat_s
  • i16x8.add_sat_u
  • i16x8.sub
  • i16x8.sub_sat_s
  • i16x8.sub_sat_u
  • i16x8.mul
  • i16x8.min_s
  • i16x8.min_u
  • i16x8.max_s
  • i16x8.max_u
  • i16x8.avgr_u
  • i16x8.extmul_low_i8x16_s
  • i16x8.extmul_high_i8x16_s
  • i16x8.extmul_low_i8x16_u
  • i16x8.extmul_high_i8x16_u
  • i32x4.extadd_pairwise_i8x16_s
  • i32x4.extadd_pairwise_i8x16_u
  • i32x4.abs
  • i32x4.neg
  • i32x4.all_true
  • i32x4.bitmask
  • i32x4.extend_low_i16x8_s
  • i32x4.extend_high_i16x8_s
  • i32x4.extend_low_i16x8_u
  • i32x4.extend_high_i16x8_u
  • i32x4.shl
  • i32x4.shr_s
  • i32x4.shr_u
  • i32x4.add
  • i32x4.sub
  • i32x4.mul
  • i32x4.min_s
  • i32x4.min_u
  • i32x4.max_s
  • i32x4.max_u
  • i32x4.dot_i16x8_s
  • i32x4.extmul_low_i16x8_s
  • i32x4.extmul_high_i16x8_s
  • i32x4.extmul_low_i16x8_u
  • i32x4.extmul_high_i16x8_u
  • i64x2.abs
  • i64x2.neg
  • i64x2.all_true
  • i64x2.bitmask
  • i64x2.extend_low_i32x4_s
  • i64x2.extend_high_i32x4_s
  • i64x2.extend_low_i32x4_u
  • i64x2.extend_high_i32x4_u
  • i64x2.shl
  • i64x2.shr_s
  • i64x2.shr_u
  • i64x2.add
  • i64x2.sub
  • i64x2.mul
  • i64x2.extmul_low_i32x4_s
  • i64x2.extmul_high_i32x4_s
  • i64x2.extmul_low_i32x4_u
  • i64x2.extmul_high_i32x4_u
  • f32x4.ceil
  • f32x4.floor
  • f32x4.trunc
  • f32x4.nearest
  • f32x4.abs
  • f32x4.neg
  • f32x4.sqrt
  • f32x4.add
  • f32x4.sub
  • f32x4.mul
  • f32x4.div
  • f32x4.min
  • f32x4.max
  • f32x4.pmin
  • f32x4.pmax
  • f64x2.ceil
  • f64x2.floor
  • f64x2.trunc
  • f64x2.nearest
  • f64x2.abs
  • f64x2.neg
  • f64x2.sqrt
  • f64x2.add
  • f64x2.sub
  • f64x2.mul
  • f64x2.div
  • f64x2.min
  • f64x2.max
  • f64x2.pmin
  • f64x2.pmax
  • i32x4.trunc_sat_f32x4_s
  • i32x4.trunc_sat_f32x4_u
  • f32x4.convert_i32x4_s
  • f32x4.convert_i32x4_u
  • i32x4.trunc_sat_f64x2_s_zero
  • i32x4.trunc_sat_f64x2_u_zero
  • f64x2.convert_low_i32x4_s
  • f64x2.convert_low_i32x4_u
  • f32x4.demote_f64x2_zero
  • f64x2.promote_low_f32x4

Module

  • Type
  • Import
    • Func
    • Table
    • Mem
    • Global
  • Function
  • Table
  • Memory
  • Global
  • Export
    • Func
    • Table
    • Mem
    • Global
  • Start
  • Element (except declarative)
  • Data count
  • Code
  • Data
  • Custom

Contributors

You might also like...
darkforest is a console and web-based Roguelike written in Rust and WebAssembly.
darkforest is a console and web-based Roguelike written in Rust and WebAssembly.

darkforest darkforest is a console and web-based Roguelike written in Rust and WebAssembly. Key Features TBA Quick Start TBA How To Contribute Contrib

WebAssembly to Lua translator, with runtime

This is a WIP (read: absolutely not ready for serious work) tool for translating WebAssembly into Lua. Support is specifically for LuaJIT, with the se

Simple file sharing with client-side encryption, powered by Rust and WebAssembly
Simple file sharing with client-side encryption, powered by Rust and WebAssembly

Hako Simple file sharing with client-side encryption, powered by Rust and WebAssembly Not feature-packed, but basic functionalities are just working.

bn.js bindings for Rust & WebAssembly with primitive-types support

bn.rs bn.js bindings for Rust & WebAssembly with primitive-types support Write Rust code that uses BN use std::str::FromStr; use primitive_types::{H1

A handy calculator, based on Rust and WebAssembly.
A handy calculator, based on Rust and WebAssembly.

qubit 💥 Visit Website To Use Calculator Example 💥 Visit Website To Use Calculator 2 + 2

A simple compile-to-WebAssembly language rewritten in Rust

chasm A very simple compile-to-WebAssembly language You can play with chasm online. This is a rewrite in Rust of the compiler for the language chasm.

Webassembly binding for Hora Approximate Nearest Neighbor Search Library
Webassembly binding for Hora Approximate Nearest Neighbor Search Library

hora-wasm [Homepage] [Document] [Examples] [Hora] Javascript bidding for the Hora Approximate Nearest Neighbor Search, in WebAssembly way. Features Pe

Stylist is a CSS-in-Rust styling solution for WebAssembly Applications.

Stylist Stylist is a CSS-in-Rust styling solution for WebAssembly Applications. This is a fork of css-in-rust. Install Add the following to your Cargo

A template project to demonstrate how to run WebAssembly functions as sidecar microservices in dapr
A template project to demonstrate how to run WebAssembly functions as sidecar microservices in dapr

Demo and tutorials Live Demo | Tutorial article | Tutorial video 1. Introduction DAPR is a portable, event-driven runtime that makes it easy for any d

Comments
  • Stacked Instructions

    Stacked Instructions

    Until now, intructions take operands from new()'s parameters, but sometimes we want to take them from the stack. A new constructor named stacked() has been added, which does not provide operands. Does anyone has a better name for this function ? When the type of the operands is Vec (such as Call), stacked does not exist since the user can give an empty vec. What do you think ? When there are multiple operands, but not in a Vec (such as I32Store), do we need to add another function to deal with the case where one is provided, but not the other ? What do we do if there is a missing operand ?

    (i32.const 420)
    // none
    (i32.store)
    
    enhancement 
    opened by vulc41n 1
  • Local builder

    Local builder

    Dealing with locals could be difficult because indexes change according to how many parameters the function has. Indexes are now abstract, and assigned at generation. The builder also group locals by their type so it takes less space and computation.

    opened by vulc41n 0
Owner
Blue Forest
Cultivons ensemble vos idées
Blue Forest
Contains the source code to compile the drop'in language into WebAssembly files

drop'in compiler This repository contains the source code to compile the drop'in language into WebAssembly files. This source code is in an experiment

Blue Forest 2 Dec 17, 2022
A prototype WebAssembly linker using module linking.

WebAssembly Module Linker Please note: this is an experimental project. wasmlink is a prototype WebAssembly module linker that can link together a mod

Peter Huene 19 Oct 28, 2022
Sealed boxes implementation for Rust/WebAssembly.

Sealed boxes for Rust/WebAssembly This Rust crate provides libsodium sealed boxes for WebAssembly. Usage: // Recipient: create a new key pair let reci

Frank Denis 16 Aug 28, 2022
WebAssembly on Rust is a bright future in making application runs at the Edge or on the Serverless technologies.

WebAssembly Tour WebAssembly on Rust is a bright future in making application runs at the Edge or on the Serverless technologies. We spend a lot of ti

Thang Chung 129 Dec 28, 2022
WebAssembly modules that use Azure services

This is an experimental repository containing WebAssembly modules running on top of WAGI (WebAssembly Gateway Interface, which allows you to run WebAssembly WASI binaries as HTTP handlers) and using Azure services.

null 7 Apr 18, 2022
WebAssembly Service Porter

WebAssembly Service Porter.

henrylee2cn 12 Dec 12, 2022
🚀Wasmer is a fast and secure WebAssembly runtime that enables super lightweight containers to run anywhere

Wasmer is a fast and secure WebAssembly runtime that enables super lightweight containers to run anywhere: from Desktop to the Cloud, Edge and IoT devices.

Wasmer 14.1k Jan 8, 2023
WAGI: WebAssembly Gateway Interface

Write HTTP handlers in WebAssembly with a minimal amount of work

null 724 Jan 6, 2023
A console and web-based Gomoku written in Rust and WebAssembly

?? rust-gomoku A console and web-based Gomoku written in Rust and WebAssembly Getting started with cargo & npm Install required program, run # install

namkyu1999 2 Jan 4, 2022
WebAssembly development with Trunk & Vite.js

Trunk & Vite.js Demo Trunk is a WASM web application bundler for Rust, and Vite.js is next Generation Frontend Tooling. Ok, they are together now for

Libing Chen 6 Nov 24, 2021