Page MenuHomePhabricator

[Matrix] Implement matrix index expressions ([][]).
Needs ReviewPublic

Authored by fhahn on Wed, Mar 25, 11:27 AM.

Details

Summary

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.

Diff Detail

Event Timeline

fhahn created this revision.Wed, Mar 25, 11:27 AM
fhahn updated this revision to Diff 254228.Wed, Apr 1, 9:36 AM

Use placeholder type for incomplete matrix index expressions, as suggested by @rjmccall