//===- TestTypes.h - MLIR Test Dialect Types --------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file contains types defined by the TestDialect for testing various // features of MLIR. // //===----------------------------------------------------------------------===// #ifndef MLIR_TESTTYPES_H #define MLIR_TESTTYPES_H #include <optional> #include <tuple> #include "TestTraits.h" #include "mlir/IR/Diagnostics.h" #include "mlir/IR/Dialect.h" #include "mlir/IR/DialectImplementation.h" #include "mlir/IR/Operation.h" #include "mlir/IR/Types.h" #include "mlir/Interfaces/DataLayoutInterfaces.h" namespace test { class TestAttrWithFormatAttr; /// FieldInfo represents a field in the StructType data type. It is used as a /// parameter in TestTypeDefs.td. struct FieldInfo { … }; /// A custom type for a test type parameter. struct CustomParam { … }; inline llvm::hash_code hash_value(const test::CustomParam ¶m) { … } } // namespace test namespace mlir { template <> struct FieldParser<test::CustomParam> { … }; inline mlir::AsmPrinter &operator<<(mlir::AsmPrinter &printer, test::CustomParam param) { … } /// Overload the attribute parameter parser for optional integers. template <> struct FieldParser<std::optional<int>> { … }; } // namespace mlir #include "TestTypeInterfaces.h.inc" namespace test { /// Storage for simple named recursive types, where the type is identified by /// its name and can "contain" another type, including itself. struct TestRecursiveTypeStorage : public ::mlir::TypeStorage { … }; /// Simple recursive type identified by its name and pointing to another named /// type, potentially itself. This requires the body to be mutated separately /// from type creation. class TestRecursiveType : public ::mlir::Type::TypeBase<TestRecursiveType, ::mlir::Type, TestRecursiveTypeStorage, ::mlir::TypeTrait::IsMutable> { … }; } // namespace test #define GET_TYPEDEF_CLASSES #include "TestTypeDefs.h.inc" #endif // MLIR_TESTTYPES_H