[RFC] MatchTable-based GlobalISel Combiners

Indeed, it’s just a small confusion. I think “top-down” (to describe root-to-leaves) is less confusing here and it’s closer to an academical definition. To me, the program order doesn’t matter in the definition, I just see it as matching a subtree in a bigger tree.

I’ll just use “root to leaves” from now on to avoid confusion :slight_smile:


I also have some (good!) progress updates on the implementation:

  • I re-added all the rule config logic - mostly copy-pasted from the old impl - and it seems to work just fine.
    • To support them, I added a special opcode GIM_CheckSimplePredicate which simply calls a function with a unsigned flag to check context-less predicates (doesn’t need a MI and can just be called right next to CheckFeatures). I think it’s a nice addition and it’s not leaking any combiner-specific stuff into the MatchTableExecutor.
  • I ported the AArch64 pre & post legalizer combiners to the new system and they also work completely fine (minus a small bug in my impl that was promptly fixed)
  • I generalized GIR_CombineApply to a GIR_CustomAction opcode, which, as the name implies, just runs a custom, generic action upon matching (and doesn’t mess with in/out instructions). The action doesn’t return anything and simply takes the MatcherState as parameter. I also think it’s a useful addition that doesn’t leak combiner-specific things into the executor.

Overall it’s in good shape I would say. It’s a bit messy in places but that’s expected of a WIP. I’ll rewrite/refactor the problematic parts while preparing the patches.

If someone feels like taking a look, here’s how AMDGPUGenPreLegalizerGICombiner.inc looks like now: AMDGPUGenPreLegalizerGICombiner.inc - Pastebin.com