Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate numerical label IDs to Yul #15969

Open
wants to merge 16 commits into
base: add_node_id_dispenser
Choose a base branch
from

Conversation

clonker
Copy link
Member

@clonker clonker commented Mar 26, 2025

With this change, nodes in the Yul AST are no longer referred to by string name (or more precisely: statically managed repository of strings and referenced by hashes thereof) but by numerical ID. The numerical ID belongs to an immutable ASTLabelRegistry, in which it is associated to a string label. In turn, the registry is owned by the yul::AST.

During, e.g., optimization it is possible to generate new LabelIDs, which not yet have an associated label in a registry but encode a parent label (which may be empty) using the yul::LabelIDDispenser. Newly generated IDs are only valid with respect to their generating instance of LabelIDDispenser.
At the end of optimization, when f.ex. serialization back into a stringified form is required, the LabelIDs currently contained in the AST are assigned new labels by the yul::LabelIDDispenser, generating a new instance of ASTLabelRegistry.

This PR removes YulString, yul::NameSimplifier, yul::NameDispenser, yul::VarNameCleaner and replaces them by the LabelID and related utilities.

There is a special case of ghost nodes. These are introduced in CFGs to map switch statements to sequences of if-else blocks but do not live in the actual AST, just the CFG. To this end, a CFG also holds an instance of ASTLabelRegistry and manages the LabelID -> string_view transformation itself. An ASTLabelRegistry itself does not know how to stringify the special ghost nodes.

Depends on #15838.

@clonker clonker added the has dependencies The PR depends on other PRs that must be merged first label Mar 26, 2025
@clonker clonker requested review from aarlt and matheusaaguiar March 26, 2025 09:46
@clonker clonker force-pushed the add_node_id_dispenser branch from d7aa648 to ba47427 Compare April 2, 2025 11:53
@clonker clonker force-pushed the add_node_id_dispenser branch from ba47427 to b45bcb3 Compare April 2, 2025 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has dependencies The PR depends on other PRs that must be merged first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant