Repository navigation
Conversation
Prior to this PR, every type system in a conjunction operated completely independent of other present type systems. This means that it was wholly responsible for context calculations based on its transfer functions. However, some type systems are explicitly designed as "action" type systems, that restrict program generation in some interesting way and do so based on some initial value in an input context. The 'OptionalTypeSystem' is e.g. one such case that allows only applying a sub-typesystem to some subset of the program. To enable the use case of "analysis" type systems that then cause an action in an "action" type system, this PR adds the concept of cross transfer functions. These are special transfer functions that can be used in subclasses of 'ConjunctionTypeSystemBase' and allows creating a transfer function that depends on another type system's context when calculating another's. Specific use-case for the future is that for a high II type system, we have one type system recognizing an innermost loop which then enables the generation of high latency reccurrences within innermost loops. This way neither type systems need to know of each other, only the conjuncting type system wires them up together.
Prior to this PR, adding a new AST node required relatively many changes throughout the code base. Besides the obvious cases of the generator and abstract type system, it also required updating the `ConjunctionTypeSystem`, the `OptionalTypeSystem` and the `CounterTypeSystem`. This is despite those 3 being fully generic over `ASTNode`s as can be seen by their body being mere copy-pastes. This PR fixes that issue by introducing C++ template adaptors to both implement and call a type system in a generic way by just giving it an `ASTNode` effectively. The type system implementation side is called `TemplateTypeSystem` which implements all methods of `AbstractTypeSystem` and dispatches to the corresponding generic method in the derived class (e.g. `getTransferFnImpl`). For callers, `TypeSystem` added generic methods such as `getTransferFn` that dispatches to the right concrete method for the given `ASTNode`. This makes it such that only the generic method + `TemplateTypeSystem` need to be updated for new `ASTNode`s in the future and none of the type system. It also substantially reduces the lines of code.
Prior to this PR the choice of variables was fully uniform. There are however use cases where we want specific variables to be more likely to be generated. One such use case e.g. is that loop recurrence variables should be used *after* the loop to make it as likely as possible for the loop to stay alive. (Making it more likely rather than forcing it via discards is easier to implement without destroying program diversity + makes it such that the generator cannot fail to generate a C program)
zero9178
force-pushed
the
users/zero9178/template-type-system
branch
from
October 5, 2026 08:41
4d4c095 to
e36e6ab
Compare
This branch has not been deployed
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.
Prior to this PR the choice of variables was fully uniform. There are however use cases where we want specific variables to be more likely to be generated.
One such use case e.g. is that loop recurrence variables should be used after the loop to make it as likely as possible for the loop to stay alive. (Making it more likely rather than forcing it via discards is easier to implement without destroying program diversity + makes it such that the generator cannot fail to generate a C program)