[PATCH] D106005: [Docs] Define matrix initialisation in MatrixTypes documentation

Saurabh Jha via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 14 11:51:46 PDT 2021


SaurabhJha created this revision.
SaurabhJha requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As part of https://bugs.llvm.org/show_bug.cgi?id=46251, this patch adds definition of matrix initialisation. I am not very familiar with this part of C++
so please let me know if I am wrong here, which I suspect I am.

I have been trying to follow the reference documentation https://en.cppreference.com/w/cpp/language/initialization and the commented out test in the
bugzilla ticket https://github.com/llvm/llvm-project/blob/3323a628ec821b8b75d3b60bf1510931f97d3883/clang/test/CodeGenCXX/matrix-type-builtins.cpp#L78


Repository:
  rG LLVM Github Monorepo

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,22 @@
   }
 
 
+Initialization Syntax
+---------------------
+An empty value of a matrix type M can be initialised using this syntax:
+
+.. code-block:: c++
+
+  constexpr M m = {};
+
+A non-empty value of a matrix type M can be initialised using the nested initialisation syntax:
+
+.. code-block: c++
+  constexpr M m = {{a, b, c}, {d, e, f}}
+
+where the number of constituent arrays must equal the number rows in the matrix type M and the number of elements
+in each constituent array must equal the number of columns in the matrix type.
+
 TODOs
 -----
 
@@ -274,9 +290,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
 =========================================
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106005.358684.patch
Type: text/x-patch
Size: 1002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210714/d431c6c6/attachment.bin>


More information about the cfe-commits mailing list