Skip to content
Closed
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
54 changes: 0 additions & 54 deletions .claude/scripts/worktree-create.sh

This file was deleted.

27 changes: 0 additions & 27 deletions .claude/scripts/worktree-remove.sh

This file was deleted.

24 changes: 0 additions & 24 deletions .claude/settings.json

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/lydite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ name: lydite
# linted, and unit-tested by ci.yml; this workflow runs lydite's own gates.

on:
# Queue drafts run these gates on combined changes. Ordinary PRs skip all
# jobs; the weekly run catches drift between merges.
# Queue drafts run editor/replay checks on combined changes. Ordinary PRs
# skip all jobs; the expensive Veryl proof gates run only weekly or manually.
push:
branches: [develop]
paths:
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
retention-days: 14

veryl-fv:
if: github.event_name != 'pull_request' || startsWith(github.head_ref, 'mergify/merge-queue/')
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-26.04
timeout-minutes: 30
steps:
Expand All @@ -147,7 +147,7 @@ jobs:
retention-days: 14

veryl-proof-corpus:
if: github.event_name != 'pull_request' || startsWith(github.head_ref, 'mergify/merge-queue/')
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-26.04
# Cold builds plus the sequential proof/mutation gates can exceed one hour.
timeout-minutes: 120
Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ docs/.vitepress/.temp
# TypeDoc generated API docs
docs/api/

# Overlay filesystem
.overlays/
.overlay-upper/
.overlay-work/

