-
Notifications
You must be signed in to change notification settings - Fork 134
Symbol table transformer #321
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
Symbol table transformer #321
Conversation
4d5cfa5 to
cd83ecd
Compare
avanhatt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High level thoughts:
- Visitor pattern implementation seems clean, straightforward, and useful.
- Before landing, I would want to see some fairly heavy testing of this. Can we add a separate script that runs this over existing tests and checks that the identity is indeed correct? And that we can do simple changes, like inverting every boolean or similar?
compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/expr.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a constructor that enforces this invariant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should make the comment more clear, but this means manually wrapped in .array_to_ptr() after construction (the other constructor does it for you).
compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/symtab_transformer/transformer.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/symtab_transformer/transformer.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/symtab_transformer/transformer.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/symtab_transformer/transformer.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/symtab_transformer/transformer.rs
Outdated
Show resolved
Hide resolved
adpaco-aws
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about having the thing you are transforming be the second part of the function names?
For example, transform_type_... when transforming types, transform_expr_... when transforming expressions, and so on. Otherwise I feel like it's a bit harder to read/search, but maybe you've already considered this and decided this was the best way.
compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/expr.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/expr.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/symtab_transformer/transformer.rs
Outdated
Show resolved
Hide resolved
cd83ecd to
65851cd
Compare
This has been manually checked, but I'm not sure what approach is best for automating it. |
|
LGTM once some automated test is included in the PR (or, let me know if you feel like that should be a 2nd PR for timing). |
c5b36ca to
13192f3
Compare
cba5f7d to
d9ddad5
Compare
avanhatt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
danielsn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nice to add something about this to a readme.
| } | ||
|
|
||
| /// Transform an assign expr (`left = right`) | ||
| /// Currently not able to be constructed, as does not exist in Rust |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constructor doesn't exist?
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
Adds a recursive visitor pattern which can be used to transform goto symbol tables, as well as a default (identity transform) implementation.
Description of changes:
Introduces a visitor pattern for transforming the symbol table. An example identity transformation is included to show the setup, and any of the default methods can be overridden to change behavior. Adds a compiler flag to list out symbol table passes to perform after codegenning.
Resolved issues:
Resolves #291
Call-outs:
Todo:
Testing:
How is this change tested? Existing regression suite, plus new unit test suite specific to the symbol table transformer trait.
Is this a refactor change? No.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.