Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lean: Allow for match statments of heterogeneous bitvector length #1071

Open
wants to merge 2 commits into
base: sail2
Choose a base branch
from

Conversation

javra
Copy link
Collaborator

@javra javra commented Feb 25, 2025

Fixes #1070.

Copy link

github-actions bot commented Feb 25, 2025

Test Results

   13 files  ±0     29 suites  ±0   0s ⏱️ ±0s
  841 tests ±0    841 ✅ ±0  0 💤 ±0  0 ❌ ±0 
3 516 runs  ±0  3 516 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit f8be909. ± Comparison against base commit fbdcb92.

♻️ This comment has been updated with latest results.

@javra javra force-pushed the lean/heterogeneous_match branch 2 times, most recently from c9d7375 to f44ca0c Compare February 25, 2025 14:44
@javra javra marked this pull request as ready for review February 25, 2025 14:45
@javra javra requested a review from ineol February 25, 2025 14:45
@javra javra force-pushed the lean/heterogeneous_match branch from f44ca0c to f8be909 Compare February 25, 2025 14:50
@ineol
Copy link
Collaborator

ineol commented Feb 25, 2025

def fp_sub (rm_3b : (BitVec 3)) (op1 : (BitVec k_m)) (op2 : (BitVec k_m)) : SailM (BitVec k_m) := do
  let (fflags, result_val) : (bits_fflags × (BitVec k_m)) ← do
    match (Sail.BitVec.length op2) with
    | 16 => (riscv_f16Sub rm_3b op1 op2)
    | 32 => (riscv_f32Sub rm_3b op1 op2)
    | _ => (riscv_f64Sub rm_3b op1 op2)
  (accrue_fflags fflags)
  (pure result_val)

I think there is an issue when the block of the let is monadic, because apparently we cannot put a type ascription in let x : typ <- ...

One solution is to do let x : typ := <- ... but it's not super pretty

@bacam
Copy link
Contributor

bacam commented Feb 25, 2025

This currently drops the optional arguments on recursive calls to doc_pat. Was that intentional?

@javra
Copy link
Collaborator Author

javra commented Feb 25, 2025

@bacam I don't think it matters, if there's no double typ ascriptions

@ineol Ah, thanks. Weirdly it accepts type ascriptions if it's an atomic binder, but not if there's a pattern 😢 Let's wait until someone weighs in on this topic then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lean: Matches on heterogeneous bitvector lengths
3 participants