<div dir="ltr"><div><div>Thanks Andrew and Renato,</div><div><br></div><div>One think I didn't mention, and I should probably made it more explicit in my RFC is that: "the new predicate framework is extensible".</div><div><br></div><div>That means, developers can extend it by adding new Check predicates.</div><div>As long as they also teach the PredicateExpander how to do the lowering for those new predicates, then everything should be fine.</div><div><br></div><div>--</div><div><br></div><div>In the RFC I mentioned how we can use a TIIPredicate to let tablegen auto-generate
two version of function `isGPRZero`:</div><div> 1) a version that takes a MachineInstr as input, and that is automatically generated by tablegen into the target-specific instruction info class.</div><div> 2) another version (still auto-generated by tablegen) that takes a MCInst as input.<br></div><div><br></div><div>The goal is to help users defining a predicate the check logic. If we use a TIIPredicate, we specify the logic only once, in a declarative way, and then we let tablegen generate code for us.</div><div><br></div>If for some reason, a user doesn't want to use this approach, then they can still provide their own implementation for variant 2. (i.e. the version of `isGPRZero` that takes a MCInst as input).<br></div><div><br><div>We can then introduce a new MCPredicate as follows:</div><div><br></div><div>```</div><div>// MCInstVariant and MachineInstVariant are both function names.<br></div><div>//</div><div>// MCinstVariant is the function to call if we want to check properties on MCInst.</div><div>// MachineInstrVariant is the function to call if we want to check properties on MachineInstr.<br></div><div><br></div><div>CheckFunction<string MCInstVariant, string MachineInstrVariant> : MCPredicate {<br></div><div> string MCinstFn = MCInstVariant;</div><div> string MachineInstrFn = MachineInstrVariant;<br></div><div>}<br></div><div>```<br></div><div><br></div>Then we teach the PredicateExpander (in utils/Tablegen/PredicateExpander.cpp|.h) how to lower that new predicate.</div><div><br></div><div>Here is an example of how this could be done:<br></div><div>```</div><div>void PredicateExpander::expandCheckFunction(formatted_raw_ostream &OS, StringRef MCInstVariant, StringRef MachineInstrVariant) {</div><div> if (shouldExpandForMC())</div><div> OS << MCInstVariant;</div><div> else</div><div> OS << MachineInstrVariant;</div><div> OS << "(MI)";<br></div><div>}<br></div><div>```</div><div><br></div><div>Basically, if we are generating code for MC, then we expand a call to "
MCInstVariant
". Otherwise, we expand a call to "
MachineInstrVariant" (both user defined functions).<br></div><div><br></div><div>--</div><div><br></div><div>The bottom line is: the framework is extensible.</div><div>As long as we tell the PredicateExpander how to lower/expand our new predicates, then we can implement different approaches.</div><div><br></div><div>I hope this answers to the comments from <a href="https://reviews.llvm.org/D46701">https://reviews.llvm.org/D46701</a>.</div><div><br></div><div>Thanks,</div><div>Andrea<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 10, 2018 at 10:24 PM, Renato Golin <span dir="ltr"><<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 10 May 2018 at 21:58, Andrew Trick <<a href="mailto:atrick@apple.com">atrick@apple.com</a>> wrote:<br>
> Fantastic writeup! It’s great to see so much progress on fundamental<br>
> infrastructure.<br>
><br>
> My time for LLVM code review is extremely limited. Can someone work with<br>
> Andrea to get these patches in?<br>
<br>
</span>Hi Andrew,<br>
<br>
Same here, but this has been a long goal for me, too, so I'll do my best.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
cheers,<br>
--renato<br>
</font></span></blockquote></div><br></div>