<div dir="ltr">Thanks. Besides the suggestions, is it possible to handle this in Legalize phase of SelectionDAG? I found that SelectionDAGLegalize could mark an operation (SDNode) and value type (VT) as custom lowering (morph the SDNode) via TargetLoweringBase::setOperationAction, but it seems this doesn't support marking ISD::ADD $reg, #const since it has 2 value types.<div><br></div><div>-Thomson</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 24, 2014 at 12:06 PM, Marcello Maggioni <span dir="ltr"><<a href="mailto:hayarms@gmail.com" target="_blank">hayarms@gmail.com</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">Usually what you would do is having load matching the pattern of a constant or another solution is Custom Selecting (in ISelDAGToDAG) the ISD::Constant and expanding it to your LoadImmediate instruction that takes as input a TargetConstant (a kind of constant that skips selection).<div><br></div><div>You also need to make sure that none of your instructions that shouldn't accept constants match constants in their patterns/custom selection</div><div><br></div><div>Cheers,</div><div>Marcello</div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-12-23 19:17 GMT-08:00 Thomson <span dir="ltr"><<a href="mailto:lilotom@gmail.com" target="_blank">lilotom@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">To generate code for a target which doesn't have immediate constant as instruction operand, do I (the target specific back-end, XXXTarget) need to provide code to break up the SDNode with constant (like ISD::ADD $reg1, #1) to 2 SDNodes (ISD::LOAD $reg2, #1; ISD::ADD $reg1, $reg2) in my XXXTargetLowering::LowerOperation, or LLVM target-independent framework can do such transformation automatically with my instruction pattern definition?</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Thanks</div><span><font color="#888888"><div class="gmail_default" style="font-family:verdana,sans-serif">-Thomson</div></font></span></div>
<br></span>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>