<div dir="ltr"><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 3, 2014 at 5:16 PM, Steve King <span dir="ltr"><<a href="mailto:steve@metrokings.com" target="_blank">steve@metrokings.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello LLVM,<br>
<br>
Suppose I have many instructions with AsmString "foo  $src".  The<br>
specific foo opcode depends on the value of $src.  I arrange<br>
AsmOperandClasses and superclasses for $src so the assembler picks the<br>
right foo.  That seems fine as far as the assembler goes.<br>
<br>
During compiler instruction selection, I can use a CodeGenOnly=1<br>
pseudo with assembly "foo $src" and emit .s files from llc.  These go<br>
to the assembler which chooses the foo opcode using the<br>
AsmOperandClass hierarchy.  The compiler didn't have to worry about<br>
which foo is the right foo.<br>
<br>
However, I want to use llc's ability to produce object files directly.<br>
That path skips assembly parsing, so my AsmOperandClass logic can't<br>
help pick the right foo, correct?<br>
<br>
What is the right approach?  Do I add DAG pattern matching logic to<br>
mirror all the AsmOperandClass selection logic?  If so, is there an<br>
easy way to detect if assembler instruction selection and compiler<br>
instruction selection are out of sync?<br>
<br>
Thanks,<br>
-steve<br></blockquote><div><br></div>CodeGen and ASM operands matching mechanisms are different. <div><br></div><div>You can do something like this:<br>  <span class="">def</span> Foo_AsmOperand: AsmOperandClass {<br>    <span class="">let</span> Name = <span class="">“Foo”</span>;<br>    <span class="">let</span> PredicateMethod = <span class="">"is_Foo"</span>;<br>  }<br>  <span class="">def</span> Foo_Operand : Operand<i32>, ComplexPattern<i32, 1, <span class="">"Select_Foo"</span>, [imm], []> {<br>    <span class="">let</span> ParserMatchClass = Foo_AsmOperand;</div><div>  }</div><div><br></div><div>You can manage by having is_Foo and Select_Foo share logic by calling the same common function.</div></div></div></div>