summaryrefslogtreecommitdiff
path: root/mlir/lib/Dialect/DLTI/Traits.cpp
blob: 3f6dd2900a91588ae2a7f3eb2b667228ef5bfc93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//===- Traits.cpp - Traits for MLIR DLTI dialect --------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "mlir/Dialect/DLTI/Traits.h"
#include "mlir/Dialect/DLTI/DLTI.h"
#include "mlir/Interfaces/DataLayoutInterfaces.h"

using namespace mlir;

LogicalResult mlir::impl::verifyHasDefaultDLTIDataLayoutTrait(Operation *op) {
  // TODO: consider having trait inheritance so that HasDefaultDLTIDataLayout
  // trait can inherit DataLayoutOpInterface::Trait and enforce the validity of
  // the assertion below.
  assert(
      isa<DataLayoutOpInterface>(op) &&
      "HasDefaultDLTIDataLayout trait unexpectedly attached to an op that does "
      "not implement DataLayoutOpInterface");
  return success();
}

DataLayoutSpecInterface mlir::impl::getDataLayoutSpec(Operation *op) {
  return op->getAttrOfType<DataLayoutSpecInterface>(
      DLTIDialect::kDataLayoutAttrName);
}

TargetSystemSpecInterface mlir::impl::getTargetSystemSpec(Operation *op) {
  return op->getAttrOfType<TargetSystemSpecAttr>(
      DLTIDialect::kTargetSystemDescAttrName);
}