<div dir="ltr">Thanks Dylan,<div><br></div><div>I am working on a backend which has mulhsu instruction that performs multiplication between signed and unsigned number and returns upper 32 bits into result register. I think I also need to write some code probably as you indicated to check signedness of the operands and based on that lower to mulhsu instruction.</div><div><br></div><div>-Vivek</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 27, 2017 at 11:13 AM, Dylan McKay <span dir="ltr"><<a href="mailto:me@dylanmckay.io" target="_blank">me@dylanmckay.io</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hey Vivek,<div><br></div><div>We don't directly emit the <span style="color:rgb(51,51,51);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap">MULSURdRr </span>instruction. On top of this, I don't believe any of the AVR multiplication instructions have patterns in TableGen.</div><div><br></div><div>This is because the AVR mul instructions are quite strange. Almost all of the other instructions of the 'Rd, Rr' format take the values of Rd and Rr, perform a computation and place the result in the destination register Rd. The mul instructions implicitly use r0 and r1 to store the results. This makes it quite hard to fit into TableGen and so we perform custom lowering for these nodes.</div><div><br></div><div>We expand the MUL DAG node into 'ISD::UMUL_LOHI' or 'ISD::SMUL_LOHI'. We see these in AVRISelDAGToDAG.cpp and custom lower them (see AVRISelDAGToDAG::<wbr>selectMultiplication) into MULSRdRr or MULRdRr, depending on signedness. Later on we have a custom inserter which inserts instructions to clear the r1,r0 scratch registers after use.</div><div><br></div><div>The <span style="color:rgb(51,51,51);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap">MULSURdRr </span>instruction you mentioned is not generated by LLVM unless you use it yourself as part of some inline assembly.</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Mon, Feb 27, 2017 at 12:41 AM, vivek pandya 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></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><font color="#333333" face="-apple-system, blinkmacsystemfont, segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol"><span style="font-size:14px">Hello LLVMDevs,</span></font><div><font color="#333333" face="-apple-system, blinkmacsystemfont, segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol"><span style="font-size:14px"><br></span></font></div><div><font color="#333333" face="-apple-system, blinkmacsystemfont, segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol"><span style="font-size:14px">I am looking for an example for how to lower LLVM IR to mulsu kind of instruction. I found that AVR back end have such instruction but AVRInstrInfo.td does not define any DAG pattern for which this instruction gets emitted.</span></font></div><div><table class="m_7305676343953937541m_3895461386356013874gmail-highlight m_7305676343953937541m_3895461386356013874gmail-tab-size m_7305676343953937541m_3895461386356013874gmail-js-file-line-container" style="box-sizing:border-box;border-collapse:collapse;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,"segoe ui",helvetica,arial,sans-serif,"apple color emoji","segoe ui emoji","segoe ui symbol";font-size:14px"><tbody style="box-sizing:border-box"><tr style="box-sizing:border-box"><td id="m_7305676343953937541m_3895461386356013874gmail-LC554" class="m_7305676343953937541m_3895461386356013874gmail-blob-code m_7305676343953937541m_3895461386356013874gmail-blob-code-inner m_7305676343953937541m_3895461386356013874gmail-js-file-line" style="font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;word-wrap:normal;white-space:pre-wrap">def MULSURdRr : FMUL2RdRr<1,</td></tr><tr style="box-sizing:border-box"><td id="m_7305676343953937541m_3895461386356013874gmail-L555" class="m_7305676343953937541m_3895461386356013874gmail-blob-num m_7305676343953937541m_3895461386356013874gmail-js-line-number" style="font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;box-sizing:border-box;padding:0px 10px;width:50.4px;min-width:50px;font-size:12px;line-height:20px;color:rgba(0,0,0,0.298039);text-align:right;white-space:nowrap;vertical-align:top"></td><td id="m_7305676343953937541m_3895461386356013874gmail-LC555" class="m_7305676343953937541m_3895461386356013874gmail-blob-code m_7305676343953937541m_3895461386356013874gmail-blob-code-inner m_7305676343953937541m_3895461386356013874gmail-js-file-line" style="font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;word-wrap:normal;white-space:pre-wrap"> (outs),</td></tr><tr style="box-sizing:border-box"><td id="m_7305676343953937541m_3895461386356013874gmail-L556" class="m_7305676343953937541m_3895461386356013874gmail-blob-num m_7305676343953937541m_3895461386356013874gmail-js-line-number" style="font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;box-sizing:border-box;padding:0px 10px;width:50.4px;min-width:50px;font-size:12px;line-height:20px;color:rgba(0,0,0,0.298039);text-align:right;white-space:nowrap;vertical-align:top"></td><td id="m_7305676343953937541m_3895461386356013874gmail-LC556" class="m_7305676343953937541m_3895461386356013874gmail-blob-code m_7305676343953937541m_3895461386356013874gmail-blob-code-inner m_7305676343953937541m_3895461386356013874gmail-js-file-line" style="font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;word-wrap:normal;white-space:pre-wrap"> (ins GPR8:$lhs, GPR8:$rhs),</td></tr><tr style="box-sizing:border-box"><td id="m_7305676343953937541m_3895461386356013874gmail-L557" class="m_7305676343953937541m_3895461386356013874gmail-blob-num m_7305676343953937541m_3895461386356013874gmail-js-line-number" style="font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;box-sizing:border-box;padding:0px 10px;width:50.4px;min-width:50px;font-size:12px;line-height:20px;color:rgba(0,0,0,0.298039);text-align:right;white-space:nowrap;vertical-align:top"></td><td id="m_7305676343953937541m_3895461386356013874gmail-LC557" class="m_7305676343953937541m_3895461386356013874gmail-blob-code m_7305676343953937541m_3895461386356013874gmail-blob-code-inner m_7305676343953937541m_3895461386356013874gmail-js-file-line" style="font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;word-wrap:normal;white-space:pre-wrap"> "mulsu\t$lhs, $rhs",</td></tr><tr style="box-sizing:border-box"><td id="m_7305676343953937541m_3895461386356013874gmail-L558" class="m_7305676343953937541m_3895461386356013874gmail-blob-num m_7305676343953937541m_3895461386356013874gmail-js-line-number" style="font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;box-sizing:border-box;padding:0px 10px;width:50.4px;min-width:50px;font-size:12px;line-height:20px;color:rgba(0,0,0,0.298039);text-align:right;white-space:nowrap;vertical-align:top"></td><td id="m_7305676343953937541m_3895461386356013874gmail-LC558" class="m_7305676343953937541m_3895461386356013874gmail-blob-code m_7305676343953937541m_3895461386356013874gmail-blob-code-inner m_7305676343953937541m_3895461386356013874gmail-js-file-line" style="font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;word-wrap:normal;white-space:pre-wrap"> []>,</td></tr><tr style="box-sizing:border-box"><td id="m_7305676343953937541m_3895461386356013874gmail-L559" class="m_7305676343953937541m_3895461386356013874gmail-blob-num m_7305676343953937541m_3895461386356013874gmail-js-line-number" style="font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;box-sizing:border-box;padding:0px 10px;width:50.4px;min-width:50px;font-size:12px;line-height:20px;color:rgba(0,0,0,0.298039);text-align:right;white-space:nowrap;vertical-align:top"></td><td id="m_7305676343953937541m_3895461386356013874gmail-LC559" class="m_7305676343953937541m_3895461386356013874gmail-blob-code m_7305676343953937541m_3895461386356013874gmail-blob-code-inner m_7305676343953937541m_3895461386356013874gmail-js-file-line" style="font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;word-wrap:normal;white-space:pre-wrap"> Requires<[SupportsMultiplicati<wbr>on]>;</td></tr></tbody></table></div><div><font color="#333333" face="-apple-system, blinkmacsystemfont, segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol"><span style="font-size:14px"> Also simple grep around related words does not show any other information. </span></font></div><div></div><div><span style="font-size:14px;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,"segoe ui",helvetica,arial,sans-serif,"apple color emoji","segoe ui emoji","segoe ui symbol""><br></span></div><div><font color="#333333" face="-apple-system, blinkmacsystemfont, segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol"><span style="font-size:14px">Can some one explain me how this kind of instruction should be lowered ? </span></font></div><div><font color="#333333" face="-apple-system, blinkmacsystemfont, segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol"><span style="font-size:14px"><br></span></font></div><div><font color="#333333" face="-apple-system, blinkmacsystemfont, segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol"><span style="font-size:14px">Sincerely,</span></font></div><div><font color="#333333" face="-apple-system, blinkmacsystemfont, segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol"><span style="font-size:14px">Vivek</span></font></div></div>
<br></div></div>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">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>
</blockquote></div><br></div>