Skip to content

Commit

Permalink
ISLE: upstream prototype ISLE verifier (Crocus) (bytecodealliance#9178)
Browse files Browse the repository at this point in the history
* Squash of verification changes 2024-08-28

* Cleanup

* fmt

* More cleanup

* clippy

* update example spec

* fmt

* null

* clippy part 1

* clippy fix, null

* clippy part 3

* fmt

* disable veri_engine tests in CI

* clap dependency

* remove strum

* use easy-smt version

* Get `cargo vet/deny` working and passing

Undoes a seeming `cargo update` that was performed previously and then
adds a vet for the new crate added.

* Flag new crates as not published

* Revert "remove strum"

This reverts commit df7b540.

* itertools

* Review feedback

* Future work comments for encodings

* fmt

* post merge Cargo.lock updates

* authors

---------

Co-authored-by: Alex Crichton <[email protected]>
  • Loading branch information
avanhatt and alexcrichton authored Oct 4, 2024
1 parent 4549585 commit e498087
Show file tree
Hide file tree
Showing 99 changed files with 22,322 additions and 157 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ vendor
examples/build
examples/.cache
*.coredump
*.smt2
cranelift/isle/veri/veri_engine/test_output
crates/explorer/node_modules
75 changes: 69 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ members = [
"cranelift",
"cranelift/isle/fuzz",
"cranelift/isle/islec",
"cranelift/isle/veri/veri_engine",
"cranelift/isle/veri/veri_ir",
"cranelift/serde",
"crates/bench-api",
"crates/c-api/artifact",
Expand Down
3 changes: 3 additions & 0 deletions ci/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#
# - wasm-spec-interpreter: brings in OCaml which is a pain to configure for all
# targets, tested as part of the wastime-fuzzing CI job.
#
# - veri_engine: requires an SMT solver (z3)

cargo test \
--workspace \
Expand All @@ -20,4 +22,5 @@ cargo test \
--exclude wasmtime-wasi-nn \
--exclude wasmtime-fuzzing \
--exclude wasm-spec-interpreter \
--exclude veri_engine \
$@
2 changes: 2 additions & 0 deletions cranelift/codegen/meta/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ impl Error {
}
}

impl std::error::Error for Error {}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.inner)
Expand Down
40 changes: 40 additions & 0 deletions cranelift/codegen/meta/src/isle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,47 @@ pub struct IsleCompilations {
pub items: Vec<IsleCompilation>,
}

impl IsleCompilations {
pub fn lookup(&self, name: &str) -> Option<&IsleCompilation> {
for compilation in &self.items {
if compilation.name == name {
return Some(compilation);
}
}
None
}
}

#[derive(Clone, Debug)]
pub struct IsleCompilation {
pub name: String,
pub output: std::path::PathBuf,
pub inputs: Vec<std::path::PathBuf>,
pub untracked_inputs: Vec<std::path::PathBuf>,
}

impl IsleCompilation {
pub fn inputs(&self) -> Vec<std::path::PathBuf> {
self.inputs
.iter()
.chain(self.untracked_inputs.iter())
.cloned()
.collect()
}
}

pub fn shared_isle_lower_paths(codegen_crate_dir: &std::path::Path) -> Vec<std::path::PathBuf> {
let inst_specs_isle = codegen_crate_dir.join("src").join("inst_specs.isle");
let prelude_isle = codegen_crate_dir.join("src").join("prelude.isle");
let prelude_lower_isle = codegen_crate_dir.join("src").join("prelude_lower.isle");
// The shared instruction selector logic.
vec![
inst_specs_isle.clone(),
prelude_isle.clone(),
prelude_lower_isle.clone(),
]
}

/// Construct the list of compilations (transformations from ISLE
/// source to generated Rust source) that exist in the repository.
pub fn get_isle_compilations(
Expand Down Expand Up @@ -61,6 +95,7 @@ pub fn get_isle_compilations(
items: vec![
// The mid-end optimization rules.
IsleCompilation {
name: "opt".to_string(),
output: gen_dir.join("isle_opt.rs"),
inputs: vec![
prelude_isle.clone(),
Expand All @@ -81,6 +116,7 @@ pub fn get_isle_compilations(
},
// The x86-64 instruction selector.
IsleCompilation {
name: "x64".to_string(),
output: gen_dir.join("isle_x64.rs"),
inputs: vec![
prelude_isle.clone(),
Expand All @@ -92,6 +128,7 @@ pub fn get_isle_compilations(
},
// The aarch64 instruction selector.
IsleCompilation {
name: "aarch64".to_string(),
output: gen_dir.join("isle_aarch64.rs"),
inputs: vec![
prelude_isle.clone(),
Expand All @@ -105,6 +142,7 @@ pub fn get_isle_compilations(
},
// The s390x instruction selector.
IsleCompilation {
name: "s390x".to_string(),
output: gen_dir.join("isle_s390x.rs"),
inputs: vec![
prelude_isle.clone(),
Expand All @@ -116,6 +154,7 @@ pub fn get_isle_compilations(
},
// The risc-v instruction selector.
IsleCompilation {
name: "riscv64".to_string(),
output: gen_dir.join("isle_riscv64.rs"),
inputs: vec![
prelude_isle.clone(),
Expand All @@ -128,6 +167,7 @@ pub fn get_isle_compilations(
},
// The Pulley instruction selector.
IsleCompilation {
name: "pulley".to_string(),
output: gen_dir.join("isle_pulley_shared.rs"),
inputs: vec![
prelude_isle.clone(),
Expand Down
Loading

0 comments on commit e498087

Please sign in to comment.