# Benchmark output
ts-output.json
benches/verilator/obj_dir/
Expand Down
11 changes: 7 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,12 @@ This does not prioritize jobs inside GitHub Actions or preempt occupied runners.
See [Mergify priorities](https://docs.mergify.com/merge-queue/priority/) and
[Mergify queue modes](https://docs.mergify.com/merge-queue/queue-modes/).

The separate lydite proof/editor gates run on queue drafts rather than ordinary
PRs; develop pushes, weekly runs, and manual dispatch remain enabled.
The `Queue validation` merge condition requires those pre-merge checks to pass;
The separate lydite documentation, editor, and Celox replay checks run on queue
drafts rather than ordinary PRs; develop pushes, weekly runs, and manual dispatch
remain enabled. The expensive `veryl-fv` and `veryl-proof-corpus` jobs run only
weekly (Monday at 03:41 UTC / 12:41 JST) or on manual dispatch, never on queue
drafts or develop pushes. These separate lydite checks are not merge requirements.
The `Queue validation` merge condition requires the selected checks in `ci.yml` to pass;
ordinary PR checks cannot satisfy it. The `ci:full` label opts a PR into the
same coverage on its next push. Unrelated paths may still skip jobs.

Expand Down Expand Up @@ -208,7 +211,7 @@ uses the finer behavior-based matrix above.
| Daily at 02:17 UTC (11:17 JST) | `codspeed.yml` measures compile time on the default branch using CPU simulation. Execution failures and CodSpeed performance-check failures open or update a branch issue; the next healthy run closes it. Manual dispatch supports branch measurements. PRs, merge groups, and pushes do not run CodSpeed. |
| Daily at 02:37 UTC (11:37 JST) | `heliodor-bench.yml` runs the complete master Linux suite on x86-64 and AArch64. Explicit manual selections retain focused suite runs and ARM64 profiling. PRs run only the benchmark tooling tests when those files change. |
| Every full CI run | Run every shared Veryl and SystemVerilog case against both Verilator and Icarus, with locked Nix tools. Run the live adapter tests normally marked ignored because they need external tools. Preserve reports and per-case diagnostics as artifacts for 14 days, including on failure; matrix failures do not cancel the other comparisons. |
| Weekly, and on pull requests with relevant changes | Existing `lydite.yml` proof, conformance, editor, and mutation gates. |
| Weekly Monday at 03:41 UTC (12:41 JST), or manual dispatch | All `lydite.yml` checks, including Veryl formal verification and proof/mutation corpus gates. The two Veryl jobs run only at this cadence; documentation, editor, and Celox replay checks also run on queue drafts and develop pushes with relevant changes. |
| On demand | Dispatch `ci.yml` on the desired branch to run full CI and external comparisons, regardless of its diff. |
| Pull requests that cut a release | A `master` pull request or legacy merge group whose diff changes `.release-please-manifest.json` (only the release pull request does there; syncing it into `develop` is not a release) runs full CI and the external comparisons. `Rust Test & NAPI Build` then requires the comparisons to pass, so a release cannot merge after only change-based checks. Daily and manual full runs do not gate on the comparisons; their failures reach the full CI issue below. A `master` pull request or legacy merge group whose diff cannot be determined is treated the same way. |

Expand Down
30 changes: 26 additions & 4 deletions crates/celox-backend-cranelift/src/translator/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,24 @@ impl SIRTranslator {
} else {
r
};
// Logical shifts by at least the physical width produce zero.
// `r` is zero-extended from a logical width no wider than
// `common_ty`, so this compares the real count without truncation.
let logical_shift_in_range = if matches!(op, BinaryOp::Shl | BinaryOp::Shr) {
Some(state.builder.ins().icmp_imm_u(
IntCC::UnsignedLessThan,
r,
i64::from(common_ty.bits()),
))
} else {
None
};
let saturate_logical_shift = |builder: &mut FunctionBuilder, shifted: Value| {
let in_range =
logical_shift_in_range.expect("logical shift count range is computed");
let zero = builder.ins().iconst(common_ty, 0);
builder.ins().select(in_range, shifted, zero)
};

let build_icmp = |builder: &mut FunctionBuilder, cc: IntCC| {
let b1_res = builder.ins().icmp(cc, l, r);
Expand Down Expand Up @@ -424,11 +442,13 @@ impl SIRTranslator {
BinaryOp::Or => state.builder.ins().bor(l, r),
BinaryOp::Xor => state.builder.ins().bxor(l, r),
BinaryOp::Shr => {
let shifted = state.builder.ins().ushr(l, r);
let raw = state.builder.ins().ushr(l, r);
let shifted = saturate_logical_shift(state.builder, raw);
apply_d_width_mask(state, shifted, common_ty, d_width)
}
BinaryOp::Shl => {
let shifted = state.builder.ins().ishl(l, r);
let raw = state.builder.ins().ishl(l, r);
let shifted = saturate_logical_shift(state.builder, raw);
apply_d_width_mask(state, shifted, common_ty, d_width)
}
BinaryOp::Sar => {
Expand Down Expand Up @@ -510,7 +530,8 @@ impl SIRTranslator {
BinaryOp::Shr => {
let zero = state.builder.ins().iconst(common_ty, 0);
let shift_amt_has_x = state.builder.ins().icmp(IntCC::NotEqual, r_m, zero);
let shifted_m = state.builder.ins().ushr(l_m, r);
let raw_m = state.builder.ins().ushr(l_m, r);
let shifted_m = saturate_logical_shift(state.builder, raw_m);
let all_ones = state.builder.ins().iconst(common_ty, -1);
let m = state
.builder
Expand All @@ -521,7 +542,8 @@ impl SIRTranslator {
BinaryOp::Shl => {
let zero = state.builder.ins().iconst(common_ty, 0);
let shift_amt_has_x = state.builder.ins().icmp(IntCC::NotEqual, r_m, zero);
let shifted_m = state.builder.ins().ishl(l_m, r);
let raw_m = state.builder.ins().ishl(l_m, r);
let shifted_m = saturate_logical_shift(state.builder, raw_m);
let all_ones = state.builder.ins().iconst(common_ty, -1);
let m = state
.builder
Expand Down
22 changes: 20 additions & 2 deletions crates/celox-backend-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1648,9 +1648,11 @@ fn compile_binary_narrow(
BinaryOp::Xor => instrs.push(Instruction::I64Xor),
BinaryOp::Shl => {
instrs.push(Instruction::I64Shl);
emit_logical_shift_saturation(instrs, r.value_idx);
}
BinaryOp::Shr => {
instrs.push(Instruction::I64ShrU);
emit_logical_shift_saturation(instrs, r.value_idx);
}
BinaryOp::Sar => {
// Arithmetic shift right — need sign extension first.
Expand Down Expand Up @@ -2629,8 +2631,14 @@ fn compile_binary_mask_narrow(
instrs.push(Instruction::LocalGet(rhs.value_idx));
}
match op {
BinaryOp::Shl => instrs.push(Instruction::I64Shl),
BinaryOp::Shr => instrs.push(Instruction::I64ShrU),
BinaryOp::Shl => {
instrs.push(Instruction::I64Shl);
emit_logical_shift_saturation(instrs, rhs.value_idx);
}
BinaryOp::Shr => {
instrs.push(Instruction::I64ShrU);
emit_logical_shift_saturation(instrs, rhs.value_idx);
}
BinaryOp::Sar => instrs.push(Instruction::I64ShrS),
_ => unreachable!(),
}
Expand Down Expand Up @@ -5947,6 +5955,16 @@ fn emit_sar_count(instrs: &mut Vec<Instruction<'static>>, count: u32) {
instrs.push(Instruction::Select);
}

/// Replaces the shifted value on the stack with zero when the logical shift
/// count is at least 64. Wasm shifts use the count modulo 64.
fn emit_logical_shift_saturation(instrs: &mut Vec<Instruction<'static>>, count: u32) {
instrs.push(Instruction::I64Const(0));
instrs.push(Instruction::LocalGet(count));
instrs.push(Instruction::I64Const(64));
instrs.push(Instruction::I64LtU);
instrs.push(Instruction::Select);
}

fn emit_sign_extend(instrs: &mut Vec<Instruction<'static>>, local_idx: u32, width: usize) {
instrs.push(Instruction::LocalGet(local_idx));
if width < 64 {
Expand Down
Loading
Loading