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" 13 #include "mlir/Interfaces/DataLayoutInterfaces.h" 14 15 namespace mlir { 16 class DataLayoutSpecAttr; 17 18 namespace impl { 19 LogicalResult verifyHasDefaultDLTIDataLayoutTrait(Operation *op); 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> 27 class HasDefaultDLTIDataLayout 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. verifyTrait(Operation * op)32 static LogicalResult verifyTrait(Operation *op) { 33 return impl::verifyHasDefaultDLTIDataLayoutTrait(op); 34 } 35 36 /// Returns the data layout specification as provided by the Target dialect 37 /// specification attribute. getDataLayoutSpec()38 DataLayoutSpecInterface getDataLayoutSpec() { 39 return impl::getDataLayoutSpec(this->getOperation()); 40 } 41 42 /// Returns the target system description specification as provided by DLTI 43 /// dialect getTargetSystemSpec()44 TargetSystemSpecInterface getTargetSystemSpec() { 45 return impl::getTargetSystemSpec(this->getOperation()); 46 } 47 }; 48 } // namespace mlir 49 50 #endif // MLIR_DIALECT_DLTI_TRAITS_H 51