<div dir="ltr"><div>1. Anonymous patterns are generally used for clarity and convenience. You can certainly define a list of patterns in the definition of the instruction, but it's often much clearer and easier to read to provide multiple patterns with anonymous patterns. Another thing this allows you to do is predicate the patterns - different anonymous patterns enclosed in different predicate blocks are useful. Also, you don't have to have a 1:1 mapping of input pattern to instruction when writing anonymous patterns - something like this is fine `def : Pat<(i32 (input_pattern i32:$in1, i32:$in2)), (i32 (INSTR1 $in1, (INSTR2 (INSTR3 $in3))))>;`. Something like that is obviously much harder to write in the definition of either of the 3 instructions.<br></div>2. See 1 above. I imagine there is something that is different between the two. Perhaps the input/output operands in the patterns. Also, you can produce multiple definitions that are synonyms with some differences in operands, register classes, etc. - see uses of `isCodeGenOnly`.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 27, 2017 at 12:33 PM, Liad Mordekoviz via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hello, </div><div>I come with 2 questions:</div><div>1. I’ve seen in multiple places the use of “def : some class<>” and can’t find any information about that anywhere,</div><div>Why would I declare a nameless def? </div><div>2. I’d like to create 2 patterns to be replaces with the same def, for example:</div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,'Courier New',monospace;line-height:18px;white-space:pre-wrap"><span style="color:#c586c0">def</span> ADD  : MyInstClass<0x10, <span style="color:#ce9178">"add"</span>, add>;</div></div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,'Courier New',monospace;line-height:18px;white-space:pre-wrap"><span style="color:rgb(197,134,192)">def</span> ADD  : MyInstClass<0x10, <span style="color:rgb(206,145,120)">"add"</span>, adde>;</div><div>(I’m trying to add support to add with carry)</div><div><br></div><div>Thank you very much!</div></div><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>