[cfe-commits] r74202 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/Expr.cpp lib/Sema/SemaExpr.cpp test/Sema/ext_vector_components.c
Nate Begeman
natebegeman at mac.com
Thu Jun 25 14:06:09 PDT 2009
Author: sampo
Date: Thu Jun 25 16:06:09 2009
New Revision: 74202
URL: http://llvm.org/viewvc/llvm-project?rev=74202&view=rev
Log:
OpenCL 1.0 Support, patch 1/N: upper case swizzle operator and hex element index.
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/ext_vector_components.c
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=74202&r1=74201&r2=74202&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Jun 25 16:06:09 2009
@@ -1103,11 +1103,17 @@
case '7': return 7;
case '8': return 8;
case '9': return 9;
+ case 'A':
case 'a': return 10;
+ case 'B':
case 'b': return 11;
+ case 'C':
case 'c': return 12;
+ case 'D':
case 'd': return 13;
+ case 'E':
case 'e': return 14;
+ case 'F':
case 'f': return 15;
}
}
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=74202&r1=74201&r2=74202&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Jun 25 16:06:09 2009
@@ -1496,7 +1496,7 @@
return false;
// Advance past s-char prefix on hex swizzles.
- if (*compStr == 's') {
+ if (*compStr == 's' || *compStr == 'S') {
compStr++;
length--;
}
@@ -1514,7 +1514,7 @@
void ExtVectorElementExpr::getEncodedElementAccess(
llvm::SmallVectorImpl<unsigned> &Elts) const {
const char *compStr = Accessor->getName();
- if (*compStr == 's')
+ if (*compStr == 's' || *compStr == 'S')
compStr++;
bool isHi = !strcmp(compStr, "hi");
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=74202&r1=74201&r2=74202&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jun 25 16:06:09 2009
@@ -1905,7 +1905,7 @@
// This flag determines whether or not CompName has an 's' char prefix,
// indicating that it is a string of hex values to be used as vector indices.
- bool HexSwizzle = *compStr == 's';
+ bool HexSwizzle = *compStr == 's' || *compStr == 'S';
// Check that we've found one of the special components, or that the component
// names must come from the same set.
Modified: cfe/trunk/test/Sema/ext_vector_components.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ext_vector_components.c?rev=74202&r1=74201&r2=74202&view=diff
==============================================================================
--- cfe/trunk/test/Sema/ext_vector_components.c (original)
+++ cfe/trunk/test/Sema/ext_vector_components.c Thu Jun 25 16:06:09 2009
@@ -3,11 +3,13 @@
typedef __attribute__(( ext_vector_type(2) )) float float2;
typedef __attribute__(( ext_vector_type(3) )) float float3;
typedef __attribute__(( ext_vector_type(4) )) float float4;
+typedef __attribute__(( ext_vector_type(16) )) float float16;
static void test() {
float2 vec2, vec2_2;
float3 vec3;
float4 vec4, vec4_2, *vec4p;
+ float16 vec16;
float f;
vec2.z; // expected-error {{vector component access exceeds type 'float2'}}
@@ -16,6 +18,7 @@
vec4.xyzc; // expected-error {{illegal vector component name 'c'}}
vec4.s01z; // expected-error {{illegal vector component name 'z'}}
vec2 = vec4.s01; // legal, shorten
+ vec2 = vec4.S01; // legal, shorten
vec3 = vec4.xyz; // legal, shorten
f = vec2.x; // legal, shorten
@@ -32,6 +35,8 @@
vec4 = (float4){ 1,2,3,4 };
vec4.xy.w; // expected-error {{vector component access exceeds type 'float2'}}
vec4.s06; // expected-error {{vector component access exceeds type 'float4'}}
+ vec4.x = vec16.sf;
+ vec4.x = vec16.sF;
vec4p->yz = vec4p->xy;
}
More information about the cfe-commits
mailing list