Skip to content

[ImportVerilog] Convert arity-based system task to named-based matching#9923

Open
fabianschuiki wants to merge 1 commit intomainfrom
fschuiki/system-task-refactor
Open

[ImportVerilog] Convert arity-based system task to named-based matching#9923
fabianschuiki wants to merge 1 commit intomainfrom
fschuiki/system-task-refactor

Conversation

@fabianschuiki
Copy link
Contributor

Instead of first checking the number of arguments of a system task or function, and only then checking the name, create one big name-based dispatch before going into details about the number of arguments. This allows us to produce better error messages about the actual system tasks that aren't supported yet, instead of failing on things like EmptyArgument expression conversions. It also allows us to better handle system tasks that can have a variable number of arguments.

Sorry for the churn everyone!


// Real math functions (all take 1 real argument)
if (name == "$ln")
return convertRealMathBI<moore::LnBIOp>(*this, loc, name, args);
Copy link
Member

@uenoku uenoku Mar 12, 2026

Choose a reason for hiding this comment

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

I sense a potential circt-tablegen opportunity ... 😏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😏

Choose a reason for hiding this comment

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

SystemSubroutine has a knownNameId member that is an enum that you can switch on or put in a hash table, rather than a big linear scan of string compares.

Instead of first checking the number of arguments of a system task or
function, and only then checking the name, create one big name-based
dispatch before going into details about the number of arguments. This
allows us to produce better error messages about the actual system tasks
that aren't supported yet, instead of failing on things like
`EmptyArgument` expression conversions. It also allows us to better
handle system tasks that can have a variable number of arguments.

Sorry for the churn everyone!
@fabianschuiki fabianschuiki force-pushed the fschuiki/system-task-refactor branch from 83d4185 to da7c031 Compare March 12, 2026 21:59
Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

Can we have some tests or slang rejects these ill-formed system call more earlier? (e.g. slang emits an error for $signed(8'h2, 2) "too many arguments for '$signed'; expected 1 but 2 were provided")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants