Skip to content

feat(idl): add execute_instruction builtin for dynamic instruction di…#1820

Open
ayosher wants to merge 3 commits intoriscv:mainfrom
ayosher:ayosher_execute_instruction
Open

feat(idl): add execute_instruction builtin for dynamic instruction di…#1820
ayosher wants to merge 3 commits intoriscv:mainfrom
ayosher:ayosher_execute_instruction

Conversation

@ayosher
Copy link
Copy Markdown
Collaborator

@ayosher ayosher commented May 3, 2026

…spatch

Add a new IDL builtin function execute_instruction(Bits<32> encoding) that allows an instruction's operation() body to dynamically fetch and execute a sub-instruction by encoding value.

Motivation: instructions like qc.cm.ilut fetch instruction encodings from a memory table and execute them. Previously this had to be expressed as unpredictable(), which crashes the simulator. This builtin provides a proper implementation path.

Semantics:

  • Decodes and executes the given 32-bit encoding in the current hart context
  • PC is NOT advanced (the calling instruction manages PC)
  • Exceptions from the sub-instruction propagate normally to the caller

Changes:

  • spec/std/isa/isa/builtin_functions.idl: declare execute_instruction builtin
  • backends/cpp_hart_gen/templates/hart.hxx.erb: implement execute_instruction() method on the generated hart class using a dedicated instruction storage buffer (m_execute_instruction_storage) to avoid aliasing the outer instruction's storage during nested execution

…spatch

Add a new IDL builtin function execute_instruction(Bits<32> encoding)
that allows an instruction's operation() body to dynamically fetch and
execute a sub-instruction by encoding value.

Motivation: instructions like qc.cm.ilut fetch instruction encodings
from a memory table and execute them. Previously this had to be
expressed as unpredictable(), which crashes the simulator. This builtin
provides a proper implementation path.

Semantics:
- Decodes and executes the given 32-bit encoding in the current hart context
- PC is NOT advanced (the calling instruction manages PC)
- Exceptions from the sub-instruction propagate normally to the caller

Changes:
- spec/std/isa/isa/builtin_functions.idl: declare execute_instruction builtin
- backends/cpp_hart_gen/templates/hart.hxx.erb: implement execute_instruction()
  method on the generated hart class using a dedicated instruction storage
  buffer (m_execute_instruction_storage) to avoid aliasing the outer
  instruction's storage during nested execution
@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.18%. Comparing base (7d85d71) to head (8473b97).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1820   +/-   ##
=======================================
  Coverage   72.18%   72.18%           
=======================================
  Files          52       52           
  Lines       27744    27744           
  Branches     6002     6002           
=======================================
  Hits        20028    20028           
  Misses       7716     7716           
Flag Coverage Δ
idlc 76.11% <ø> (ø)
udb 66.25% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant