<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div>Currently tablegen emits a rather surprising match code for the following case:</div><div><br></div><div>Suppose we have a pattern that uses a ComplexPattern to match an operand. This pattern then appears as a child pattern in a different pattern.</div><div>Pattern 1: (N1 ComplexPattern:OP)</div><div>Pattern 0: (N0 (N1 ComplexPattern:OP))</div><div><br class="webkit-block-placeholder"></div><div>The match code for ComplexPattern is passed in N1 in Pattern 1 and N0 in Pattern 0. This means that ComplexPattern is always passed in the root of the DAG it's embedded in, rather than the root of the DAG to which it is directly attached. I would expect that N1 would be passed into ComplexPattern regardless of the larger DAG in which it's embedded.</div><div><br class="webkit-block-placeholder"></div><div>Was this intended behavior, a bug, or just the way it was done?</div><div><br class="webkit-block-placeholder"></div><div>The attached patch fundamentally changes the semantics of ComplexPatterns to always be passed the DAG node to which the ComplexPattern is an operand. If the current behavior is as designed, or needed for backwards compatibility I'll try to add an attribute to complex patterns to make this behavior optional.</div><br><div> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>--</div><div>Christopher Lamb</div><div><br class="khtml-block-placeholder"></div><br class="Apple-interchange-newline"></span></span> </div></body></html>