This commit is contained in:
Chris Fallin 2021-11-13 17:52:30 -08:00
parent 0eb41cb0a3
commit eab9e60338
5 changed files with 21 additions and 9 deletions

View file

@ -1,10 +1,9 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use waffle::frontend::wasm_to_ir;
use wasm_smith::Module;
use waffle::Module;
fuzz_target!(|module: Module| {
fuzz_target!(|module: wasm_smith::Module| {
let _ = env_logger::try_init();
let _parsed_module = wasm_to_ir(&module.to_bytes()[..]).unwrap();
let _parsed_module = Module::from_wasm_bytes(&module.to_bytes()[..]).unwrap();
});

View file

@ -4,7 +4,7 @@ use anyhow::Result;
use log::debug;
use std::path::PathBuf;
use structopt::StructOpt;
use waffle::frontend;
use waffle::Module;
#[derive(Debug, StructOpt)]
#[structopt(name = "waffle-util", about = "WAFFLE utility.")]
@ -38,7 +38,7 @@ fn main() -> Result<()> {
Command::PrintIR { wasm } => {
let bytes = std::fs::read(wasm)?;
debug!("Loaded {} bytes of Wasm data", bytes.len());
let module = frontend::wasm_to_ir(&bytes[..])?;
let module = Module::from_wasm_bytes(&bytes[..])?;
println!("{:?}", module);
}
}

View file

@ -1,5 +1,7 @@
//! Intermediate representation for Wasm.
use crate::frontend;
use anyhow::Result;
use wasmparser::{FuncType, Operator, Type};
pub type SignatureId = usize;
@ -119,3 +121,9 @@ impl<'a> std::default::Default for Terminator<'a> {
Terminator::None
}
}
impl<'a> Module<'a> {
pub fn from_wasm_bytes(bytes: &'a [u8]) -> Result<Self> {
frontend::wasm_to_ir(bytes)
}
}

View file

@ -5,6 +5,9 @@
pub use wasm_encoder;
pub use wasmparser;
pub mod frontend;
pub mod ir;
pub mod op_traits;
mod frontend;
mod ir;
mod localssa;
mod op_traits;
pub use ir::*;

2
src/localssa.rs Normal file
View file

@ -0,0 +1,2 @@
//! Local-to-SSA conversion.