[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 30 00:13:53 PDT 2021
rjmccall added inline comments.
================
Comment at: clang/lib/Sema/SemaCast.cpp:2236
+ }
+ }
+
----------------
The expected semantics for this conversion are not the ordinary bitwise-reinterpretation semantics of `reinterpret_cast`, so this really should not be allowed as a `reinterpret_cast`. Allowing it as a `static_cast` seems appropriate.
================
Comment at: clang/lib/Sema/SemaExpr.cpp:7315
+/// is not a scalar type.
+bool Sema::areCompatibleMatrixTypes(QualType srcTy, QualType destTy) {
+ assert(destTy->isMatrixType() && srcTy->isMatrixType());
----------------
"Compatible" has a specific meaning in the C standard, so if you aren't intending to invoke that concept of compatibility, you should find a new word.
It looks like this kind of cast is supposed to be doing an elementwise conversion. I guess all the types you can have matrices of are interconvertible, so there are no restrictions on the element types. But you definitely need this to produce a new `CastKind` for elementwise conversion instead of using `CK_BitCast`, which does a bitwise reinterpretation, which is not what you want.
Matrix element types already have to be scalar types, so those checks aren't doing anything.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99037/new/
https://reviews.llvm.org/D99037
More information about the cfe-commits
mailing list