Page MenuHomePhabricator

[Matrix] Add matrix type to Clang (WIP).
Needs ReviewPublic

Authored by fhahn on Jan 6 2020, 9:05 AM.



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

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.


Diff Detail

Unit TestsFailed

140 msClang.CodeGen::pch-dllexport.cpp
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/build/bin/clang -cc1 -internal-isystem /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/build/lib/clang/10.0.0/include -nostdsysteminc -triple i686-pc-win32 -fms-extensions -emit-pch -o /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/build/tools/clang/test/CodeGen/Output/pch-dllexport.cpp.tmp /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/clang/test/CodeGen/pch-dllexport.cpp

Event Timeline

fhahn created this revision.Jan 6 2020, 9:05 AM
Herald added a project: Restricted Project. · View Herald Transcript
scanon added a subscriber: scanon.Jan 6 2020, 9:28 AM

Unit tests: fail. 61254 tests passed, 1 failed and 736 were skipped.

failed: Clang.CodeGen/pch-dllexport.cpp

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

@jwakely it would be great if you could have a brief look at our recent proposal for matrix support in Clang and could let us know if you have any concerns? The original proposal is being discussed on cfe-dev ( and the discussion continued in January

We are currently updating the proposal to use operators instead of builtins, but it would be good to know if you have any high-level concerns.