<div dir="ltr"><div>Good to know, thanks!</div><div><br></div><div>Currently I'm just not declaring an i8 register class since we only have load/store/convert available for that type.  This works fine for most uses, but becomes a hassle when dealing with function parameters.  For example, if the function argument is i8, the code in LowerFormalArguments sees it as an i16 since that is the next target legal type.  For my target, we need to load function parameters from a special memory pool; so I need to emit any-extend loads of an 8-bit memory VT to a 16-bit register VT.  But I don't see any way to get at the information that the function argument is really 8 bits unless I go back to the llvm::Function definition.  This is do-able, but feels wrong to be doing in TargetLowering.  I was trying to get around this by declaring i8 as a legal type (strictly speaking, it *is* legal in the target), and relying on the legalizer to perform any extensions for me; but now it looks like it may be easier to just teach SelectionDAGBuilder to pass along the original parameter type in LowerFormalArguments and friends.</div>
<div><br></div><br><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 8, 2013 at 1:37 PM, Jim Grosbach <span dir="ltr"><<a href="mailto:grosbach@apple.com" target="_blank">grosbach@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Justin,<br>
<br>
This is a big weakness of the current SelectionDAG infrastructure. There's not a really clean way to do this. The legalizer assumes that if a type is "legal" at all, the target can do at least basic arithmetic on that type.<br>

<br>
Theoretically, your approach of setting the operations to "TargetLowering::Promote" for i8 should work. I think it would be reasonable to fix SelectionDAG to allow that. It's probably a non-trivial task, though.<br>

<br>
-Jim<br>
<div><div class="h5"><br>
On Aug 8, 2013, at 7:35 AM, Justin Holewinski <<a href="mailto:justin.holewinski@gmail.com">justin.holewinski@gmail.com</a>> wrote:<br>
<br>
> Is there a way to define a register class that is storage-only?  I want to have an i8 register class that I can use for loads/stores/converts, but that does not support arithmetic.<br>
><br>
> It seems addOperationAction(ISD::ADD, MVT::i8, Promote) and SetPromotedToType(ISD::ADD, MVT::i8, MVT::i16) are not sufficient, as the legalizer just looks at whether or not the underlying type is legal (which it is).  So come instruction selection time I still have i8 adds.  Do I need to custom handle all 8-bit arithmetic, or is there some way to have the legalizer do the promotion like it would for an illegal type?<br>

><br>
><br>
> --<br>
><br>
> Thanks,<br>
><br>
> Justin Holewinski<br>
</div></div>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">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><br clear="all"><div><br></div>-- <br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div>
</div></div>