|
| 1 | +//===- VectorTypes.h - MLIR Vector Types ------------------------*- C++ -*-===// |
| 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 | +// Convenience wrappers for `VectorType` to allow idiomatic code like |
| 10 | +// * isa<vector::ScalableVectorType>(type) |
| 11 | +// |
| 12 | +//===----------------------------------------------------------------------===// |
| 13 | + |
| 14 | +#ifndef MLIR_IR_VECTORTYPES_H |
| 15 | +#define MLIR_IR_VECTORTYPES_H |
| 16 | + |
| 17 | +#include "mlir/IR/BuiltinTypes.h" |
| 18 | +#include "mlir/IR/Types.h" |
| 19 | + |
| 20 | +namespace mlir { |
| 21 | +namespace vector { |
| 22 | + |
| 23 | +/// A vector type containing at least one scalable dimension. |
| 24 | +class ScalableVectorType : public VectorType { |
| 25 | +public: |
| 26 | + using VectorType::VectorType; |
| 27 | + |
| 28 | + static bool classof(Type type) { |
| 29 | + auto vecTy = llvm::dyn_cast<VectorType>(type); |
| 30 | + if (!vecTy) |
| 31 | + return false; |
| 32 | + return vecTy.isScalable(); |
| 33 | + } |
| 34 | +}; |
| 35 | + |
| 36 | +/// A vector type with no scalable dimensions. |
| 37 | +class FixedVectorType : public VectorType { |
| 38 | +public: |
| 39 | + using VectorType::VectorType; |
| 40 | + static bool classof(Type type) { |
| 41 | + auto vecTy = llvm::dyn_cast<VectorType>(type); |
| 42 | + if (!vecTy) |
| 43 | + return false; |
| 44 | + return !vecTy.isScalable(); |
| 45 | + } |
| 46 | +}; |
| 47 | + |
| 48 | +} // namespace vector |
| 49 | +} // namespace mlir |
| 50 | + |
| 51 | +#endif // MLIR_IR_VECTORTYPES_H |
0 commit comments