Skip to content

feat(io): Interpreter for the I/O Dialect - #1379

Draft
ArquintL wants to merge 6 commits into
mainfrom
arquintl-io-interpreter
Draft

ArquintL wants to merge 6 commits into
mainfrom
arquintl-io-interpreter

Conversation

@ArquintL

@ArquintL ArquintL commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Extends the Interpreter's state by a source of entropy and a network abstraction.
The source of entropy is supposed to be initialized before interpretation starts and allows operations like random number generation to consume random bytes from this source. As soon as no entropy is left, the behavior is UB.
The network abstraction holds the in-flight messages as a FIFO queue and recv consumes (& drops) the first message in the queue for the given receiver.

Copilot AI lite review requested due to automatic review settings September 4, 2026 10:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Io.interpretOp' handles a non-existent .address opcode and references non-existent properties.id, so the io.self interpretation is incorrect and likely won’t compile.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds interpreter support for the io dialect by extending interpreter state with (1) an entropy source for io.rand and (2) a simple in-flight message queue for io.send/io.recv, and introduces an io address runtime value to represent !io.address at runtime.

Changes:

  • Add RuntimeValue.ioAddr plus refinement support for !io.address.
  • Extend MemoryState with EntropyState and NetworkState, and implement entropy/message operations plus Io.interpretOp' (self/send/recv/rand).
  • Update/extend MLIR tests, including a new interpreter roundtrip test for io.send/io.recv.
File summaries
File Description
Veir/RuntimeValue.lean Adds ioAddr runtime value and string rendering.
Veir/Interpreter/Refinement/Basic.lean Extends runtime refinement relation to cover ioAddr.
Veir/Interpreter/Refinement/Lemmas.lean Adds lemma for extracting ioAddr from refinement evidence.
Veir/Interpreter/Basic.lean Extends interpreter memory state and implements entropy/network + io op interpretation.
Test/IO/roundtrip.mlir Updates IO IR test to use io.self.
Test/Interpreter/IO/roundtrip.mlir Adds interpreter roundtrip test for io.send/io.recv.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Veir/Interpreter/Basic.lean Outdated
@ArquintL
ArquintL force-pushed the arquintl-io-interpreter branch from 4e0598a to 9413f8a Compare September 4, 2026 10:30
@ArquintL
ArquintL requested a lite review from Copilot September 4, 2026 10:37
@ArquintL
ArquintL marked this pull request as draft September 4, 2026 10:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The IO interpreter currently converts arbitrary-width len operands via truncating toUInt64, which can silently wrap large lengths instead of failing/UB.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

Veir/Interpreter/Basic.lean:1851

  • len for io.rand is accepted as any integer width, but len.toNat.toUInt64 truncates values above UInt64.max. This can wrap the requested byte count instead of failing/UB.
    let [.addr addr, .int _ len] := operands.toList | none
    let .val len := len | Interp.ub
    let len := len.toNat.toUInt64
  • Files reviewed: 5/5 changed files
  • Comments generated: 3
  • Review effort level: Lite

Comment thread Veir/Interpreter/Basic.lean
Comment on lines +1 to +5
// RUN: veir-interpret %s | filecheck %s

// Send `abcd` to our own address, clear the buffer, receive it back, and
// return the bytes sent, the bytes received, the buffer contents, and the
// sender. The interpreter assigns itself address 0.
Comment thread Veir/Interpreter/Basic.lean Outdated
@ArquintL
ArquintL force-pushed the arquintl-io-interpreter branch from 5aea012 to 270ef40 Compare September 4, 2026 13:08
@ArquintL
ArquintL force-pushed the arquintl-io-dialect-extension branch from 13feb45 to d69004c Compare September 4, 2026 14:58
@ArquintL
ArquintL force-pushed the arquintl-io-interpreter branch from 46164c9 to 48ea333 Compare September 4, 2026 14:58
Base automatically changed from arquintl-io-dialect-extension to main September 4, 2026 15:46
ArquintL and others added 6 commits September 4, 2026 16:46
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ArquintL
ArquintL force-pushed the arquintl-io-interpreter branch from 48ea333 to 7f0cdd7 Compare September 4, 2026 15:46
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.

2 participants