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

(Towards #2165) add support for associate constructs. #2167

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

arporter
Copy link
Member

@arporter arporter commented Jun 9, 2023

This is an initial cut that we can improve upon if we need to. In particular, the solution chosen here replaces instances of associate-name with the corresponding expression. However, since that expression must be evaluated at the start of the construct, if any of the variables it references are written to within the construct then this substitution cannot be performed. We could refine this by checking the precise location at which any such writes are performed - if they happen to only occur after lines where we need to perform the substitution then this would still be OK.

Alternatively, we could attempt to determine the type of the expression and then store its value in a new variable at the start of the construct.

@arporter arporter self-assigned this Jun 9, 2023
@arporter arporter added in progress NEMOVAR Relating to the NEMOVAR code. labels Jun 9, 2023
@codecov
Copy link

codecov bot commented Jun 9, 2023

Codecov Report

Patch coverage: 99.50% and project coverage change: -0.01 ⚠️

Comparison is base (badc7f5) 99.84% compared to head (14c8bd5) 99.84%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2167      +/-   ##
==========================================
- Coverage   99.84%   99.84%   -0.01%     
==========================================
  Files         334      336       +2     
  Lines       45137    45239     +102     
==========================================
+ Hits        45068    45169     +101     
- Misses         69       70       +1     
Impacted Files Coverage Δ
src/psyclone/psyir/frontend/fparser2.py 99.93% <98.18%> (-0.07%) ⬇️
src/psyclone/psyir/tools/__init__.py 100.00% <100.00%> (ø)
src/psyclone/psyir/tools/dependency_tools.py 100.00% <100.00%> (ø)
src/psyclone/psyir/tools/substitution_tool.py 100.00% <100.00%> (ø)
src/psyclone/psyir/transformations/inline_trans.py 100.00% <100.00%> (ø)
.../psyir/frontend/fparser2_associate_handler_test.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@arporter
Copy link
Member Author

arporter commented Jun 9, 2023

I need to test this branch with some real NEMOVAR code before putting it as ready for review.

@arporter
Copy link
Member Author

arporter commented Jun 9, 2023

Of course, the very first NEMOVAR I tried this on had some WRITE stmts inside the associate construct so we're no further forward. I can refine by checking which symbols are referenced by the resulting CodeBlock but that may not help. If that's so then I think the only option is to remove the WRITES?

@arporter
Copy link
Member Author

arporter commented Jun 12, 2023

In the telco this morning @sergisiso reminded me that we can't handle Associate constructs that contain calls to impure routines either. I need to catch this case.

@arporter
Copy link
Member Author

I could refine what I have to check that any Call or Write is not the last statement in the construct. Beyond that, I could check whether there are any reads of any associate names after a Call or write.

@arporter
Copy link
Member Author

The ASSOCIATE constructs in the NV code we looked at today all contained calls and so this approach won't work. We could allow a user to permit calls within associate blocks but that feels dangerous and very hard to test. I think therefore that the only remaining option is to create temporary variables and that means we have to be able to determine their type.

@arporter arporter added Blocked An issue/PR that is blocked by one or more issues/PRs. and removed in progress labels Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocked An issue/PR that is blocked by one or more issues/PRs. NEMOVAR Relating to the NEMOVAR code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant