[PATCH] D76791: [Matrix] Implement matrix index expressions ([][]).

Florian Hahn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 25 11:53:42 PDT 2020


fhahn created this revision.
fhahn added reviewers: rjmccall, anemet, Bigcheese, rsmith, martong.
Herald added subscribers: tschuett, arphaman, dexonsmith, rnkovacs.
Herald added a project: clang.

This patch implements matrix index expressions
(matrix[RowIdx][ColumnIdx]).

It does so by utilizing ArraySubscriptExpr: a matrix index expression
is represented as nested ArraySubscriptExpr as follows

  ArraySubscriptExpr(ArraySubscriptExpr(matrix, row index), column index).

A new helper getMatrixFromIndexExpr is added to Expr to check if the
base of an index expression is a matrix, by checking for the nested
expression as described above.

For CodeGen, a new MatrixElt type is added to LValue, which is very
similar to VectorElt. The only difference is that we may need to cast
the type of the base from an array to a vector type when accessing it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76791

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/Sema/matrix-type-operators.c
  clang/test/SemaCXX/matrix-type-operators.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76791.252636.patch
Type: text/x-patch
Size: 37631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200325/c481436a/attachment-0001.bin>


More information about the cfe-commits mailing list