UQ-PAC / aslp

Partial evaluator for Arm's Architecture Specification Language (ASL)
Other
6 stars 2 forks source link

implement aslBackwardsVisitor #72

Closed katrinafyi closed 2 months ago

katrinafyi commented 3 months ago

This adds a visitor suitable for basic backwards analyses. In doing so, we refactor the visit_* functions to place them inside a class. This makes it possible to override one or more of the methods, as we do in aslBackwardsVisitor for visit_stmts.

The backwards visitor has the same limitations as the existing forwards visitor. That is, merging results at control flow joins is difficult to do. However, for simple analyses, this can be worked around with careful use of enter/exit scope.

There is naming confusion in aslVisitor / aslForwardsVisitor / aslBackwardsVisitor which would be good to fix. aslVisitor defines the visit actions for specific AST nodes, whereas the aslForwardsVisitor/aslBackwardsVisitor applies these recursively in a particular order. Maybe these can be called aslForwardsTransform...?

ncough commented 3 months ago

Nice! My only other issue with the visitor is supporting transforms from individual statements into lists of statements. I'd be keen to get rid of the custom walks I keen implementing.

katrinafyi commented 3 months ago

There is now a draft commit to support returning stmt list. However, it has not been tested at all beyond the existing tests (which all use transforms on single statements, so really not at all).

Indeed, I think this will require a more careful implementation of the backwards visitor. One thought is that we need to make sure that we do not reverse statement lists before/after ChangeDoChildrenPost.

It sure would be nice to have unit tests.