CIRCT 20.0.0git
Loading...
Searching...
No Matches
HandshakeOps.h
Go to the documentation of this file.
1//===- Ops.h - Handshake MLIR Operations ------------------------*- 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// This file defines convenience types for working with handshake operations.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef CIRCT_HANDSHAKEOPS_OPS_H_
14#define CIRCT_HANDSHAKEOPS_OPS_H_
15
19#include "circt/Support/LLVM.h"
20#include "mlir/IR/Attributes.h"
21#include "mlir/IR/Builders.h"
22#include "mlir/IR/BuiltinOps.h"
23#include "mlir/IR/BuiltinTypes.h"
24#include "mlir/IR/Dialect.h"
25#include "mlir/IR/OpDefinition.h"
26#include "mlir/IR/OpImplementation.h"
27#include "mlir/IR/Operation.h"
28#include "mlir/IR/RegionKindInterface.h"
29#include "mlir/IR/TypeSupport.h"
30#include "mlir/IR/Types.h"
31#include "mlir/Interfaces/CallInterfaces.h"
32#include "mlir/Interfaces/FunctionInterfaces.h"
33#include "mlir/Interfaces/InferTypeOpInterface.h"
34#include "mlir/Interfaces/SideEffectInterfaces.h"
35#include "mlir/Pass/Pass.h"
36#include "llvm/ADT/Any.h"
37
38namespace mlir {
39namespace OpTrait {
40template <typename ConcreteType>
41class HasClock : public TraitBase<ConcreteType, HasClock> {};
42
43template <typename InterfaceType>
45public:
46 template <typename ConcreteType>
47 class Impl : public TraitBase<ConcreteType,
48 HasParentInterface<InterfaceType>::Impl> {
49 public:
50 static LogicalResult verifyTrait(Operation *op) {
51 if (llvm::isa_and_nonnull<InterfaceType>(op->getParentOp()))
52 return success();
53
54 // @mortbopet: What a horrible error message - however, there's no way to
55 // report the interface name without going in and adjusting the tablegen
56 // backend to also emit string literal names for interfaces.
57 return op->emitOpError() << "expects parent op to be of the interface "
58 "parent type required by the given op type";
59 }
60 };
61};
62
63} // namespace OpTrait
64} // namespace mlir
65
66#define GET_ATTRDEF_CLASSES
67#include "circt/Dialect/Handshake/HandshakeAttributes.h.inc"
68
69#define GET_OP_CLASSES
70#include "circt/Dialect/Handshake/Handshake.h.inc"
71
72#endif // MLIR_HANDSHAKEOPS_OPS_H_
static LogicalResult verifyTrait(Operation *op)