[cfe-commits] [REVIEW] - Altivec vector literal casting problem - need feedback - AST/Sema
rjmccall at apple.com
Fri Jun 25 17:21:12 PDT 2010
On Jun 25, 2010, at 4:48 PM, John Thompson wrote:
> I have the first pass at a fix for bug 6895, which I also reported. However, because of possible problems in altivec.h that are being looked into, it's not quite ready for prime time. However, I'm hoping for some preliminary feedback to see if I'm on the right track.
> First, some background on the problem.
> Basically, the following produced an "cannot initialize a vector element of type '(type)'" error:
> vector char v1 = (vector char)((vector int)(1, 2, 3, 4));
> This was because the outer paren expression was trying to make a vector literal out of the inner, instead of making it a cast. (See the original AltiVec standard at http://www.freescale.com/files/32bit/doc/ref_manual/ALTIVECPIM.pdf, section 2.5.2, where it actually discusses this case.)
> After straining my brain to figure out where the fix should go (I think it should be ActOnCastOfParenListExpr), this patch is what I came up with.
> Because I needed some way to determine if the initializers were arithmetic constants or not, I added a function to Expr, isArithmeticConstantExpr, which calls a static function of the same name, which I hacked up from a copy of the CheckICE function used by the isIntegerConstantExpression function. (Is this plagerism?). I'm not sure if it's exactly right, complete, or is overkill, but it seems to work for the few cases I've tried. Is it reasonable to put it in Expr, or should it just be a static function in the one file I use it in?
Is there a reason why the fix can't be "the operand is of vector type and therefore this is a vector cast and not a vector literal"? I thought building vectors from subvectors was an OpenCL-ism not supported in AltiVec.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-commits