[llvm-commits] Patch: Pattern matching for intrinsics

Chandler Carruth chandlerc at google.com
Mon Dec 10 16:53:36 PST 2012


Hey Michael,

On Dec 7, 2012, at 1:40 PM, Michael Ilseman <milseman at apple.com> wrote:
>
> > Below is a patch to add some pattern matching support for intrinsics to
> PatternMatch.h:
> >
> >
> > Pattern matching code for intrinsics.
> >
> > Provides m_Intrinsic pattern that can be templatized over the intrinsic
> id and bind/match operands similarly to other pattern matchers. Also
> provides example template specialization for bswap (m_BSwap) and example of
> code cleanup for its use. One motiviation for this is to ease upcoming
> peephole fast-math optimizations which may want to inspect into built-in
> intrinsics.
>

I really like the idea of intrinsic matchers. I think the current matching
patterns need some tweaking though...

First, for the baseline matching: I would make this pattern able to match a
reasonable number of arguments. I think my ideal syntax would be:

  m_Intrinsic(Intrinsic::foo, m_Args(m_Foo(), m_Bar(), m_Baz(), ...))

I'm not sure if having the extra 'm_Args' layer is too much, we could fold
them directly into the top level matcher.

I think you can do this for as many arguments as we would ever need in a
pattern matcher by just providing default template arguments for them, and
have, say, 8 of them.


I think the only other abstractions which should exist at the matcher level
should be based on the synthetic classes in IntrinsicInst.h. In particular,
I think Unary and Binary aren't good abstractions for intrinsic calls. And
we shouldn't need them if we provide generic argument matching as above?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121210/a8ebd96c/attachment.html>


More information about the llvm-commits mailing list