Skip to content

make the IL Call grammar more regular - #159

Draft
zerbina wants to merge 5 commits into
nim-works:mainfrom
zerbina:il-regular-calls
Draft

make the IL Call grammar more regular#159
zerbina wants to merge 5 commits into
nim-works:mainfrom
zerbina:il-regular-calls

Conversation

@zerbina

@zerbina zerbina commented May 3, 2025

Copy link
Copy Markdown
Collaborator

Summary

Always have a type operand before the callee for every call syntax, no
longer making a grammatical distinction between static and dynamic
calls. ProcVal is removed.

Details

Call, CheckedCall, and CheckedCallAsgn now always have a callee
type operand now, with the motivation being that:

  1. it makes the procedure signature queryable directly at the callsite
    for static calls (not just for dynamic calls)
  2. the grammar becomes simpler
  3. some processing becomes more uniform

Since the proc reference (Proc) vs. procedure value (ProcVal)
distinction is not useful anymore, the latter syntax is removed, with
Proc taking over its meaning.

The passes, skully, and source2il are adjusted to the aforementioned
changes. Tests using static calls (and their expected output) are
also updated to adhere to the new grammar.

For the VM code generator, tests for indirect calls now have to use
local variables as the callee, as using the Proc directly now always
yields a static call.


To-Do

  • update the hand-written L30 code in source2il

Notes For Reviewers

  • IL code size increase a bit, but I consider this to be outweighed by increase regularity
  • passes that navigate/recompute types a lot benefit the most, as they no longer have to look up the ProcDef first

zerbina added 5 commits May 3, 2025 20:44
There's now no longer a distinction made between static and dynamic
calls at the grammar level: both start with a type reference.

The `ProcVal` vs. `Proc` distinction no longer provides any value,
so `ProcVal` is removed, with `Proc` taking over its meaning.
Transformations and processing relying on the old shapes, or using
`ProcVal`, are updated.
The hand-written code is not adjusted just yet.
* `ProcVal` usage is replaced with `Proc`
* call translation is changed to always emit the callee type operand
* `compilerProc` is replaced with `emitCompilerProcCallee`, which
  emits both the type and proc value
All static calls are changed to include the type node -- nothing else
is changed.

For the VM tests, local variables are now required for testing indirect
calls.
@zerbina

zerbina commented May 9, 2025

Copy link
Copy Markdown
Collaborator Author

The hand-written L30 in source2il needs to be updated, which is fairly annoying to do at the moment, as it would currently require manually passing all needed signature types to the % calls.

I'm waiting with the update, until the L30 code is moved to dedicated modules read from disk, the latter which will make modifying the L30 code a lot more comfortable.

@zerbina

zerbina commented Nov 22, 2025

Copy link
Copy Markdown
Collaborator Author

I'm leaving this PR open for now, but it's effectively dead.

As part of the transition to using a proper nanopass framework (#179), the IL(s) will become a lot more regular in general (as that makes the passes easier to implement), and there's not really a point in refactoring code that is obsolete and (most likely) won't see much further usage.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant