[cfe-commits] r40781 - in /cfe/trunk/CodeGen: CGExpr.cpp CodeGenFunction.h
Chris Lattner
sabre at nondot.org
Fri Aug 3 09:28:33 PDT 2007
Author: lattner
Date: Fri Aug 3 11:28:33 2007
New Revision: 40781
URL: http://llvm.org/viewvc/llvm-project?rev=40781&view=rev
Log:
add codegen support for storing into a single-element ocu lvalue, such as:
vec2.x = f;
Modified:
cfe/trunk/CodeGen/CGExpr.cpp
cfe/trunk/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExpr.cpp?rev=40781&r1=40780&r2=40781&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/CodeGen/CGExpr.cpp Fri Aug 3 11:28:33 2007
@@ -354,17 +354,23 @@
/// is 'Ty'.
void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
QualType Ty) {
- if (Dst.isVectorElt()) {
- // Read/modify/write the vector, inserting the new element.
- // FIXME: Volatility.
- llvm::Value *Vec = Builder.CreateLoad(Dst.getVectorAddr(), "tmp");
- Vec = Builder.CreateInsertElement(Vec, Src.getVal(),
- Dst.getVectorIdx(), "vecins");
- Builder.CreateStore(Vec, Dst.getVectorAddr());
- return;
- }
+ if (!Dst.isSimple()) {
+ if (Dst.isVectorElt()) {
+ // Read/modify/write the vector, inserting the new element.
+ // FIXME: Volatility.
+ llvm::Value *Vec = Builder.CreateLoad(Dst.getVectorAddr(), "tmp");
+ Vec = Builder.CreateInsertElement(Vec, Src.getVal(),
+ Dst.getVectorIdx(), "vecins");
+ Builder.CreateStore(Vec, Dst.getVectorAddr());
+ return;
+ }
- assert(Dst.isSimple() && "FIXME: Don't support store to bitfield yet");
+ // If this is an update of elements of a vector, insert them as appropriate.
+ if (Dst.isOCUVectorComp())
+ return EmitStoreThroughOCUComponentLValue(Src, Dst, Ty);
+
+ assert(0 && "FIXME: Don't support store to bitfield yet");
+ }
llvm::Value *DstAddr = Dst.getAddress();
if (Src.isScalar()) {
@@ -411,6 +417,29 @@
Builder.CreateCall(CGM.getMemCpyFn(), MemCpyOps, MemCpyOps+4);
}
+void CodeGenFunction::EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst,
+ QualType Ty) {
+ // This access turns into a read/modify/write of the vector. Load the input
+ // value now.
+ llvm::Value *Vec = Builder.CreateLoad(Dst.getOCUVectorAddr(), "tmp");
+ // FIXME: Volatility.
+ unsigned EncFields = Dst.getOCUVectorComp();
+
+ llvm::Value *SrcVal = Src.getVal();
+
+ // If the Src is a scalar (not a vector) it must be updating a single element.
+ if (!Ty->isVectorType()) {
+ unsigned InIdx = OCUVectorComponent::getAccessedFieldNo(0, EncFields);
+ llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx);
+ Vec = Builder.CreateInsertElement(Vec, SrcVal, Elt, "tmp");
+ } else {
+
+ }
+
+
+ Builder.CreateStore(Vec, Dst.getOCUVectorAddr());
+}
+
LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
const Decl *D = E->getDecl();
Modified: cfe/trunk/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenFunction.h?rev=40781&r1=40780&r2=40781&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/CodeGen/CodeGenFunction.h Fri Aug 3 11:28:33 2007
@@ -323,6 +323,7 @@
/// lvalue, where both are guaranteed to the have the same type, and that type
/// is 'Ty'.
void EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty);
+ void EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst, QualType Ty);
LValue EmitDeclRefLValue(const DeclRefExpr *E);
LValue EmitStringLiteralLValue(const StringLiteral *E);
More information about the cfe-commits
mailing list