Procedure call parameter-passing abstraction #255
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a transform (behind the flag
--parameter-form
) which lifts all registers to local variables passed via procedure parameters.Procedures now have a list of formal input parameters and output parameters, as well as a default mapping from these parameters to the actual parameters for use at calls to these procedures (this is set up by the front end and procedure form transform, and used by the spec loader and output pass).
DirectCall
.Return()
statements (unlike boogie we can return local variables rather than having a special variable). The Directcall then binds these to its mappingoutParams
, from formal out param name to lexpr variable.So now we have
returns have the following meaning, where the
a_out
etc. are the formal out parameters of the procedure.Similarly, calls provide the actual in parameters (a,b,c), and the actual return parameters (a', b', c').
when parameter-form is disabled
main_argc
is replaced byR0[31:0]
and the parameters attached to procedures are removedwhen enabled
use LocalVar to describe the parameters.
Generally this is motivated by the static analysis and program transforms, as parameter passing means the ssa form and interpretation def/use chains work across procedure calls more naturally. We probably don't want to enable this by default now, but I will try building the analysis on top of it and refine it as needed, but this provides the basis. I may implement the inverse transform too if it makes sense.