[cfe-commits] r64667 - in /cfe/trunk: clang.xcodeproj/project.pbxproj include/clang/AST/Expr.h lib/CodeGen/CGExpr.cpp lib/Sema/SemaExpr.cpp test/Sema/ext_vector_components.c
Chris Lattner
sabre at nondot.org
Mon Feb 16 13:11:58 PST 2009
Author: lattner
Date: Mon Feb 16 15:11:58 2009
New Revision: 64667
URL: http://llvm.org/viewvc/llvm-project?rev=64667&view=rev
Log:
enhance ExtVectorElementExpr to allow V->xxyy to work like (*V).xxyy
Modified:
cfe/trunk/clang.xcodeproj/project.pbxproj
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/ext_vector_components.c
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=64667&r1=64666&r2=64667&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Mon Feb 16 15:11:58 2009
@@ -387,7 +387,6 @@
35A057E00EAE2D950069249F /* RegionStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegionStore.cpp; path = lib/Analysis/RegionStore.cpp; sourceTree = "<group>"; };
35A057E10EAE2D950069249F /* SVals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SVals.cpp; path = lib/Analysis/SVals.cpp; sourceTree = "<group>"; };
35A057E60EAE2DDD0069249F /* CacheTokens.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CacheTokens.cpp; path = Driver/CacheTokens.cpp; sourceTree = "<group>"; };
- 35A2B8610CF8FFA300E6C317 /* SemaUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = SemaUtil.h; path = lib/Sema/SemaUtil.h; sourceTree = "<group>"; tabWidth = 2; };
35A3E7000DD3874400757F74 /* CGDebugInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = CGDebugInfo.cpp; path = lib/CodeGen/CGDebugInfo.cpp; sourceTree = "<group>"; tabWidth = 2; wrapsLines = 1; };
35A3E7010DD3874400757F74 /* CGDebugInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = CGDebugInfo.h; path = lib/CodeGen/CGDebugInfo.h; sourceTree = "<group>"; tabWidth = 2; };
35A8FCF60D9B4ADD001C2F97 /* ProgramPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProgramPoint.h; path = clang/Analysis/ProgramPoint.h; sourceTree = "<group>"; };
@@ -911,7 +910,6 @@
DE67E70C0C020ECA00F66BC5 /* SemaStmt.cpp */,
3591853E0EFB1088000039AF /* SemaTemplate.cpp */,
DE67E70A0C020EC500F66BC5 /* SemaType.cpp */,
- 35A2B8610CF8FFA300E6C317 /* SemaUtil.h */,
);
name = Sema;
sourceTree = "<group>";
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=64667&r1=64666&r2=64667&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon Feb 16 15:11:58 2009
@@ -2053,6 +2053,9 @@
/// vector, and may occur on the left hand side or right hand side. For example
/// the following is legal: "V.xy = V.zw" if V is a 4 element extended vector.
///
+/// Note that the base may have either vector or pointer to vector type, just
+/// like a struct field reference.
+///
class ExtVectorElementExpr : public Expr {
Stmt *Base;
IdentifierInfo &Accessor;
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=64667&r1=64666&r2=64667&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Feb 16 15:11:58 2009
@@ -257,13 +257,8 @@
if (LV.isPropertyRef())
return EmitLoadOfPropertyRefLValue(LV, ExprType);
- if (LV.isKVCRef())
- return EmitLoadOfKVCRefLValue(LV, ExprType);
-
- assert(0 && "Unknown LValue type!");
- //an invalid RValue, but the assert will
- //ensure that this point is never reached
- return RValue();
+ assert(LV.isKVCRef() && "Unknown LValue type!");
+ return EmitLoadOfKVCRefLValue(LV, ExprType);
}
RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV,
@@ -799,7 +794,16 @@
LValue CodeGenFunction::
EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
// Emit the base vector as an l-value.
- LValue Base = EmitLValue(E->getBase());
+ LValue Base;
+
+ // ExtVectorElementExpr's base can either be a vector or pointer to vector.
+ if (const PointerType *PT = E->getBase()->getType()->getAsPointerType()) {
+ llvm::Value *Ptr = EmitScalarExpr(E->getBase());
+ Base = LValue::MakeAddr(Ptr, PT->getPointeeType().getCVRQualifiers());
+ } else {
+ assert(E->getBase()->getType()->isVectorType());
+ Base = EmitLValue(E->getBase());
+ }
// Encode the element access list into a vector of unsigned indices.
llvm::SmallVector<unsigned, 4> Indices;
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=64667&r1=64666&r2=64667&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb 16 15:11:58 2009
@@ -1815,7 +1815,7 @@
<< &Member << BaseType);
}
// Handle 'field access' to vectors, such as 'V.xx'.
- if (BaseType->isExtVectorType() && OpKind == tok::period) {
+ if (BaseType->isExtVectorType()) {
QualType ret = CheckExtVectorComponent(BaseType, OpLoc, Member, MemberLoc);
if (ret.isNull())
return ExprError();
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=64667&r1=64666&r2=64667&view=diff
==============================================================================
--- cfe/trunk/test/Sema/ext_vector_components.c (original)
+++ cfe/trunk/test/Sema/ext_vector_components.c Mon Feb 16 15:11:58 2009
@@ -7,7 +7,7 @@
static void test() {
float2 vec2, vec2_2;
float3 vec3;
- float4 vec4, vec4_2;
+ float4 vec4, vec4_2, *vec4p;
float f;
vec2.z; // expected-error {{vector component access exceeds type 'float2'}}
@@ -32,4 +32,6 @@
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'}}
+
+ vec4p->yz = vec4p->xy;
}
More information about the cfe-commits
mailing list