Add Data Representation Flattening Pass - #555
Hidden character warning
Conversation
|
I think one possible way to address the second problem is:
|
|
Hmm that does seem quite complicated. I don't think we actually need to transform the pattern matches in such a fine-grained way. We should be able to replace the entire deep pattern match by a single tag-check in one go. Indeed, the extracted ctor fields are only used for matching the shape itself, and not for something else; we should be able to not extract them at all. This might require a bit of a variable use analaysis, though. Or, better, we should simply find a way of annotating those "shape" pattern matches, which always discard the extracted fields, so the IR pass does not have to make a guess. Actually, now that I think of it, why don't we just generate code that already includes all the necessary info (in the form of annotations) for easily compiling the shape match away? Eg, something like: |
Actually, it seems that the @matchShapes(C(D(_)), C(E(1)), F(_))
if x is
C(D(_)) then ...
C(E(1)) then ...
F(_) then ...Those |
MatchnodesProblems to be addressed:
How to track linearity (discussed in the meeting and decided to insert tags for class instances for pattern matching for now).
Block IR uses a flattened pattern matching, which makes tag checks difficult. e.g.,It is flattened into:
Assume that
Cons(1, Cons(2, Cons(3, Cons(dyn, Cons(dyn, Cons(dyn, Nil))))))'s tag is0, we need to check if we want to replace the whole huge matching with the tag checking. It is not clear when to set the boundary to say that the inner irrelevant matchings are untouched. e.g.,how should we know whether we are now checking against a nested pattern (e.g.,
C(D(...), E(...), F(...))), or this is just a user code?