Files
wasmtime/cranelift/isle/isle/src/compile.rs
Jamey Sharp bfc6aad184 cranelift-isle: codegen from new IR (#5435)
ISLE's existing code-generation strategy doesn't generate the most
efficient matching order for rules. This PR completely replaces it.

With this PR applied, wasmtime compile retires 2% fewer instructions on
the pulldown-cmark and spidermonkey benchmarks from Sightglass.

A dev build of cranelift-codegen from an empty target/ directory takes
2% less time. The build script, invoking ISLE, takes a little longer,
but Rust can compile the generated code faster, so it balances out.
2023-01-23 12:27:51 -08:00

25 lines
877 B
Rust

//! Compilation process, from AST to Sema to Sequences of Insts.
use std::path::Path;
use crate::error::Errors;
use crate::{ast, codegen, sema};
/// Compile the given AST definitions into Rust source code.
pub fn compile(defs: &ast::Defs, options: &codegen::CodegenOptions) -> Result<String, Errors> {
let mut typeenv = sema::TypeEnv::from_ast(defs)?;
let termenv = sema::TermEnv::from_ast(&mut typeenv, defs)?;
let terms = crate::overlap::check(&typeenv, &termenv)?;
Ok(codegen::codegen(&typeenv, &termenv, &terms, options))
}
/// Compile the given files into Rust source code.
pub fn from_files<P: AsRef<Path>>(
inputs: impl IntoIterator<Item = P>,
options: &codegen::CodegenOptions,
) -> Result<String, Errors> {
let lexer = crate::lexer::Lexer::from_files(inputs)?;
let defs = crate::parser::parse(lexer)?;
compile(&defs, options)
}