change how top-level emit/asm statements work #1635
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Only treat
emit
andasm
statements at the module-scope andoutside of any complex expression as top-level emit/asm statements.
Details
The main goal is to move top-level emit/asm handling largely out of the
code generator and into the orchestrator; the user-facing behaviour
changing is a side effect.
When creating the module lifecycle routines from module AST, emit/asm
statements that are at the top-level are now extracted and put into a
separate section. They're then translated from AST to MIR and
emitted as the new
bekEmit
event by thebackends.process
iterator.For the C backend, they're passed onto the code generator; they're not
possible for the other two backends. Section determination is removed
from
cgen
.While the section modifiers are translated to the same C file section
as before, all top-level emit/asm statements are now processed before
other top-level code. Tests for top-level emit statements and those
using them are updated (where needed).