MLIR  20.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 {
20 DataLayoutSpecInterface getDataLayoutSpec(Operation *op);
21 TargetSystemSpecInterface getTargetSystemSpec(Operation *op);
22 } // namespace impl
23 
24 /// Trait to be used by operations willing to use the implementation of the
25 /// data layout interfaces provided by the Target dialect.
26 template <typename ConcreteOp>
28  : public OpTrait::TraitBase<ConcreteOp, HasDefaultDLTIDataLayout> {
29 public:
30  /// Verifies that the operation to which this trait is attached is valid for
31  /// the trait, i.e., that it implements the data layout operation interface.
32  static LogicalResult verifyTrait(Operation *op) {
34  }
35 
36  /// Returns the data layout specification as provided by the Target dialect
37  /// specification attribute.
38  DataLayoutSpecInterface getDataLayoutSpec() {
39  return impl::getDataLayoutSpec(this->getOperation());
40  }
41 
42  /// Returns the target system description specification as provided by DLTI
43  /// dialect
44  TargetSystemSpecInterface getTargetSystemSpec() {
46  }
47 };
48 } // namespace mlir
49 
50 #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:28
TargetSystemSpecInterface getTargetSystemSpec()
Returns the target system description specification as provided by DLTI dialect.
Definition: Traits.h:44
static LogicalResult verifyTrait(Operation *op)
Verifies that the operation to which this trait is attached is valid for the trait,...
Definition: Traits.h:32
DataLayoutSpecInterface getDataLayoutSpec()
Returns the data layout specification as provided by the Target dialect specification attribute.
Definition: Traits.h:38
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
TargetSystemSpecInterface getTargetSystemSpec(Operation *op)
Definition: Traits.cpp:31
LogicalResult verifyHasDefaultDLTIDataLayoutTrait(Operation *op)
Definition: Traits.cpp:15
Include the generated interface declarations.