<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt"><div dir="ltr">Hey Michael,<div><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">On Dec 7, 2012, at 1:40 PM, Michael Ilseman <<a href="mailto:milseman@apple.com">milseman@apple.com</a>> wrote:<br>
<br>
> Below is a patch to add some pattern matching support for intrinsics to PatternMatch.h:<br>
><br>
><br>
> Pattern matching code for intrinsics.<br>
><br>
> 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.<br>
</div></div></blockquote><div><br></div><div style>I really like the idea of intrinsic matchers. I think the current matching patterns need some tweaking though...</div><div style><br></div><div style>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:</div>
<div style><br></div><div style>  m_Intrinsic(Intrinsic::foo, m_Args(m_Foo(), m_Bar(), m_Baz(), ...))</div><div style><br></div><div style>I'm not sure if having the extra 'm_Args' layer is too much, we could fold them directly into the top level matcher.</div>
<div style><br></div><div style>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.</div><div style><br>
</div><div style><br></div><div style>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?</div>
</div></div></div></div></div>