@@ -2790,6 +2790,73 @@ class ArraySubscriptExpr : public Expr {
27902790 }
27912791};
27922792
2793+ // / MatrixSingleSubscriptExpr - Matrix single subscript expression for the
2794+ // / MatrixType extension when you want to get\set a vector from a Matrix.
2795+ class MatrixSingleSubscriptExpr : public Expr {
2796+ enum { BASE, ROW_IDX, END_EXPR };
2797+ Stmt *SubExprs[END_EXPR];
2798+
2799+ public:
2800+ // / matrix[row]
2801+ // /
2802+ // / \param Base The matrix expression.
2803+ // / \param RowIdx The row index expression.
2804+ // / \param T The type of the row (usually a vector type).
2805+ // / \param RBracketLoc Location of the closing ']'.
2806+ MatrixSingleSubscriptExpr (Expr *Base, Expr *RowIdx, QualType T,
2807+ SourceLocation RBracketLoc)
2808+ : Expr(MatrixSingleSubscriptExprClass, T,
2809+ Base->getValueKind (), // lvalue/rvalue follows the matrix base
2810+ OK_MatrixComponent) { // or OK_Ordinary/OK_VectorComponent if you
2811+ // prefer
2812+ SubExprs[BASE] = Base;
2813+ SubExprs[ROW_IDX] = RowIdx;
2814+ ArrayOrMatrixSubscriptExprBits.RBracketLoc = RBracketLoc;
2815+ setDependence (computeDependence (this ));
2816+ }
2817+
2818+ // / Create an empty matrix single-subscript expression.
2819+ explicit MatrixSingleSubscriptExpr (EmptyShell Shell)
2820+ : Expr(MatrixSingleSubscriptExprClass, Shell) {}
2821+
2822+ Expr *getBase () { return cast<Expr>(SubExprs[BASE]); }
2823+ const Expr *getBase () const { return cast<Expr>(SubExprs[BASE]); }
2824+ void setBase (Expr *E) { SubExprs[BASE] = E; }
2825+
2826+ Expr *getRowIdx () { return cast<Expr>(SubExprs[ROW_IDX]); }
2827+ const Expr *getRowIdx () const { return cast<Expr>(SubExprs[ROW_IDX]); }
2828+ void setRowIdx (Expr *E) { SubExprs[ROW_IDX] = E; }
2829+
2830+ SourceLocation getBeginLoc () const LLVM_READONLY {
2831+ return getBase ()->getBeginLoc ();
2832+ }
2833+
2834+ SourceLocation getEndLoc () const { return getRBracketLoc (); }
2835+
2836+ SourceLocation getExprLoc () const LLVM_READONLY {
2837+ return getBase ()->getExprLoc ();
2838+ }
2839+
2840+ SourceLocation getRBracketLoc () const {
2841+ return ArrayOrMatrixSubscriptExprBits.RBracketLoc ;
2842+ }
2843+ void setRBracketLoc (SourceLocation L) {
2844+ ArrayOrMatrixSubscriptExprBits.RBracketLoc = L;
2845+ }
2846+
2847+ static bool classof (const Stmt *T) {
2848+ return T->getStmtClass () == MatrixSingleSubscriptExprClass;
2849+ }
2850+
2851+ // Iterators
2852+ child_range children () {
2853+ return child_range (&SubExprs[0 ], &SubExprs[0 ] + END_EXPR);
2854+ }
2855+ const_child_range children () const {
2856+ return const_child_range (&SubExprs[0 ], &SubExprs[0 ] + END_EXPR);
2857+ }
2858+ };
2859+
27932860// / MatrixSubscriptExpr - Matrix subscript expression for the MatrixType
27942861// / extension.
27952862// / MatrixSubscriptExpr can be either incomplete (only Base and RowIdx are set
0 commit comments