-
Notifications
You must be signed in to change notification settings - Fork 19
Association Dialect #173
Description
Maybe an association dialect would be helpful.
Often, when we rewrite things, we want to replace something with a semantically equal term on another level.
The destination term can often be written (more or less) conveniently in thorin.
This is especially the case for staged lowering like present in the autodiff and matrix dialect.
These associations are currently implemented using naming conventions and internals (a hack around externals that are erased).
The association dialect would keep track of associations in the thorin code and expose map on the C++ side.
No special care to quoting/reification is needed as we usually only want to associate axioms anyway.
Example:
// in associate
%assoc.associate: [T1:*,T2:*] -> %assoc.association_class -> T1 -> T2 -> %assoc.association
// in matrix
%matrix.association : %assoc.association_class
.extern associate_matrix() {
(%assoc.associate %matrix.association %matrix.prod internal_matrix_mapRed_prod,
...)
}There could also be generalized passes on associations (e.g. replace all terms in a class with their associated counterpart).
This seems like a simple way to cleverly utilize the dialect infrastructure and get away from string matching.
This dialect could be combined or extend the sketched rewrite-mapping dialect from previous discussions.