MLIR  19.0.0git
Traits.h
Go to the documentation of this file.
1 //===- Traits.h - Trait Declaration for MLIR DLTI dialect -------*- 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 #ifndef MLIR_DIALECT_DLTI_TRAITS_H
10 #define MLIR_DIALECT_DLTI_TRAITS_H
11 
12 #include "mlir/IR/OpDefinition.h"
14 
15 namespace mlir {
16 class DataLayoutSpecAttr;
17 
18 namespace impl {
19 LogicalResult verifyHasDefaultDLTIDataLayoutTrait(Operation *op);
20 DataLayoutSpecInterface getDataLayoutSpec(Operation *op);
21 } // namespace impl
22 
23 /// Trait to be used by operations willing to use the implementation of the
24 /// data layout interfaces provided by the Target dialect.
25 template <typename ConcreteOp>
27  : public OpTrait::TraitBase<ConcreteOp, HasDefaultDLTIDataLayout> {
28 public:
29  /// Verifies that the operation to which this trait is attached is valid for
30  /// the trait, i.e., that it implements the data layout operation interface.
33  }
34 
35  /// Returns the data layout specification as provided by the Target dialect
36  /// specification attribute.
37  DataLayoutSpecInterface getDataLayoutSpec() {
38  return impl::getDataLayoutSpec(this->getOperation());
39  }
40 };
41 } // namespace mlir
42 
43 #endif // MLIR_DIALECT_DLTI_TRAITS_H
Trait to be used by operations willing to use the implementation of the data layout interfaces provid...
Definition: Traits.h:27
static LogicalResult verifyTrait(Operation *op)
Verifies that the operation to which this trait is attached is valid for the trait,...
Definition: Traits.h:31
DataLayoutSpecInterface getDataLayoutSpec()
Returns the data layout specification as provided by the Target dialect specification attribute.
Definition: Traits.h:37
Helper class for implementing traits.
Definition: OpDefinition.h:373
Operation * getOperation()
Return the ultimate Operation being worked on.
Definition: OpDefinition.h:376
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
DataLayoutSpecInterface getDataLayoutSpec(Operation *op)
Definition: Traits.cpp:26
LogicalResult verifyHasDefaultDLTIDataLayoutTrait(Operation *op)
Definition: Traits.cpp:15
Include the generated interface declarations.
This class represents an efficient way to signal success or failure.
Definition: LogicalResult.h:26