From 795ec871806ea189818bbf2fd2a69455384d2004 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 14 Sep 2026 10:48:16 +0200 Subject: feat: replace parser optimizer with streaming selection Signed-off-by: Henry --- crates/parser/src/lib.rs | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'crates/parser/src/lib.rs') diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index 4954056..2752d8b 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -30,10 +30,11 @@ pub(crate) mod log { } mod conversion; +mod emitter; mod error; mod macros; mod module; -mod optimize; +mod selection; mod validation; mod visit; @@ -62,8 +63,8 @@ pub struct ParserOptions { /// a module that violates runtime assumptions. pub validation: bool, - /// Whether to run the peephole rewrite optimizer. - pub optimize_rewrite: bool, + /// Whether to enable some of the optimizations during lowering, such as bounded instruction selection. + pub optimize: bool, /// Whether to deduplicate immutable function operands while parsing. pub deduplicate_operands: bool, @@ -76,17 +77,17 @@ pub struct ParserOptions { /// - `None`: auto-detect based on available parallelism /// - `Some(1)`: force single-threaded /// - `Some(n)`: use up to `n` workers - pub parser_threads: Option, + pub threads: Option, } impl Default for ParserOptions { fn default() -> Self { Self { validation: cfg!(feature = "validate"), - optimize_rewrite: true, - deduplicate_operands: false, + optimize: true, + deduplicate_operands: true, #[cfg(parallel_parser)] - parser_threads: None, + threads: None, } } } @@ -114,15 +115,15 @@ impl ParserOptions { self.validation } - /// Enable or disable the peephole rewrite optimizer. - pub const fn with_rewrite_optimization(mut self, enabled: bool) -> Self { - self.optimize_rewrite = enabled; + /// Enable or disable some of the optimizations during lowering, such as bounded instruction selection. + pub const fn with_optimize(mut self, enabled: bool) -> Self { + self.optimize = enabled; self } - /// Returns whether the peephole rewrite optimizer is enabled. - pub const fn optimize_rewrite(&self) -> bool { - self.optimize_rewrite + /// Returns whether some of the optimizations during lowering, such as bounded instruction selection, are enabled. + pub const fn optimize(&self) -> bool { + self.optimize } /// Enable or disable parse-time deduplication of immutable function operands. @@ -140,15 +141,15 @@ impl ParserOptions { /// Set the number of threads for parallel parsing. /// /// Requires the `parallel` feature to have any effect. - pub const fn with_parser_threads(mut self, threads: usize) -> Self { - self.parser_threads = Some(threads); + pub const fn with_threads(mut self, threads: usize) -> Self { + self.threads = Some(threads); self } #[cfg(parallel_parser)] /// Returns the configured parser thread count, or `None` for auto-detect. - pub const fn parser_threads(&self) -> Option { - self.parser_threads + pub const fn threads(&self) -> Option { + self.threads } } -- cgit v1.3.1