Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ All i32 operations (arithmetic, division, comparison, bit-manip, shift/rotate) h

## Conventions

- Rust edition 2024, MSRV 1.85
- Rust edition 2024, MSRV 1.88
- Edition 2024 notes: `unsafe fn` bodies require explicit inner `unsafe {}` blocks; `#[no_mangle]` must be `#[unsafe(no_mangle)]`; `static mut` access via `&raw const`/`&raw mut`
- Bazel 8.x with bzlmod (`MODULE.bazel`, not `WORKSPACE`)
- Renode tests use `rules_renode` (PulseEngine fork with macOS support)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resolver = "2"
[workspace.package]
version = "0.1.0"
edition = "2024"
rust-version = "1.85"
rust-version = "1.88"
authors = ["PulseEngine Team"]
license = "Apache-2.0"
repository = "https://github.com/pulseengine/synth"
Expand Down
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ register_toolchains("@local_config_cc_toolchains//:all")
# Rust toolchains
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
edition = "2021",
versions = ["1.84.0"],
edition = "2024",
versions = ["1.88.0"],
)
use_repo(rust, "rust_toolchains")
register_toolchains("@rust_toolchains//:all")
Expand Down
67 changes: 18 additions & 49 deletions crates/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rust_library(
name = "synth-core",
srcs = glob(["synth-core/src/**/*.rs"]),
crate_root = "synth-core/src/lib.rs",
edition = "2021",
edition = "2024",
deps = [
"@crates//:anyhow",
"@crates//:serde",
Expand All @@ -26,7 +26,7 @@ rust_library(
name = "synth-frontend",
srcs = glob(["synth-frontend/src/**/*.rs"]),
crate_root = "synth-frontend/src/lib.rs",
edition = "2021",
edition = "2024",
deps = [
":synth-core",
"@crates//:anyhow",
Expand All @@ -41,7 +41,7 @@ rust_library(
name = "synth-analysis",
srcs = glob(["synth-analysis/src/**/*.rs"]),
crate_root = "synth-analysis/src/lib.rs",
edition = "2021",
edition = "2024",
deps = [
":synth-core",
":synth-cfg",
Expand All @@ -54,7 +54,7 @@ rust_library(
name = "synth-cfg",
srcs = glob(["synth-cfg/src/**/*.rs"]),
crate_root = "synth-cfg/src/lib.rs",
edition = "2021",
edition = "2024",
deps = [
":synth-core",
"@crates//:anyhow",
Expand All @@ -66,7 +66,7 @@ rust_library(
name = "synth-opt",
srcs = glob(["synth-opt/src/**/*.rs"]),
crate_root = "synth-opt/src/lib.rs",
edition = "2021",
edition = "2024",
deps = [
":synth-cfg",
"@crates//:anyhow",
Expand All @@ -78,7 +78,7 @@ rust_library(
name = "synth-synthesis",
srcs = glob(["synth-synthesis/src/**/*.rs"]),
crate_root = "synth-synthesis/src/lib.rs",
edition = "2021",
edition = "2024",
deps = [
":synth-core",
":synth-opt",
Expand All @@ -91,34 +91,19 @@ rust_library(
],
)

# Register allocation
rust_library(
name = "synth-regalloc",
srcs = glob(["synth-regalloc/src/**/*.rs"]),
crate_root = "synth-regalloc/src/lib.rs",
edition = "2021",
deps = [
":synth-core",
":synth-opt",
"@crates//:anyhow",
# TODO: Add regalloc2 dependency
],
)

# Code generation backend (ELF builder, linker scripts, ARM encoder)
# ARM-specific modules require synth-synthesis (arm-cortex-m feature in Cargo)
rust_library(
name = "synth-backend",
srcs = glob(["synth-backend/src/**/*.rs"]),
crate_root = "synth-backend/src/lib.rs",
edition = "2021",
edition = "2024",
rustc_flags = ["--cfg", "feature=\"arm-cortex-m\""],
deps = [
":synth-core",
":synth-codegen",
":synth-regalloc",
":synth-synthesis",
"@crates//:anyhow",
"@crates//:thiserror",
],
)

Expand All @@ -127,7 +112,7 @@ rust_library(
name = "synth-backend-awsm",
srcs = glob(["synth-backend-awsm/src/**/*.rs"]),
crate_root = "synth-backend-awsm/src/lib.rs",
edition = "2021",
edition = "2024",
deps = [
":synth-core",
"@crates//:anyhow",
Expand All @@ -140,34 +125,20 @@ rust_library(
name = "synth-backend-wasker",
srcs = glob(["synth-backend-wasker/src/**/*.rs"]),
crate_root = "synth-backend-wasker/src/lib.rs",
edition = "2021",
edition = "2024",
deps = [
":synth-core",
"@crates//:anyhow",
"@crates//:thiserror",
],
)

# Machine code generation
rust_library(
name = "synth-codegen",
srcs = glob(["synth-codegen/src/**/*.rs"]),
crate_root = "synth-codegen/src/lib.rs",
edition = "2021",
deps = [
":synth-core",
":synth-opt",
":synth-regalloc",
"@crates//:anyhow",
],
)

# ABI and calling conventions
rust_library(
name = "synth-abi",
srcs = glob(["synth-abi/src/**/*.rs"]),
crate_root = "synth-abi/src/lib.rs",
edition = "2021",
edition = "2024",
deps = [
":synth-wit",
"@crates//:anyhow",
Expand All @@ -179,7 +150,7 @@ rust_library(
name = "synth-wit",
srcs = glob(["synth-wit/src/**/*.rs"]),
crate_root = "synth-wit/src/lib.rs",
edition = "2021",
edition = "2024",
deps = [
":synth-core",
"@crates//:anyhow",
Expand All @@ -193,7 +164,7 @@ rust_library(
name = "synth-verify",
srcs = glob(["synth-verify/src/**/*.rs"]),
crate_root = "synth-verify/src/lib.rs",
edition = "2021",
edition = "2024",
rustc_flags = [
"--cfg", "feature=\"z3-solver\"",
"--cfg", "feature=\"arm\"",
Expand All @@ -218,7 +189,7 @@ rust_library(
name = "synth-memory",
srcs = glob(["synth-memory/src/**/*.rs"]),
crate_root = "synth-memory/src/lib.rs",
edition = "2021",
edition = "2024",
crate_features = ["std"],
deps = [
"@crates//:bitflags",
Expand All @@ -230,7 +201,7 @@ rust_library(
name = "synth-qemu",
srcs = glob(["synth-qemu/src/**/*.rs"]),
crate_root = "synth-qemu/src/lib.rs",
edition = "2021",
edition = "2024",
deps = [
":synth-core",
"@crates//:anyhow",
Expand All @@ -242,7 +213,7 @@ rust_binary(
name = "synth",
srcs = glob(["synth-cli/src/**/*.rs"]),
crate_root = "synth-cli/src/main.rs",
edition = "2021",
edition = "2024",
deps = [
":synth-core",
":synth-frontend",
Expand All @@ -264,7 +235,7 @@ rust_library(
srcs = glob(["synth-test/src/**/*.rs"], exclude = ["synth-test/src/main.rs"]),
crate_root = "synth-test/src/lib.rs",
crate_name = "synth_test",
edition = "2021",
edition = "2024",
deps = [
"@crates//:anyhow",
"@crates//:clap",
Expand All @@ -282,7 +253,7 @@ rust_library(
rust_binary(
name = "synth-test",
srcs = ["synth-test/src/main.rs"],
edition = "2021",
edition = "2024",
deps = [
":synth-test-lib",
"@crates//:anyhow",
Expand All @@ -300,11 +271,9 @@ filegroup(
":synth-cfg",
":synth-opt",
":synth-synthesis",
":synth-regalloc",
":synth-backend",
":synth-backend-awsm",
":synth-backend-wasker",
":synth-codegen",
":synth-abi",
":synth-wit",
":synth-verify",
Expand Down
4 changes: 2 additions & 2 deletions crates/synth-synthesis/tests/proptest_robustness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ proptest! {
let db = RuleDatabase::with_standard_rules();

let mut sel1 = InstructionSelector::new(db.rules().to_vec());
let r1 = sel1.select(&[op.clone()]).unwrap();
let r1 = sel1.select(std::slice::from_ref(&op)).unwrap();

let mut sel2 = InstructionSelector::new(db.rules().to_vec());
let r2 = sel2.select(&[op]).unwrap();
let r2 = sel2.select(std::slice::from_ref(&op)).unwrap();

prop_assert_eq!(
r1.len(), r2.len(),
Expand Down
16 changes: 8 additions & 8 deletions crates/synth-synthesis/tests/rocq_correspondence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
//! implementations agree. The Rocq proofs verify `compile_wasm_to_arm` preserves
//! semantics; these tests verify the Rust code matches `compile_wasm_to_arm`.

use synth_synthesis::{
ArmOp, InstructionSelector, Operand2, RuleDatabase, WasmOp,
};
use synth_synthesis::{ArmOp, InstructionSelector, Operand2, RuleDatabase, WasmOp};

/// Helper: extract opcode names from an ARM instruction sequence,
/// abstracting away register allocation.
Expand Down Expand Up @@ -53,7 +51,9 @@ fn opcode_names(ops: &[ArmOp]) -> Vec<&'static str> {
/// which has no peephole optimizations.
fn select_single(wasm_op: WasmOp) -> Vec<ArmOp> {
let mut selector = InstructionSelector::new(vec![]);
let result = selector.select(&[wasm_op]).expect("selection should succeed");
let result = selector
.select(&[wasm_op])
.expect("selection should succeed");
result.into_iter().map(|instr| instr.op).collect()
}

Expand Down Expand Up @@ -317,10 +317,10 @@ fn instruction_counts_match_rocq() {
(WasmOp::I32DivS, 1),
(WasmOp::I32DivU, 1),
// Two-instruction ops
(WasmOp::I32Rotl, 2), // RSB + ROR_reg
(WasmOp::I32Ctz, 2), // RBIT + CLZ
(WasmOp::I32RemS, 2), // SDIV + MLS
(WasmOp::I32RemU, 2), // UDIV + MLS
(WasmOp::I32Rotl, 2), // RSB + ROR_reg
(WasmOp::I32Ctz, 2), // RBIT + CLZ
(WasmOp::I32RemS, 2), // SDIV + MLS
(WasmOp::I32RemU, 2), // UDIV + MLS
];

for (wasm_op, expected_count) in &expected {
Expand Down
Loading