clang 24.0.0git
MatrixUtils.h
Go to the documentation of this file.
1//===- MatrixUtils.h - Matrix AST utilities -------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// Defines AST-level helper utilities for matrix types.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_AST_MATRIXUTILS_H
15#define LLVM_CLANG_AST_MATRIXUTILS_H
16
17#include "clang/AST/Type.h"
19
20namespace clang {
21/// Returns true if matrices of \p T should be laid out in row-major order.
22///
23/// An explicit layout stored on the matrix type takes precedence over the
24/// `-fmatrix-memory-layout=` default carried in \p LangOpts.
25inline bool isMatrixRowMajor(const LangOptions &LangOpts, QualType T) {
26 if (const auto *MT = T.isNull() ? nullptr : T->getAs<ConstantMatrixType>();
27 LangOpts.HLSL && MT && MT->getLayout())
28 return MT->getLayout() == MatrixType::LayoutKind::RowMajor;
29 return LangOpts.getDefaultMatrixMemoryLayout() ==
31}
32} // namespace clang
33
34#endif // LLVM_CLANG_AST_MATRIXUTILS_H
Defines the clang::LangOptions interface.
C Language Family Type Representation.
Represents a concrete matrix type with constant number of rows and columns.
Definition TypeBase.h:4490
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A (possibly-)qualified type.
Definition TypeBase.h:938
Top level wrappers for InstallAPI frontend operations.
bool isMatrixRowMajor(const LangOptions &LangOpts, QualType T)
Returns true if matrices of T should be laid out in row-major order.
Definition MatrixUtils.h:25
const FunctionProtoType * T