CIRCT  20.0.0git
ModuleImplementation.h
Go to the documentation of this file.
1 //===- ModuleImplementation.h - Module-like Op utilities --------*- 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 provides utility functions for implementing module-like
10 // operations, in particular, parsing, and printing common to module-like
11 // operations.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef CIRCT_DIALECT_HW_MODULEIMPLEMENTATION_H
16 #define CIRCT_DIALECT_HW_MODULEIMPLEMENTATION_H
17 
19 #include "circt/Support/LLVM.h"
20 #include "mlir/IR/DialectImplementation.h"
21 
22 namespace circt {
23 namespace hw {
24 
25 class HWModuleLike;
26 
27 namespace module_like_impl {
28 
29 struct PortParse : OpAsmParser::Argument {
31  std::string rawName;
32 };
33 
34 /// This is a variant of mlir::parseFunctionSignature that allows names on
35 /// result arguments.
37  OpAsmParser &parser, bool &isVariadic,
38  SmallVectorImpl<OpAsmParser::Argument> &args,
39  SmallVectorImpl<Attribute> &argNames, SmallVectorImpl<Attribute> &argLocs,
40  SmallVectorImpl<Attribute> &resultNames,
41  SmallVectorImpl<DictionaryAttr> &resultAttrs,
42  SmallVectorImpl<Attribute> &resultLocs, TypeAttr &type);
43 
44 /// Print a module signature with named results.
45 void printModuleSignature(OpAsmPrinter &p, Operation *op,
46  ArrayRef<Type> argTypes, bool isVariadic,
47  ArrayRef<Type> resultTypes, bool &needArgNamesAttr);
48 
49 /// New Style parsing
50 ParseResult parseModuleSignature(OpAsmParser &parser,
51  SmallVectorImpl<PortParse> &args,
52  TypeAttr &modType);
53 
54 void printModuleSignatureNew(OpAsmPrinter &p, Region &body,
55  hw::ModuleType modType,
56  ArrayRef<Attribute> portAttrs,
57  ArrayRef<Location> locAttrs);
58 void printModuleSignatureNew(OpAsmPrinter &p, HWModuleLike op);
59 void getAsmBlockArgumentNamesImpl(mlir::Region &region,
60  OpAsmSetValueNameFn setNameFn);
61 
62 SmallVector<Location> getAllPortLocsImpl(hw::ModuleType modType);
63 
64 } // namespace module_like_impl
65 } // namespace hw
66 } // namespace circt
67 
68 #endif // CIRCT_DIALECT_HW_MODULEIMPLEMENTATION_H
void printModuleSignature(OpAsmPrinter &p, Operation *op, ArrayRef< Type > argTypes, bool isVariadic, ArrayRef< Type > resultTypes, bool &needArgNamesAttr)
Print a module signature with named results.
ParseResult parseModuleSignature(OpAsmParser &parser, SmallVectorImpl< PortParse > &args, TypeAttr &modType)
New Style parsing.
ParseResult parseModuleFunctionSignature(OpAsmParser &parser, bool &isVariadic, SmallVectorImpl< OpAsmParser::Argument > &args, SmallVectorImpl< Attribute > &argNames, SmallVectorImpl< Attribute > &argLocs, SmallVectorImpl< Attribute > &resultNames, SmallVectorImpl< DictionaryAttr > &resultAttrs, SmallVectorImpl< Attribute > &resultLocs, TypeAttr &type)
This is a variant of mlir::parseFunctionSignature that allows names on result arguments.
void getAsmBlockArgumentNamesImpl(mlir::Region &region, OpAsmSetValueNameFn setNameFn)
Get a special name to use when printing the entry block arguments of the region contained by an opera...
void printModuleSignatureNew(OpAsmPrinter &p, Region &body, hw::ModuleType modType, ArrayRef< Attribute > portAttrs, ArrayRef< Location > locAttrs)
SmallVector< Location > getAllPortLocsImpl(hw::ModuleType modType)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
Definition: hw.py:1
function_ref< void(Value, StringRef)> OpAsmSetValueNameFn
Definition: LLVM.h:182