summaryrefslogtreecommitdiff
path: root/Notes/MIR-Match.md
blob: cc95522c0597800dfec879303273a3e45b6126eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
% MIR Match Generation Algorithms and Notes

Alternative DecisionTree generator
=================================

Take the full list of rules and iteratively partition and simplify/propagate
- Requires that all rules have the same format (which they do)


For each index in the rule (all rules must be the same length)
- Sort the rules (with `_` sorting to the end)
- If all rules are `_`, skip and continue
- Group into sub-lists based on the condition
- Add copies of the default to all sub-lists
 - NOTE: Default is maintained only if the ruleset is not exhaustive at this level


- TODO: The above approach beaks with value ranges (which can overlap)
 - Requires special handling to resolve the overlaps
 - Ranges sort after?



Alternative Generator 2
=======================

Maintains match ordering

1. Calculate branch rulesets (as existing)
1. While rules to process:
 1. Group based on shared values.
 1. Generate dispatch arm for each group
 1. Recurse into group, passing local _ as fallback (or parent _ if none)

```

for 

```