Switch IR to Patronus Expressions, Enhance Edge Contraction#249
Merged
Conversation
cleanup the new graph_interpreter and patronus lowering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Switch to Patronus Expressions in Lowering/Edge Contraction:
ProtoGraphs now hold a PatronusContextfor expressions (type-aliased asExprContext).Symexpressions are turned into PatronusBVSymbol, and we track them withsymbol_expr: FxHashMap<SymbolId, ExprRef>, allowing us to consistently lower the sameSymbolIdto the sameExprRefas well as handleAssignops in the IR, which still refer to AST symbolsDontCareexpressions are turned intoBVSymbols with names prefixed by a DONTCARE_PREFIX (__dontcare__) @ekiwi maybe we could just store all theExprRefthat are DontCare in a set as an internal attribute of theProtoGraphinstead of doing this.andandorexpressions.Graph Interpreter:
ExprRefs in two contexts. IRExprRefs, and Patronus transition system simulatorExprRefs. we will refer toProtoExprRefandSimExprRefhere for writing clarity, but they're not distinguished in the codeBVSymbolProtoExprRefs. A binding just maps aProtoExprRefto one of 3 things:Sim(SimExprRef)binding , saying that thisProtoExprRefget's its concrete value from the simulatorArg(Value)binding - this is just the standardArgalso used in the AST interpreterDontCarebinding - i.e. we have no binding for this at all.SymbolValueStore, which Patronus will use to evaluateProtoExprRefs. This is simply done by looking up theArgandSimvalues from thearg_mappassed in to the interpreter by the.txparser, and from the Patronus simulator.DontCareare not left unbound, they are given random values.Edge Contraction updates: <-- this part can be moved into a LaTeX doc at some point and fleshed out further
InternalAssertFalseaction. if the guard is true this asserts false. these just panic if hit in the graph interpreter[1] <input port> := ite(P, <expr>, <input port expr>)at lowering.InternalAssertFalse. Suppose the existingForkis action guarded byP or Q, and the newForkis action guarded byR. the existingInternalAssertFalseguarded byP and Q. So we update the action guard toP or Q or Rand we update theInternalAssertFalseguard to(P or Q) and R. likewise if we added guard W, the guard would become `(P or Q or R) and W) etc.ite(P, new_assign, existing_assign). If it does not exist, we just append the action - this appended action must be an ITE anyways by invariant 2 above.trueguard always because the actual conditionals are fully represented by ITEs. TODO: this also should mean I can get rid of the semantics that handle retaining old port values into the new cycle n the graph_interpreter.rs , but I want to leave this to a follow-up PR once we have tested and thought about it.(Transition, set of NodeId)pairs. That set is the visited path of Nodes for this worklist item. if we revisit one of those nodes, we have a non-step cycle. If two transtions P and Q respectively send us back to a node we've already seen without a step, we just have anInternalAssertFalsefor the guarded transitions. The currentTransitionwe popped off the worklist has a guard that is literally the path condition, so we just have anInternalAssertFalsefor(Transition.guard AND P) OR (Transition.guard AND Q).normalize_assignmentsto ensure all ports have an assignment in each node. If a port didn't have an assignment, an assignment of the formDUT.a := DUT.ais generated (RHS is the old value).graphviz.rs
DontCareasX, and luckily we're using only a small part of the Patronus expression expressivity, so it's not too painful to write the formatter myself.