summaryrefslogtreecommitdiffstats
path: root/mlir/test/lib/IR/TestMatchers.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [mlir] m_Constant()Lorenzo Chelini2020-01-131-0/+3
| | | | | | Summary: Introduce m_Constant() which allows matching a constant operation without forcing the user also to capture the attribute value. Differential Revision: https://reviews.llvm.org/D72397
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-231-13/+4
| | | | PiperOrigin-RevId: 286906740
* Post-submit cleanups in RecursiveMatchersNicolas Vasilache2019-12-091-28/+34
| | | | | | | This CL addresses leftover cleanups and adds a test mixing RecursiveMatchers and m_Constant that captures properly. PiperOrigin-RevId: 284551567
* Add a layer of recursive matchers that compose.Nicolas Vasilache2019-12-081-0/+150
This CL adds support for building matchers recursively. The following matchers are provided: 1. `m_any()` can match any value 2. `m_val(Value *)` binds to a value and must match it 3. `RecursivePatternMatcher<OpType, Matchers...>` n-arity pattern that matches `OpType` and whose operands must be matched exactly by `Matchers...`. This allows building expression templates for patterns, declaratively, in a very natural fashion. For example pattern `p9` defined as follows: ``` auto mul_of_muladd = m_Op<MulFOp>(m_Op<MulFOp>(), m_Op<AddFOp>()); auto mul_of_anyadd = m_Op<MulFOp>(m_any(), m_Op<AddFOp>()); auto p9 = m_Op<MulFOp>(m_Op<MulFOp>( mul_of_muladd, m_Op<MulFOp>()), m_Op<MulFOp>(mul_of_anyadd, mul_of_anyadd)); ``` Successfully matches `%6` in: ``` %0 = addf %a, %b: f32 %1 = addf %a, %c: f32 // matched %2 = addf %c, %b: f32 %3 = mulf %a, %2: f32 // matched %4 = mulf %3, %1: f32 // matched %5 = mulf %4, %4: f32 // matched %6 = mulf %5, %5: f32 // matched ``` Note that 0-ary matchers can be used as leaves in place of n-ary matchers. This alleviates from passing explicit `m_any()` leaves. In the future, we may add extra patterns to specify that operands may be matched in any order. PiperOrigin-RevId: 284469446
OpenPOWER on IntegriCloud