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

split initialization on param, type, and refs #14565

Closed
mppf opened this issue Dec 3, 2019 · 1 comment
Closed

split initialization on param, type, and refs #14565

mppf opened this issue Dec 3, 2019 · 1 comment

Comments

@mppf
Copy link
Member

mppf commented Dec 3, 2019

PR #14564 adds split initialization for var and const declarations.

This issue tracks the feature request to add it for param, type, ref, and const ref declarations.

@mppf mppf mentioned this issue Dec 11, 2019
3 tasks
mppf added a commit that referenced this issue Dec 12, 2019
Split initialization

This PR adds support for split initialization of Chapel variables.

Resolves #14271 which contains design discussion.

When a variable is declared without an initialization expression
(including possibly without a type), the compiler will search for a
following assignment and make that assignment initialize the variable.
The following assignment must be the first usage of the variable on that
control path. It can be contained in a nested block or a conditional but
not in a loop, begin, on statement, or function.

For example:

``` chapel
var a;
a = 2; // equivalent to `var a = 2`

const r: MyGenericRecord;
r = new MyGenericRecord(1); // equivalent to
                            // const r:MyGenericRecord = new MyGenericRecord(1)
```

The implementation approach in the compiler is to adjust the
normalization of variable initialization. Additionally, at parse time,
mark variables that are declared without a type and without an
initialization expression as requiring split initialization.

At normalization time, the compiler searches for applicable assignment
statements (called with `findInitPoints`). If these are found, it
normalizes the declaration into `PRIM_INIT_VAR_SPLIT_DECL` and the
assignment statements into `PRIM_INIT_VAR_SPLIT_INIT`. Function
resolution then handles these.

This PR also includes some changes to misc.cpp for reporting
instantiations. In particular, the code previously stored an `FnSymbol*`
for the last function for which an error was printed. That can go wrong
if this function is deleted in the meantime. So, it now uses integer ids
instead.

Additionally, this PR includes changes to the representation of `on`
statements for local compilation. These are now represented with
`PRIM_BLOCK_ELIDED_ON` and changed into regular blocks in 
createTaskFunctions.

PR #14594 contains the spec changes for this feature.

Future Work:
 * split initialization for `param`, `type`, `const ref`, and `ref`
   #14565
 * issue #14621 discusses the interaction between split initialization
   and nested functions

Reviewed by @vasslitvinov - thanks!

- [x] full local testing
- [x] primers pass with GASNet
- [x] primers pass with numa locale model
@mppf
Copy link
Member Author

mppf commented Jan 24, 2020

PRs #14662, #14657 and #14673 did this.

@mppf mppf closed this as completed Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant