Skip to content

[hls-fuzzer] Add template adaptors for generic type systems - #1024

Open
zero9178 wants to merge 2 commits into
users/zero9178/wrap-transfer-fnfrom
users/zero9178/template-type-system
Open

[hls-fuzzer] Add template adaptors for generic type systems#1024
zero9178 wants to merge 2 commits into
users/zero9178/wrap-transfer-fnfrom
users/zero9178/template-type-system

Conversation

@zero9178

Copy link
Copy Markdown
Collaborator

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 ASTNodes 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 ASTNodes in the future and none of the type system. It also substantially reduces the lines of code.

Depends on #1023

@zero9178
zero9178 requested a review from Jiahui17 July 29, 2026 12:43
@zero9178
zero9178 force-pushed the users/zero9178/template-type-system branch from ae2e8c1 to 937d63c Compare July 29, 2026 19:19
@zero9178
zero9178 force-pushed the users/zero9178/template-type-system branch from 937d63c to ea29177 Compare August 3, 2026 15:17
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.
@zero9178
zero9178 force-pushed the users/zero9178/template-type-system branch from ea29177 to 4d4c095 Compare August 4, 2026 08:52
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