<div>Thanks, Doug.</div>
<div> </div>
<div>I also found this page, PowerPC-specific: <a href="http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/PowerPC-AltiVec-Built_002din-Functions.html">http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/PowerPC-AltiVec-Built_002din-Functions.html</a><br>
</div>
<div>In the PS3 gcc, "vector" appears to be built-in.</div>
<div> </div>
<div>Using the info from the page you pointed me to, I've been experimenting a little to see what Clang seems to understand.  Apparently I can do something like this:</div>
<div> </div>
<div>  __attribute__((vector_size(16))) unsigned char MyVectorVariable;</div>
<div> </div>
<div>And I can do:</div>
<div> </div>
<div>  typedef __attribute__((vector_size(16))) unsigned char MyVectorTypeUC;<br></div>
<div>But if I try to simulate the "vector" type with a typedef, I can't do:</div>
<div> </div>
<div>  typedef __attribute__((vector_size(16))) vector;<br></div>
<div>  vectest.cpp:19:3: error: declaration does not declare anything<br>    typedef __attribute__((vector_size(16))) vector;<br></div>
<div>Also, I can do:</div>
<div> </div>
<div>  MyVectorTypeUC vec_add(MyVectorTypeUC, MyVectorTypeUC);</div>
<div> </div>
<div>and</div>
<div> </div>
<div>  void f1(__attribute__((vector_size(16))) unsigned char, __attribute__((vector_size(16))) unsigned char);</div>
<div> </div>
<div>But I can't use the raw notation in a return type:</div>
<div> </div>
<div>  __attribute__((vector_size(16))) unsigned char f();<br></div>
<div>   vectest.cpp:9:16: error: unsupported type 'unsigned char ()' for vector_size attribute,  please use on typedef<br>  __attribute__((vector_size(16))) unsigned char f();</div>
<div> </div>
<div>I guess the attribute is trying to associate with the function declaration.</div>
<div> </div>
<div>I looked at:</div>
<div> </div>
<div>  #define vector __attribute__((vector_size(16)))</div>
<div> </div>
<div>But then that would conflict with the library's vector class, as well as have problems with function return types.</div>
<div> </div>
<div>BTW, how would a built-in "vector" type not conflict with the vector class?  Is it the types following it that allow the compiler to differentiate?  (I.e. in seeing "vector int", the "int" part tells that compiler the vector keyword is used?)</div>

<div> </div>
<div>So, down to the question I want to ask, would it be reasonable for me to implement a built-in vector type in Clang, perhaps enabled by the -faltivec option?  Or is there a correct way to otherwise do it with existing features?</div>

<div> </div>
<div>It looks like something needed in the PS3/PowerPC world.</div>
<div> </div>
<div>-John</div>
<div> </div>
<div class="gmail_quote">On Thu, Nov 19, 2009 at 9:09 AM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div class="im"><br>On Nov 18, 2009, at 3:41 PM, John Thompson wrote:<br><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Hi,<br><br>I thought I'd to some preliminary work to see what issues I'd run into trying to compile some sources intented for the PS3 PPU target.  The PS3 devkit includes a gcc-based compiler, so I'm thinking that would make it a bit easier.<br>
<br>Although there is a -faltivec option, it appears that there is no support yet for the "vector" type (or is it really "__vector", or perhaps a built-in alias?).<br></blockquote><br></div>There's a little bit of information about a "__vector" in the "PowerPC Type Attributes" section of the GCC manual, here:<br>
<br>       <a href="http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Type-Attributes.html#Type-Attributes" target="_blank">http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Type-Attributes.html#Type-Attributes</a> 
<div class="im"><br><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">I don't know much about this, so I was wondering if someone out there could say something about it with respect to plans for it in clang.<br>
</blockquote><br></div>Clang currently supports two kinds of vector types, the GNU vector attribute (e.g., "int __attribute__((vector_size(number-of-bytes)))") and Clang's own OpenCL-inspired extended vector attribute (e.g., "int __attribute__((ext_vector_type(number-of-elements)))"). The Altivec vector/__vector probably matches one of those. 
<div class="im"><br><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">I suppose that in addition to the vector type, this would also involve all the "__builtin_vec-*" functions, but not having the vector type used in the altivec.h include file was the first thing I ran into.<br>
I've enclosed some initial work for the targets, in ps3targets.patch.  This depends on changes to the Triple class in ps3triple.patch, which I've submitted seperately to the llvmdev list.  The gcc-based compiler in the PS3 devkit uses the the "ppu-uknown-lv2" and "spu-unknown-lv2" triples, so these changes do the same.  I don't know why there isn't a "ps3" in there somewhere, but it probably should be the same in both compilers.<br>
</blockquote><br></div>+    // FIXME:  Does this belong in PPCTargetInfo?<br>+    if (Opts.AltiVec) {<br>+      Define(Defs, "__VEC__", "1");<br>+      Define(Defs, "__ALTIVEC__", "1");<br>
+    }<br><br>GCC defines both of these when compiling for PPC, so they should go into PPCTargetInfo. I'm seeing the following definitions:<br><br>#define __VEC__ 10206<br>#define __ALTIVEC__ 1<br><br>Otherwise, the triple and target changes look good!<br>
<br> - Doug<br></blockquote></div><br><br clear="all"><br>-- <br>John Thompson<br><a href="mailto:John.Thompson.JTSoftware@gmail.com">John.Thompson.JTSoftware@gmail.com</a><br><br>