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