<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/6/25 Tom Stellard <span dir="ltr"><<a href="mailto:tom@stellard.net" target="_blank">tom@stellard.net</a>></span><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">
<div class="im">On Sun, Jun 23, 2013 at 04:57:44PM +0100, David Chisnall wrote:<br>
> Hi,<br>
><br>
> In our version of LLVM, we've added different-sized iPTR* types, so we have an iPTR256 for our fat pointers.  This causes some problems with constraints, because the way that TableGen resolves constraints is not expected to handle multiple pointer types.  We've added a flag that can be set on a per-backend basis to turn this off.<br>

><br>
<br>
</div>I've been following this thread, and I just wanted to mention that we<br>
have a similar problem for newer GPU targets in the R600 backend where<br>
pointers for image reads and writes can be 128 or 256 bits and the<br>
largest integer type we support is i64.  Luckily, since image reads and<br>
writes aren't something you can do in a 'normal' C or C++ program we can<br>
get away with using special intrinsics that return the fat pointers,<br>
which we model using v16i8 and v32i8 types.  However, as we improve<br>
support for OpenCL and other compute oriented programming languages,<br>
we may need to starting using 'real' pointers.<br>
<div class="im"><br>
> Our problem is perhaps a bit different form yours, as our pointers must be loaded and manipulated via special instructions, they can not use the integer instructions or registers.<br>
><br>
<br>
</div>We also have a somewhat related issue with newer GPUs, that have<br>
essentially two different instruction sets.  However, instead of having<br>
one for pointers and one for integers like your target, we have a Vector<br>
ALU (VALU) for manipulating integers and floats and a Scalar ALU (SALU)<br>
for handling control flow and loading for constant memory.  There is a<br>
lot overlap between these two instruction sets (i.e both support almost<br>
all standard integer operations).  Since tablegen matches patterns based<br>
on types, it is impossible for us to select from both instruction sets,<br>
and it sounds like you will have the same problem if you treat pointers as<br>
integer types. </blockquote><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">
<br>
To make matters worse, you can only copy registers between<br>
the ALUs in one direction.  SALU to VALU is legal, but VALU to SALU isn't.<br>
Currently we do post processing on the DAG after instruction selection<br>
to help avoid these illegal copies.  I've considered also adding post<br>
processing to help select the optimal instruction type (VALU or SALU),<br>
but I think something like this may be easier to handle in a<br>
pre-regalloc scheduler pass.<br>
<br>
Not sure if any of this information will help you, but sometimes it's<br>
just nice to know that you're not the only one with a strange target ;)</blockquote><div><br></div><div>Aha, that makes two of us. Thank you!<br></div><div><br></div><div style>You newer GPU is much more complicated than our prototype DSP.</div>
<div style><br></div><div style>I am about to add a pre-isel pass to tag DAGNodes and replace operand types with some target-specific ones, then let built-in instruction selector do its job. Hope this work out for me.</div>
<div style><br></div><div style>Regard!</div><div> </div><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">
<span class=""><font color="#888888"><br>
-Tom<br>
</font></span><div class=""><div class="h5"><br>
<br>
> David<br>
><br>
> On 23 Jun 2013, at 15:49, 杨勇勇 <<a href="mailto:triple.yang@gmail.com">triple.yang@gmail.com</a>> wrote:<br>
><br>
> > David, thanks for your immediate response.<br>
> ><br>
> > Since iPTR is a reserved type for tablegen internal use, can you make a further explanation?<br>
> ><br>
> > On the other hand, it can be simply treated as a register class assignment problem during register allocation.<br>
> > Assume both pointer and integet have a 32 bit width. backend handles it just as to i32. When it performs register allocation, it can retrieve from target constraint information about which register class is valid for a operand, and this is determined by which instruction consumes the operand.<br>

> ><br>
> > So is there a convienient way to constrain register class assignment, like a tablegen interface or something else?<br>
> ><br>
> > Regards.<br>
> ><br>
> > 2013/6/21 David Chisnall <<a href="mailto:David.Chisnall@cl.cam.ac.uk">David.Chisnall@cl.cam.ac.uk</a>><br>
> > We also have this problem, and have added iPTR types to the back end.  Our pointers are actually fat pointers, so this also requires tweaking some optimisations (for example, things like to turn GEPs with 64-bit offsets into pointer-sized offsets, but our pointers are larger than any integer type that we support...).  Most of the changes are a bit ugly, and I'm loath to upstream them without an in-tree target that has these requirements, or they will be hard for anyone else to keep working.<br>

> ><br>
> > David<br>
> ><br>
> > On 21 Jun 2013, at 06:00, 杨勇勇 <<a href="mailto:triple.yang@gmail.com">triple.yang@gmail.com</a>> wrote:<br>
> ><br>
> > > llvm code generator lowers both integer and pointer types into ixx(say, i16, i32, i64, ...). This make senses for some optimizations.<br>
> > ><br>
> > > However, integer registers and pointer registers is expilicitly distinguished from each other for some architectures, like TriCore, Blackfin, and our lab prototype dsp, which accelerates address computation and memory access.<br>

> > ><br>
> > > I have already read this mail thread: <a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-May/022142.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-May/022142.html</a> , and I am wondering how is the progress about it.<br>

> > ><br>
> > > Thanks.<br>
> > ><br>
> > > --<br>
> > > 杨勇勇 (Yang Yong-Yong)<br>
> > > _______________________________________________<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>
> ><br>
> ><br>
> ><br>
> > --<br>
> > 杨勇勇 (Yang Yong-Yong)<br>
><br>
><br>
> _______________________________________________<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>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>杨勇勇 (Yang Yong-Yong)
</div></div>