add support for codegen of an OCUVectorComponent as an lvalue.
We can now codegen:
vec4.xy;
as nothing!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40769 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp
index a8a7b36..1a841f9 100644
--- a/CodeGen/CGExpr.cpp
+++ b/CodeGen/CGExpr.cpp
@@ -253,6 +253,8 @@
return EmitUnaryOpLValue(cast<UnaryOperator>(E));
case Expr::ArraySubscriptExprClass:
return EmitArraySubscriptExpr(cast<ArraySubscriptExpr>(E));
+ case Expr::OCUVectorComponentClass:
+ return EmitOCUVectorComponentExpr(cast<OCUVectorComponent>(E));
}
}
@@ -471,6 +473,16 @@
return LValue::MakeAddr(Builder.CreateGEP(Base, Idx, "arrayidx"));
}
+LValue CodeGenFunction::
+EmitOCUVectorComponentExpr(const OCUVectorComponent *E) {
+ // Emit the base vector as an l-value.
+ LValue Base = EmitLValue(E->getBase());
+ assert(Base.isSimple() && "Can only subscript lvalue vectors here!");
+
+ return LValue::MakeOCUVectorComp(Base.getAddress(),
+ E->getEncodedElementAccess());
+}
+
//===--------------------------------------------------------------------===//
// Expression Emission
//===--------------------------------------------------------------------===//