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

Simplify convert-uast's handling of SymExprs and similar #25946

Merged
merged 10 commits into from
Sep 24, 2024

Conversation

mppf
Copy link
Member

@mppf mppf commented Sep 16, 2024

This PR makes incremental progress towards having convert-uast handle more of the fully resolved data.

It does the following:

  • instead of using various global variables, use a single Converter for all modules and do fixups at the end. To accomplish this, added a wrapper class UastConverter, which contains a pointer to the real Converter in a way that allows the implementation details of Converter to be private to convert-uast.cpp. This involved adjusting parseAndConvert.cpp which calls the functionality in convert-uast.cpp; now it creates a UastConverter and passes it to a few functions, calling methods on it to convert uAst to AST.
  • Remove the complicated handling of fixups in ConvertedSymbolsMap. A fixup is needed when the process of converting uAST to AST encounters something that refers to some uAST that is not converted yet. Previous to this PR, fixups were processed at the end of whatever syntactic construct contains both the SymExpr and the target Symbol, but since this could not be relied on in all cases, there was also a global fixups table. The problems with this approach are 1) it makes this code significantly more complicated 2) it can't apply to Types or handle point-of-instantiation in any reasonable way and 3) it does not offer significant performance improvement (as measured with --dyno-scope-bundled). So, this PR removes ConvertedSymbolsMap and folds the relevant structures into Converter so that there is only one mapping of how a symbol/type was converted and only one list of fixups. (There are different fixups lists for different types of things as they are processed differently; but there is no longer a chain of ConvertedSymbolsMap each containing fixups lists).
  • Prepares for type fixups by adding TemporaryConversionType which can be used when a type is known but the type has not yet been converted. This is similar to TemporaryConversionSymbol but for types.
  • Adjust wellknown.cpp / wellknown.h to consider dtCPointer and dtCPointerConst to be well-known types that need to be handled in a manner similar to string and bytes records. These will have a dummy AggregateType created early in compilation and the details will be filled in when processing the relevant declarations from the module code. dtCPointer and dtCPointerConst are used in convert-uast.cpp when converting C pointer types because the type system in frontend/ has its own representation for these apart from these classes in the modules.

For https://github.com/Cray/chapel-private/issues/6261

Reviewed by @DanilaFe - thanks!

  • full comm=none testing

compiler/passes/convert-uast.cpp Outdated Show resolved Hide resolved
compiler/passes/convert-uast.cpp Show resolved Hide resolved
compiler/passes/convert-uast.cpp Outdated Show resolved Hide resolved
compiler/include/symbol.h Outdated Show resolved Hide resolved
Copy link
Contributor

@DanilaFe DanilaFe left a comment

Choose a reason for hiding this comment

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

Everything looks good, thanks for implementing the suggestions!

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
Need to use 'explicit' since implicit conversion not needed here.

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
@mppf mppf merged commit 827e02e into chapel-lang:main Sep 24, 2024
7 checks passed
@mppf mppf deleted the convert-two-pass branch September 24, 2024 19:46
mppf added a commit that referenced this pull request Sep 24, 2024
This PR fixes a compilation failure for frontend/ when compiling with
clang.

Follow-up to PR #25946.

Reviewed by @jabraham17 - thanks!

- [x] full comm=none testing
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.

2 participants