Skip to content

[hls-fuzzer] Add variable probability table - #1030

Open
zero9178 wants to merge 5 commits into
users/zero9178/template-type-systemfrom
users/zero9178/variable-probability-table
Open

zero9178 wants to merge 5 commits into
users/zero9178/template-type-systemfrom
users/zero9178/variable-probability-table

Conversation

@zero9178

@zero9178 zero9178 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

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)

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
zero9178 requested a review from Jiahui17 August 4, 2026 09:16
@zero9178
zero9178 force-pushed the users/zero9178/template-type-system branch from 4d4c095 to e36e6ab Compare October 5, 2026 08:41

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant