OpenCL 1.0 Support, patch 1/N: upper case swizzle operator and hex element index.

llvm-svn: 74202
This commit is contained in:
Nate Begeman 2009-06-25 21:06:09 +00:00
parent 188e87fa21
commit 0359e12208
4 changed files with 14 additions and 3 deletions

View File

@ -1103,11 +1103,17 @@ public:
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;
}
}

View File

@ -1496,7 +1496,7 @@ bool ExtVectorElementExpr::containsDuplicateElements() const {
return false;
// Advance past s-char prefix on hex swizzles.
if (*compStr == 's') {
if (*compStr == 's' || *compStr == 'S') {
compStr++;
length--;
}
@ -1514,7 +1514,7 @@ bool ExtVectorElementExpr::containsDuplicateElements() const {
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");

View File

@ -1905,7 +1905,7 @@ CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc,
// 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.

View File

@ -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 @@ static void test() {
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 @@ static void test() {
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;
}