[llvm] [SelectionDAG] Introducing the SelectionDAG pattern matching framework (PR #78654)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 15:53:51 PST 2024


mshockwave wrote:

I'd just introduced the concept of match context to SDPatternMatch: now a user can pattern match a SDValue under certain match context using `sd_context_match`. A match context is really similar to that in DAGCombiner (e.g. VPMatchContext) except it only needs to implement `getDAG()` and `getTLI()`; The `match(SDValue, unsigned)` is optional. 
Furthermore, you can use custom contexts only in a sub-pattern via `m_Context(<custom context>, <sub pattern>)`.

Switching to this match context design also solves one of the problem where previously, the user had to provide a SelectionDAG in order to use any TLI hook, which was inconvenient in places lack of SelectionDAG. Now we can independently provide TLI instances to either `sd_match` or `sd_context_match`.

https://github.com/llvm/llvm-project/pull/78654


More information about the llvm-commits mailing list