[PATCH] D72281: [Matrix] Add matrix type to Clang (WIP).

Florian Hahn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 6 09:07:47 PST 2020


fhahn created this revision.
Herald added a reviewer: martong.
Herald added subscribers: tschuett, arphaman.
Herald added a project: clang.

This patch adds a matrix type to Clang as described in
"Matrix Support in Clang" on cfe-dev [1]. The patch is not intended for
review yet, just to provide an idea how the implementation would look
like.

One aspect in particular I would appreciate feedback on is how to best
ensure matrix type values are aligned the same as pointers to the
element type, while using LLVM's vector type to lower operations.

The main problem is struct layouting, where LLVM's vector type has a
larger alignment than desired.

To work around that fact, the patch uses array types as storage types for
matrix values, but vector types in other contexts. After loading/before
storing, we bitcast between array type and vector type. Alternatively
we could opt for generating packed LLVM structs.

The builtins will be added in separate, follow-on patches.

[1] http://lists.llvm.org/pipermail/cfe-dev/2019-December/064141.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72281

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TypeNodes.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGen/matrix-type.c
  clang/test/CodeGenCXX/matrix-type.cpp
  clang/test/SemaCXX/matrix-type.cpp
  clang/tools/libclang/CIndex.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72281.236391.patch
Type: text/x-patch
Size: 76817 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200106/b86b7d70/attachment-0001.bin>


More information about the cfe-commits mailing list