[cfe-dev] Casting scalars to vectors

John Thompson john.thompson.jtsoftware at gmail.com
Mon Apr 19 18:02:09 PDT 2010


>I'm pretty sure that's already implemented... are you passing
>-faltivec to clang?
Yes.

This stops the error, but is it enough?:

Index: lib/Sema/SemaInit.cpp
===================================================================
--- lib/Sema/SemaInit.cpp (revision 101528)
+++ lib/Sema/SemaInit.cpp (working copy)
@@ -886,7 +886,7 @@

     // OpenCL & AltiVec require all elements to be initialized.
     if (numEltsInit != maxElements)
-      if (SemaRef.getLangOptions().OpenCL ||
SemaRef.getLangOptions().AltiVec)
+      if (SemaRef.getLangOptions().OpenCL)
         SemaRef.Diag(IList->getSourceRange().getBegin(),
                      diag::err_vector_incorrect_num_initializers)
           << (numEltsInit < maxElements) << maxElements << numEltsInit;

On Mon, Apr 19, 2010 at 4:07 PM, Eli Friedman <eli.friedman at gmail.com>wrote:

> On Mon, Apr 19, 2010 at 3:00 PM, John Thompson
> <john.thompson.jtsoftware at gmail.com> wrote:
> > My colleague pointed out that it's not a cast, but a literal, which Clang
> > should support.
>
> I'm pretty sure that's already implemented... are you passing
> -faltivec to clang?
>
> -Eli
>
> > -John
> >
> > On Mon, Apr 19, 2010 at 11:45 AM, John Thompson
> > <john.thompson.jtsoftware at gmail.com> wrote:
> >>
> >> According to the AltiVec standard (section 2.4.6 in
> >> http://www.freescale.com/files/32bit/doc/ref_manual/ALTIVECPIM.pdf),
> casting
> >> a scalar to a vector is illegal, yet gcc seems to support it, as seen in
> >> many of those little files in the PS3 SDK in target\ppu\include\bits,
> which
> >> have statements like:
> >>
> >> vec_uint4 mask = (vec_uint4)(vec_int4)(-1);
> >>
> >> where vec_uint4 and vec_int4 are typedefs for vector types, i.e.:
> >>
> >> typedef vector int vec_int4;
> >>
> >> What does this actually do? I'm guessing it's supposed to fill the
> vector
> >> components with -1.
> >>
> >> How should this be handled in Clang?
> >>
> >> I filed a Bugzilla bug 6846 on this.
> >>
> >> If Clang should support it
> >> , I might be able to take a crack at it, with a little guidance.
> >>
> >> --
> >> John Thompson
> >> John.Thompson.JTSoftware at gmail.com
> >>
> >
> >
> >
> > --
> > John Thompson
> > John.Thompson.JTSoftware at gmail.com
> >
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> >
> >
>



-- 
John Thompson
John.Thompson.JTSoftware at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100419/8eafd446/attachment.html>


More information about the cfe-dev mailing list