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

Constraint evaluation optimizer for MASM backend #339

Open
bobbinth opened this issue Jul 20, 2023 · 0 comments
Open

Constraint evaluation optimizer for MASM backend #339

bobbinth opened this issue Jul 20, 2023 · 0 comments
Labels
codegen enhancement New feature or request

Comments

@bobbinth
Copy link
Contributor

Currently, the code emitted for constraint evaluation by the MASM codegen is very simple but also very inefficient. Basically, for every operation we are loading values from memory, performing the operation, and then saving values back to memory. This happens even if some of the needed values are already on the stack.

We should improve this by building an optimized algebraic expression evaluator. The goal of this evaluator would be: given an algebraic expression and knowing locations of all operands (both on the stack and in memory), output an optimal sequence of MASM code to evaluate the expression. As as side effect, this would also update the information about what is located on the stack.

As a bonus, we could also try to optimize evaluation across multiple expressions - but we can also do this later.

A potential way to implement this would be to have a ConstraintEvalEmitter struct, which would be initialized with a reference to the AlgebraicGraph and information about OOD trace frame location in memory. Then, it could have visit_constraint() method which would take an expression index and a writer. This method would determine the optimal sequence of instructions needed to evaluate the constraint, and would write this sequence into the writer.

@bobbinth bobbinth added enhancement New feature or request codegen labels Jul 20, 2023
@bobbinth bobbinth added this to the AirScript v0.4 milestone Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant