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

506 refactor value handling #511

Merged
merged 15 commits into from
Mar 27, 2025
Merged

506 refactor value handling #511

merged 15 commits into from
Mar 27, 2025

Conversation

jberthold
Copy link
Member

  • distinguish TypedLocal by subsorts TypedValue, NewLocal, MovedLocal (renaming constructors)
  • introduce supersort Evaluation with result sort TypedValue for Operand and RValue
  • introduce MIRError sort inhabited by all errors, and a labelled stop rule
  • use heating/cooling for a number of constructs that read or/and write locals

@jberthold jberthold requested review from dkcumming and gtrepta March 27, 2025 03:28
@jberthold jberthold marked this pull request as ready for review March 27, 2025 03:28
Copy link
Collaborator

@dkcumming dkcumming left a comment

Choose a reason for hiding this comment

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

Looks great

Comment on lines +440 to +458
// no value to return, skip writing
rule <k> #execTerminator(terminator(terminatorKindReturn, _SPAN)) ~> _
=>
#execBlockIdx(TARGET)
</k>
<currentFunc> _ => CALLER </currentFunc>
//<currentFrame>
<currentBody> _ => #getBlocks(FUNCS, CALLER) </currentBody>
<caller> CALLER => NEWCALLER </caller>
<dest> _ => NEWDEST </dest>
<target> someBasicBlockIdx(TARGET) => NEWTARGET </target>
<unwind> _ => UNWIND </unwind>
<locals> ListItem(_:NewLocal) _ => NEWLOCALS </locals>
//</currentFrame>
// remaining call stack (without top frame)
<stack> ListItem(StackFrame(NEWCALLER, NEWDEST, NEWTARGET, UNWIND, NEWLOCALS)) STACK => STACK </stack>
<functions> FUNCS </functions>
requires CALLER in_keys(FUNCS)
[preserves-definedness] // CALLER lookup defined
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am trying to think of what this looks like in the mir code. What is an example of this?

Copy link
Member Author

Choose a reason for hiding this comment

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

The new rule is for the case where local _0 has not been written to (it is still sort NewLocal ) but the function returns. That happens regularly when a function returns nothing (i.e., unit). We used to "write" the noValue as a NoOp but now the sort is different so we should skip it.

@jberthold jberthold merged commit ecdc904 into master Mar 27, 2025
5 checks passed
@jberthold jberthold deleted the 506-refactor-value-handling branch March 27, 2025 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants