diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-16 21:11:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-16 21:11:58 +0000 |
commit | 6c7ce109e0460bf06b23eef8592cf284375b47f7 (patch) | |
tree | 98b5292c1319ebe32de9d13f35c0b2a54269dead /clang/lib/CodeGen/CGExpr.cpp | |
parent | bfdd607372e900c3a05bcb3ce7a172179def8048 (diff) | |
download | bcm5719-llvm-6c7ce109e0460bf06b23eef8592cf284375b47f7.tar.gz bcm5719-llvm-6c7ce109e0460bf06b23eef8592cf284375b47f7.zip |
enhance ExtVectorElementExpr to allow V->xxyy to work like (*V).xxyy
llvm-svn: 64667
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 3e44c0079b3..03efbc9ad56 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -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; |