Skip to content

refactor(sv): identify system tasks and functions by type - #1381

Merged
mergify[bot] merged 1 commit into
masterfrom
feature/refactoring-svtf
Oct 16, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
feature/refactoring-svtf

Conversation

@tignear

@tignear tignear commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Summary

System task and function calls were carried through the SV analyzer IR and the frontend as name strings, told apart from user subroutine calls by their $ prefix. About 20 files matched names again. The list of data queries ($bits | $size | $left | ...) and the result types of the integral functions were repeated in 4–5 places, and some copies had drifted apart.

This PR gives the calls types:

  • Catalog (system_functions.rs): each supported entry carries a SystemFunction (with ArrayQuery) or a SystemTask (with Radix, Severity, MemoryFormat). Properties that were spread across the code now live on the enum: is_data_query, is_effectful, result_type. check_call returns the identified call (SystemCall), and check_function_call covers expression position.
  • IR: ConstExpr::Function / Expr::Call take callee: Callee (Subroutine(String) | System(SystemFunction)), and Stmt::SystemTask takes task: SystemTask.
  • Analyzer / frontend: name matching is replaced by matches on the enums. Removed typecheck::bit_vector_function_return_type and system_functions::is_system_name. SystemTaskKind, readmem, $urandom handling and the bit-vector lowering are driven by the types.
  • Syntax-tree passes (validation, parameters, interfaces, timescales, dimensions) use called_system_function / called_system_task instead of comparing names.

Behavior notes

This is meant to be a pure refactor, with these minor edge cases:

  • $readmemh/$readmemb with a destination that is neither an identifier nor a select now reports the readmem-specific error, where it used to report a generic "system task" error.
  • Integral lowering of a system function the frontend cannot lower in that position (such as $urandom(seed) in glue logic) now returns None (unsupported). Before, it fell into the $onehot0 branch.
  • The internal $unsupported_mixed_function_* placeholder calls are now user-subroutine callees. They are no longer treated as system calls because of their $ prefix.

Validation

  • cargo clippy -p celox-sv-analyzer -p celox-frontend-sv -p celox --features celox/systemverilog --tests: clean
  • cargo test -p celox-sv-analyzer -p celox-frontend-sv -p celox --features celox/systemverilog: 11603 passed, 0 failed
  • No shared cases or external adapters changed, so I did not rerun the Verilator/Icarus comparisons.

System task and function calls were carried through the analyzer IR and
the frontend as name strings and told apart from user subroutine calls
by their `$` prefix. Each consumer matched names again, and the lists of
data queries and the result types of the integral functions were
repeated in several places, with entries that had drifted apart.

The catalog now identifies each supported call as a `SystemFunction` or
`SystemTask`. `ConstExpr::Function` and `Expr::Call` take a `Callee`, a
user subroutine or a system function, and `Stmt::SystemTask` takes the
task. Data queries, effectful calls and fixed result types are answered
by the catalog, so the frontend dispatches on the enums instead of names.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-16T22:35:46.838392Z 7cd26db PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 16, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 16, 2026
@mergify

mergify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 41 minutes 44 seconds in the queue, including 39 minutes 57 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Lint & Format
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Windows)
    • check-neutral = @github-actions/NAPI Build (Windows)
    • check-skipped = @github-actions/NAPI Build (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Rust Test & NAPI Build
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Ubuntu)
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Windows)
    • check-neutral = @github-actions/JS Test (Windows)
    • check-skipped = @github-actions/JS Test (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Conventional Commit title
    • check-neutral = @github-actions/Conventional Commit title
    • check-skipped = @github-actions/Conventional Commit title

@mergify
mergify Bot merged commit c7e54b4 into master Oct 16, 2026
26 of 28 checks passed
@mergify
mergify Bot deleted the feature/refactoring-svtf branch October 16, 2026 23:55
@mergify mergify Bot removed the queued Mergify queue entry label Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant