SaurabhJha updated this revision to Diff 360886.
SaurabhJha added a comment.

Add documentation for matrix broadcast initialization


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106005/new/

https://reviews.llvm.org/D106005

Files:
  clang/docs/MatrixTypes.rst


Index: clang/docs/MatrixTypes.rst
===================================================================
--- clang/docs/MatrixTypes.rst
+++ clang/docs/MatrixTypes.rst
@@ -266,6 +266,25 @@
   }
 
 
+Initialization Syntax
+---------------------
+A value of a matrix type M can be initialized with an initializer list:
+
+.. code-block:: c++
+
+  constexpr M m1 = {};
+  constexpr M m2 = {x};
+  constexpr M m2 = {{a, b, c}, {d, e, f}};
+
+If the initializer list is empty, all elements of the matrix are 
zero-initialized.
+
+If the initializer list has just one expression, all elements of the matrix 
will be initialized using that expression.
+
+Otherwise, the initializer list must consist of M::rows initializer lists, 
each of which must consist of
+M::columns expressions, each of which is used to initialize the corresponding 
element of the matrix. For example,
+m[i][j] is initialized by the jth expression of the ith initializer list in 
the initializer. Element designators are
+not allowed.
+
 TODOs
 -----
 
@@ -274,9 +293,6 @@
 convenient. The alternative is using template deduction to extract this
 information. Also add spelling for C.
 
-Future Work: Initialization syntax.
-
-
 Decisions for the Implementation in Clang
 =========================================
 


Index: clang/docs/MatrixTypes.rst
===================================================================
--- clang/docs/MatrixTypes.rst
+++ clang/docs/MatrixTypes.rst
@@ -266,6 +266,25 @@
   }
 
 
+Initialization Syntax
+---------------------
+A value of a matrix type M can be initialized with an initializer list:
+
+.. code-block:: c++
+
+  constexpr M m1 = {};
+  constexpr M m2 = {x};
+  constexpr M m2 = {{a, b, c}, {d, e, f}};
+
+If the initializer list is empty, all elements of the matrix are zero-initialized.
+
+If the initializer list has just one expression, all elements of the matrix will be initialized using that expression.
+
+Otherwise, the initializer list must consist of M::rows initializer lists, each of which must consist of
+M::columns expressions, each of which is used to initialize the corresponding element of the matrix. For example,
+m[i][j] is initialized by the jth expression of the ith initializer list in the initializer. Element designators are
+not allowed.
+
 TODOs
 -----
 
@@ -274,9 +293,6 @@
 convenient. The alternative is using template deduction to extract this
 information. Also add spelling for C.
 
-Future Work: Initialization syntax.
-
-
 Decisions for the Implementation in Clang
 =========================================
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to