[cfe-commits] r40769 - in /cfe/trunk/CodeGen: CGExpr.cpp CodeGenFunction.h

Chris Lattner sabre at nondot.org
Thu Aug 2 16:37:32 PDT 2007


Author: lattner
Date: Thu Aug  2 18:37:31 2007
New Revision: 40769

URL: http://llvm.org/viewvc/llvm-project?rev=40769&view=rev
Log:
add support for codegen of an OCUVectorComponent as an lvalue.

We can now codegen:

  vec4.xy;

as nothing!


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=40769&r1=40768&r2=40769&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/CodeGen/CGExpr.cpp Thu Aug  2 18:37:31 2007
@@ -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
 //===--------------------------------------------------------------------===//

Modified: cfe/trunk/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenFunction.h?rev=40769&r1=40768&r2=40769&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/CodeGen/CodeGenFunction.h Thu Aug  2 18:37:31 2007
@@ -54,6 +54,7 @@
   class BinaryOperator;
   class CompoundAssignOperator;
   class ArraySubscriptExpr;
+  class OCUVectorComponent;
   class ConditionalOperator;
   class PreDefinedExpr;
   
@@ -116,26 +117,35 @@
   // alignment?
   
   enum {
-    Simple,    // This is a normal l-value, use getAddress().
-    VectorElt, // This is a vector element l-value (V[i]), use getVector*
-    BitField   // This is a bitfield l-value, use getBitfield*.
+    Simple,       // This is a normal l-value, use getAddress().
+    VectorElt,    // This is a vector element l-value (V[i]), use getVector*
+    BitField,     // This is a bitfield l-value, use getBitfield*.
+    OCUVectorComp // This is an ocu vector subset, use getOCUVectorComp
   } LVType;
   
   llvm::Value *V;
   
   union {
-    llvm::Value *VectorIdx;
+    llvm::Value *VectorIdx;   // Index into a vector subscript: V[i]
+    unsigned VectorComp;      // Encoded OCUVector element subset: V.xyx
   };
 public:
   bool isSimple() const { return LVType == Simple; }
   bool isVectorElt() const { return LVType == VectorElt; }
   bool isBitfield() const { return LVType == BitField; }
+  bool isOCUVectorComp() const { return LVType == OCUVectorComp; }
   
   // simple lvalue
   llvm::Value *getAddress() const { assert(isSimple()); return V; }
   // vector elt lvalue
   llvm::Value *getVectorAddr() const { assert(isVectorElt()); return V; }
   llvm::Value *getVectorIdx() const { assert(isVectorElt()); return VectorIdx; }
+  // ocu vector components.
+  unsigned getOCUVectorComp() const {
+    assert(isOCUVectorComp());
+    return VectorComp;
+  }
+  
   
   static LValue MakeAddr(llvm::Value *V) {
     LValue R;
@@ -152,6 +162,13 @@
     return R;
   }
   
+  static LValue MakeOCUVectorComp(llvm::Value *Vec, unsigned Components) {
+    LValue R;
+    R.LVType = VectorElt;
+    R.V = Vec;
+    R.VectorComp = Components;
+    return R;
+  }
 };
 
 /// CodeGenFunction - This class organizes the per-function state that is used
@@ -309,6 +326,7 @@
   LValue EmitPreDefinedLValue(const PreDefinedExpr *E);
   LValue EmitUnaryOpLValue(const UnaryOperator *E);
   LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E);
+  LValue EmitOCUVectorComponentExpr(const OCUVectorComponent *E);
     
   //===--------------------------------------------------------------------===//
   //                             Expression Emission





More information about the cfe-commits mailing list