From 6bb4f42f6d56970ed2964c1bfd9849f63937fe39 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Fri, 12 Nov 2021 22:16:54 -0800 Subject: [PATCH] Skeleton of IR. --- Cargo.toml | 11 +++++++++++ src/ir.rs | 25 +++++++++++++++++++++++++ src/lib.rs | 8 ++++++++ 3 files changed, 44 insertions(+) create mode 100644 Cargo.toml create mode 100644 src/ir.rs create mode 100644 src/lib.rs diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..a9c1fed --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "waffle" +version = "0.0.1" +description = "Wasm Analysis Framework For Lightweight Experiments" +author = ["Chris Fallin "] +license = "Apache-2.0 WITH LLVM-exception" +edition = "2018" + +[dependencies] +wasmparser = "0.81" +wasm-encoder = "0.3" diff --git a/src/ir.rs b/src/ir.rs new file mode 100644 index 0000000..556b0e0 --- /dev/null +++ b/src/ir.rs @@ -0,0 +1,25 @@ +//! Intermediate representation for Wasm. + +use wasmparser::{FuncType, Type}; + +pub type SignatureId = usize; +pub type FuncId = usize; + +#[derive(Clone, Debug)] +pub struct Module { + pub funcs: Vec, + pub signatures: Vec, +} + +#[derive(Clone, Debug)] +pub enum FuncDecl { + Import(SignatureId), + Body(SignatureId, Function), +} + +#[derive(Clone, Debug)] +pub struct Function { + pub id: FuncId, + pub signature: SignatureId, + pub locals: Vec, +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..01e38da --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,8 @@ +//! WAFFLE Wasm analysis framework. + +// Re-export wasmparser and wasmencoder for easier use of the right +// version by our embedders. +pub use wasmparser; +pub use wasm_encoder; + +pub mod ir;