Types and attributes now have a `hasTrait` function that allow users to check if a type defines a trait. Also, AbstractType and AbstractAttribute has now a `hasTraitFn` field to carry the implementation of the `hasTrait` function of the concrete type or attribute. This patch also adds the remaining functions to access type and attribute traits in TableGen. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D105202
40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
//===- TestTraits.h - MLIR Test Traits --------------------------*- 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 traits defined by the TestDialect.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef MLIR_TESTTRAITS_H
|
|
#define MLIR_TESTTRAITS_H
|
|
|
|
#include "mlir/IR/Attributes.h"
|
|
#include "mlir/IR/Types.h"
|
|
|
|
namespace mlir {
|
|
namespace TypeTrait {
|
|
|
|
/// A trait defined on types for testing purposes.
|
|
template <typename ConcreteType>
|
|
class TestTypeTrait : public TypeTrait::TraitBase<ConcreteType, TestTypeTrait> {
|
|
};
|
|
|
|
} // namespace TypeTrait
|
|
|
|
namespace AttributeTrait {
|
|
|
|
/// A trait defined on attributes for testing purposes.
|
|
template <typename ConcreteType>
|
|
class TestAttrTrait
|
|
: public AttributeTrait::TraitBase<ConcreteType, TestAttrTrait> {};
|
|
|
|
} // namespace AttributeTrait
|
|
} // namespace mlir
|
|
|
|
#endif // MLIR_TESTTRAITS_H
|