Skip to content

Lean backend: LeanRV32D.Functions.execute is noncomputable, has no executable code #1015

@GZGavinZhao

Description

@GZGavinZhao

Hi! I'm trying to use the Lean model generated by the spec, and unfortunately LeanRV32D.Functions.execute seems to be noncomputable which causes me to add uncomputable to every function that uses it.

For example, the following snippet

import LeanRV32D

open Sail
open LeanRV32D.Functions

def spec_add (rd rs1 rs2 : regidx) : SailM Unit := do
  writeReg Register.nextPC (BitVec.addInt (← readReg Register.PC) 4)
  let _ ← execute (.RTYPE ⟨rs2, rs1, rd, rop.ADD⟩)
  pure ()

produces the following error:

failed to compile definition, compiler IR check failed at 'spec_add'. Error: depends on declaration 'LeanRV32D.Functions.execute', which has no executable code; consider marking definition as 'noncomputable'

However, the following works perfectly fine:

def spec_add (rd rs1 rs2 : regidx) : SailM Unit := do
  writeReg Register.nextPC (BitVec.addInt (← readReg Register.PC) 4)
  /- let _ ← execute (.RTYPE ⟨rs2, rs1, rd, rop.ADD⟩) -/
  let _ ← execute_RTYPE rs2 rs1 rd rop.ADD
  pure ()

even though this is precisely what you get if you pattern-match out .RTYPE.

Is this expected? I know there are some uncomputable functions in the generated code here, but judging from their names it seems like they're all for decoding/encoding instructions and execute shouldn't really involve them?

Thank you for your time!

The Lean model is generated at 3dc7e1c with Sail commit rems-project/sail@5794bf15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions