@@ -291,6 +291,7 @@ class Expr : public ValueStmt {
291291 LV_NotObjectType,
292292 LV_IncompleteVoidType,
293293 LV_DuplicateVectorComponents,
294+ LV_DuplicateMatrixComponents,
294295 LV_InvalidExpression,
295296 LV_InvalidMessageExpression,
296297 LV_MemberFunction,
@@ -306,6 +307,7 @@ class Expr : public ValueStmt {
306307 MLV_NotObjectType,
307308 MLV_IncompleteVoidType,
308309 MLV_DuplicateVectorComponents,
310+ MLV_DuplicateMatrixComponents,
309311 MLV_InvalidExpression,
310312 MLV_LValueCast, // Specialized form of MLV_InvalidExpression.
311313 MLV_IncompleteType,
@@ -344,6 +346,7 @@ class Expr : public ValueStmt {
344346 CL_Void, // Void cannot be an lvalue in C.
345347 CL_AddressableVoid, // Void expression whose address can be taken in C.
346348 CL_DuplicateVectorComponents, // A vector shuffle with dupes.
349+ CL_DuplicateMatrixComponents, // A matrix shuffle with dupes.
347350 CL_MemberFunction, // An expression referring to a member function
348351 CL_SubObjCPropertySetting,
349352 CL_ClassTemporary, // A temporary of class type, or subobject thereof.
@@ -6488,30 +6491,24 @@ class GenericSelectionExpr final
64886491// Clang Extensions
64896492// ===----------------------------------------------------------------------===//
64906493
6491- // / ExtVectorElementExpr - This represents access to specific elements of a
6492- // / vector, and may occur on the left hand side or right hand side. For example
6493- // / the following is legal: "V.xy = V.zw" if V is a 4 element extended vector.
6494- // /
6495- // / Note that the base may have either vector or pointer to vector type, just
6496- // / like a struct field reference.
6497- // /
6498- class ExtVectorElementExpr : public Expr {
6494+ template <class Derived > class ElementAccessExprBase : public Expr {
6495+ protected:
64996496 Stmt *Base;
65006497 IdentifierInfo *Accessor;
65016498 SourceLocation AccessorLoc;
6502- public:
6503- ExtVectorElementExpr ( QualType ty , ExprValueKind VK, Expr *base ,
6504- IdentifierInfo &accessor , SourceLocation loc)
6505- : Expr(ExtVectorElementExprClass, ty, VK,
6506- (VK == VK_PRValue ? OK_Ordinary : OK_VectorComponent) ),
6507- Base (base), Accessor(&accessor), AccessorLoc(loc ) {
6508- setDependence (computeDependence (this ));
6499+
6500+ ElementAccessExprBase (StmtClass SC, QualType Ty , ExprValueKind VK, Expr *Base ,
6501+ IdentifierInfo &Accessor , SourceLocation Loc,
6502+ ExprObjectKind OK)
6503+ : Expr(SC, Ty, VK, OK), Base(Base), Accessor(&Accessor ),
6504+ AccessorLoc (Loc ) {
6505+ setDependence (computeDependence (static_cast <Derived *>( this ) ));
65096506 }
65106507
6511- // / Build an empty vector element expression.
6512- explicit ExtVectorElementExpr (EmptyShell Empty)
6513- : Expr(ExtVectorElementExprClass, Empty) { }
6508+ explicit ElementAccessExprBase (StmtClass SC, EmptyShell Empty)
6509+ : Expr(SC, Empty) {}
65146510
6511+ public:
65156512 const Expr *getBase () const { return cast<Expr>(Base); }
65166513 Expr *getBase () { return cast<Expr>(Base); }
65176514 void setBase (Expr *E) { Base = E; }
@@ -6522,34 +6519,71 @@ class ExtVectorElementExpr : public Expr {
65226519 SourceLocation getAccessorLoc () const { return AccessorLoc; }
65236520 void setAccessorLoc (SourceLocation L) { AccessorLoc = L; }
65246521
6525- // / getNumElements - Get the number of components being selected.
6526- unsigned getNumElements () const ;
6527-
6528- // / containsDuplicateElements - Return true if any element access is
6529- // / repeated.
6530- bool containsDuplicateElements () const ;
6531-
6532- // / getEncodedElementAccess - Encode the elements accessed into an llvm
6533- // / aggregate Constant of ConstantInt(s).
6534- void getEncodedElementAccess (SmallVectorImpl<uint32_t > &Elts) const ;
6535-
65366522 SourceLocation getBeginLoc () const LLVM_READONLY {
65376523 return getBase ()->getBeginLoc ();
65386524 }
65396525 SourceLocation getEndLoc () const LLVM_READONLY { return AccessorLoc; }
65406526
6527+ /* static bool classof(const Stmt *T) {
6528+ return T->getStmtClass() == ExtVectorElementExprClass ||
6529+ T->getStmtClass() == MatrixElementExprClass;
6530+ }*/
6531+
6532+ child_range children () { return child_range (&Base, &Base + 1 ); }
6533+ const_child_range children () const {
6534+ return const_child_range (&Base, &Base + 1 );
6535+ }
6536+ };
6537+
6538+ // / ExtVectorElementExpr - This represents access to specific elements of a
6539+ // / vector, and may occur on the left hand side or right hand side. For example
6540+ // / the following is legal: "V.xy = V.zw" if V is a 4 element extended vector.
6541+ // /
6542+ // / Note that the base may have either vector or pointer to vector type, just
6543+ // / like a struct field reference.
6544+ // /
6545+ class ExtVectorElementExpr
6546+ : public ElementAccessExprBase<ExtVectorElementExpr> {
6547+ public:
6548+ ExtVectorElementExpr (QualType Ty, ExprValueKind VK, Expr *Base,
6549+ IdentifierInfo &Accessor, SourceLocation Loc)
6550+ : ElementAccessExprBase(
6551+ ExtVectorElementExprClass, Ty, VK, Base, Accessor, Loc,
6552+ (VK == VK_PRValue ? OK_Ordinary : OK_VectorComponent)) {}
6553+
6554+ explicit ExtVectorElementExpr (EmptyShell Empty)
6555+ : ElementAccessExprBase(ExtVectorElementExprClass, Empty) {}
6556+
6557+ unsigned getNumElements () const ;
6558+ bool containsDuplicateElements () const ;
6559+ void getEncodedElementAccess (SmallVectorImpl<uint32_t > &Elts) const ;
6560+
65416561 // / isArrow - Return true if the base expression is a pointer to vector,
65426562 // / return false if the base expression is a vector.
65436563 bool isArrow () const ;
65446564
65456565 static bool classof (const Stmt *T) {
65466566 return T->getStmtClass () == ExtVectorElementExprClass;
65476567 }
6568+ };
65486569
6549- // Iterators
6550- child_range children () { return child_range (&Base, &Base+1 ); }
6551- const_child_range children () const {
6552- return const_child_range (&Base, &Base + 1 );
6570+ class MatrixElementExpr : public ElementAccessExprBase <MatrixElementExpr> {
6571+ public:
6572+ MatrixElementExpr (QualType Ty, ExprValueKind VK, Expr *Base,
6573+ IdentifierInfo &Accessor, SourceLocation Loc)
6574+ : ElementAccessExprBase(
6575+ MatrixElementExprClass, Ty, VK, Base, Accessor, Loc,
6576+ OK_Ordinary /* TODO: Should we add a new OK_MatrixComponent?*/ ) {}
6577+
6578+ explicit MatrixElementExpr (EmptyShell Empty)
6579+ : ElementAccessExprBase(MatrixElementExprClass, Empty) {}
6580+
6581+ unsigned getNumElements () const ;
6582+ bool containsDuplicateElements () const ;
6583+ void getEncodedElementAccess (SmallVectorImpl<uint32_t > &Elts) const ;
6584+
6585+ static bool classof (const Stmt *T) {
6586+ return T->getStmtClass () == MatrixElementExprClass;
65536587 }
65546588};
65556589
0 commit comments