CIRCT 20.0.0git
Loading...
Searching...
No Matches
HandshakeUtils.h
Go to the documentation of this file.
1//===- HandshakeUtils.h -----------------------------------------*- 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 CIRCT_DIALECT_HANDSHAKE_HANDSHAKEUTILS_H
10#define CIRCT_DIALECT_HANDSHAKE_HANDSHAKEUTILS_H
11
15#include "circt/Support/LLVM.h"
16#include <map>
17
18namespace circt {
19namespace handshake {
20
21/// Iterates over the handshake::FuncOp's in the program to build an instance
22/// graph. In doing so, we detect whether there are any cycles in this graph, as
23/// well as infer a top function for the design by performing a topological sort
24/// of the instance graph. The result of this sort is placed in sortedFuncs.
25using InstanceGraph = std::map<std::string, std::set<std::string>>;
26LogicalResult resolveInstanceGraph(ModuleOp moduleOp,
27 InstanceGraph &instanceGraph,
28 std::string &topLevel,
29 SmallVectorImpl<std::string> &sortedFuncs);
30
31/// Checks all block arguments and values within op to ensure that all
32/// values have exactly one use.
34
35/// Attribute name for the name of a predeclaration of the to-be-lowered
36/// hw.module from a handshake function.
37static constexpr const char *kPredeclarationAttr = "handshake.module_name";
38
39/// Converts 't' into a valid HW type. This is strictly used for converting
40/// 'index' types into a fixed-width type.
41Type toValidType(Type t);
42
43/// Wraps a type into an ESI ChannelType type. The inner type is converted to
44/// ensure comprehensability by the RTL dialects.
46
47/// Returns the hw::ModulePortInfo that corresponds to the given handshake
48/// operation and its in- and output types.
49hw::ModulePortInfo getPortInfoForOpTypes(mlir::Operation *op, TypeRange inputs,
50 TypeRange outputs);
51
52/// Adds fork operations to any value with multiple uses in r.
53void insertFork(Value result, bool isLazy, OpBuilder &rewriter);
54
55} // namespace handshake
56} // namespace circt
57
58#endif // CIRCT_DIALECT_HANDSHAKE_HANDSHAKEUTILS_H
Channels are the basic communication primitives.
Definition Types.h:63
hw::ModulePortInfo getPortInfoForOpTypes(mlir::Operation *op, TypeRange inputs, TypeRange outputs)
Returns the hw::ModulePortInfo that corresponds to the given handshake operation and its in- and outp...
std::map< std::string, std::set< std::string > > InstanceGraph
Iterates over the handshake::FuncOp's in the program to build an instance graph.
LogicalResult resolveInstanceGraph(ModuleOp moduleOp, InstanceGraph &instanceGraph, std::string &topLevel, SmallVectorImpl< std::string > &sortedFuncs)
Iterates over the handshake::FuncOp's in the program to build an instance graph.
static constexpr const char * kPredeclarationAttr
Attribute name for the name of a predeclaration of the to-be-lowered hw.module from a handshake funct...
esi::ChannelType esiWrapper(Type t)
Wraps a type into an ESI ChannelType type.
LogicalResult verifyAllValuesHasOneUse(handshake::FuncOp op)
Checks all block arguments and values within op to ensure that all values have exactly one use.
void insertFork(Value result, bool isLazy, OpBuilder &rewriter)
Adds fork operations to any value with multiple uses in r.
Type toValidType(Type t)
Converts 't' into a valid HW type.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
This holds a decoded list of input/inout and output ports for a module or instance.