[clang] Enable matrices in HLSL (PR #111415)
Greg Roth via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 7 11:11:29 PDT 2024
================
@@ -852,34 +852,50 @@ void TypePrinter::printExtVectorAfter(const ExtVectorType *T, raw_ostream &OS) {
void TypePrinter::printConstantMatrixBefore(const ConstantMatrixType *T,
raw_ostream &OS) {
+ if (Policy.UseHLSLTypes)
+ OS << "matrix<";
printBefore(T->getElementType(), OS);
- OS << " __attribute__((matrix_type(";
- OS << T->getNumRows() << ", " << T->getNumColumns();
- OS << ")))";
}
void TypePrinter::printConstantMatrixAfter(const ConstantMatrixType *T,
raw_ostream &OS) {
printAfter(T->getElementType(), OS);
+ if (Policy.UseHLSLTypes) {
+ OS << ", ";
+ OS << T->getNumRows() << ", " << T->getNumColumns();
+ OS << ">";
+ } else {
+ OS << " __attribute__((matrix_type(";
+ OS << T->getNumRows() << ", " << T->getNumColumns();
+ OS << ")))";
+ }
}
void TypePrinter::printDependentSizedMatrixBefore(
const DependentSizedMatrixType *T, raw_ostream &OS) {
+ if (Policy.UseHLSLTypes)
+ OS << "matrix<";
printBefore(T->getElementType(), OS);
- OS << " __attribute__((matrix_type(";
- if (T->getRowExpr()) {
- T->getRowExpr()->printPretty(OS, nullptr, Policy);
- }
- OS << ", ";
- if (T->getColumnExpr()) {
- T->getColumnExpr()->printPretty(OS, nullptr, Policy);
- }
- OS << ")))";
}
void TypePrinter::printDependentSizedMatrixAfter(
const DependentSizedMatrixType *T, raw_ostream &OS) {
printAfter(T->getElementType(), OS);
+ if (Policy.UseHLSLTypes)
+ OS << ", ";
+ else
+ OS << " __attribute__((matrix_type(";
+
+ if (Expr *E = T->getRowExpr())
+ E->printPretty(OS, nullptr, Policy);
+ OS << ", ";
+ if (Expr *E = T->getColumnExpr())
+ E->printPretty(OS, nullptr, Policy);
+
+ if (Policy.UseHLSLTypes)
+ OS << ">";
+ else
+ OS << ")))";
----------------
pow2clk wrote:
The changes to this file do alter how pointer and reference matrices are printed. I'd like to get @fhahn's opinion on this even if on nothing else.
https://github.com/llvm/llvm-project/pull/111415
More information about the cfe-commits
mailing list