enhance ExtVectorElementExpr to allow V->xxyy to work like (*V).xxyy

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64667 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-02-16 21:11:58 +00:00
Родитель 450da9832b
Коммит 73525de7fd
5 изменённых файлов: 19 добавлений и 12 удалений

Просмотреть файл

@ -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>";

Просмотреть файл

@ -2053,6 +2053,9 @@ public:
/// 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;

Просмотреть файл

@ -257,13 +257,8 @@ RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) {
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 @@ llvm::Constant *GenerateConstantVector(llvm::SmallVector<unsigned, 4> &Elts) {
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;

Просмотреть файл

@ -1815,7 +1815,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
<< &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();

Просмотреть файл

@ -7,7 +7,7 @@ typedef __attribute__(( ext_vector_type(4) )) float float4;
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 @@ 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'}}
vec4p->yz = vec4p->xy;
}