brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 3f6dd29 Raw
35 lines · cpp
1//===- Traits.cpp - Traits for MLIR DLTI dialect --------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "mlir/Dialect/DLTI/Traits.h"10#include "mlir/Dialect/DLTI/DLTI.h"11#include "mlir/Interfaces/DataLayoutInterfaces.h"12 13using namespace mlir;14 15LogicalResult mlir::impl::verifyHasDefaultDLTIDataLayoutTrait(Operation *op) {16  // TODO: consider having trait inheritance so that HasDefaultDLTIDataLayout17  // trait can inherit DataLayoutOpInterface::Trait and enforce the validity of18  // the assertion below.19  assert(20      isa<DataLayoutOpInterface>(op) &&21      "HasDefaultDLTIDataLayout trait unexpectedly attached to an op that does "22      "not implement DataLayoutOpInterface");23  return success();24}25 26DataLayoutSpecInterface mlir::impl::getDataLayoutSpec(Operation *op) {27  return op->getAttrOfType<DataLayoutSpecInterface>(28      DLTIDialect::kDataLayoutAttrName);29}30 31TargetSystemSpecInterface mlir::impl::getTargetSystemSpec(Operation *op) {32  return op->getAttrOfType<TargetSystemSpecAttr>(33      DLTIDialect::kTargetSystemDescAttrName);34}35