Expand description
Procedural macros for integrating ISLE DSL with Intarsia optimizers.
This crate provides macros to help integrate ISLE-generated code into your Rust optimizer framework. ISLE (Instruction Selection Lowering Expressions) is a domain-specific language for pattern matching and rewriting, originally developed for Cranelift.
§Overview
The macros fall into three categories:
§1. Accessor Generation (Non-Multi)
For basic ISLE operators that match/construct single nodes:
- [
isle_extractor!] - Pattern matching (e-node → children IDs) - [
isle_constructor!] - Node construction (children IDs → e-node) - [
isle_accessors!] - Both extractor and constructor
§2. Multi-Accessor Generation
For ISLE multi-extractors/constructors that explore all nodes in an e-class:
- [
isle_multi_extractor!] - Match all nodes in an e-class - [
isle_multi_constructor!] - Construct and add to results vector - [
isle_multi_accessors!] - Both multi-extractor and multi-constructor
§3. Integration Setup
isle_integration!- Generate required type definitionsisle_integration_full!- Module declaration + type definitions
§Quick Start Example
ⓘ
// In your optimizer module (e.g., src/optimizer.rs)
use intarsia_macros::{isle_integration, isle_accessors};
// 1. Declare the ISLE-generated rules module
#[allow(dead_code, unused_variables, unused_imports, non_snake_case)]
#[path = "isle/rules.rs"]
pub(crate) mod rules;
// 2. Generate required ISLE type definitions
isle_integration!();
// 3. In your Context implementation, generate accessor functions
impl rules::Context for MyContext {
isle_accessors! {
And(extractor_and, constructor_and, 2);
Or(extractor_or, constructor_or, 2);
Not(extractor_not, constructor_not, 1);
}
// ... other required methods
}§Build Script Integration
Use intarsia-build to compile ISLE files in your build.rs:
// build.rs
fn main() -> Result<(), Box<dyn std::error::Error>> {
intarsia_build::compile_isle_auto()?;
Ok(())
}Macros§
- isle_
integration - Generate type definitions required by ISLE-generated code.
- isle_
integration_ full - Complete ISLE integration including module declaration and type definitions.