CIRCT  20.0.0git
CustomDirectiveImpl.h
Go to the documentation of this file.
1 //===- CustomDirectiveImpl.h - Table-gen custom directive impl --*- 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 common custom directives for table-gen assembly formats.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef CIRCT_DIALECT_HW_CUSTOMDIRECTIVEIMPL_H
14 #define CIRCT_DIALECT_HW_CUSTOMDIRECTIVEIMPL_H
15 
16 #include "circt/Support/LLVM.h"
17 #include "mlir/IR/Builders.h"
18 #include "mlir/IR/OpImplementation.h"
19 
20 namespace circt {
21 
22 //===----------------------------------------------------------------------===//
23 // InputPortList Custom Directive
24 //===----------------------------------------------------------------------===//
25 
26 /// Parse a list of instance input ports.
27 /// input-list ::= `(` ( input-element (`,` input-element )* )? `)`
28 /// input-element ::= identifier `:` value `:` type
29 ParseResult
30 parseInputPortList(OpAsmParser &parser,
31  SmallVectorImpl<OpAsmParser::UnresolvedOperand> &inputs,
32  SmallVectorImpl<Type> &inputTypes, ArrayAttr &inputNames);
33 
34 /// Print a list of instance input ports.
35 void printInputPortList(OpAsmPrinter &p, Operation *op, OperandRange inputs,
36  TypeRange inputTypes, ArrayAttr inputNames);
37 
38 //===----------------------------------------------------------------------===//
39 // OutputPortList Custom Directive
40 //===----------------------------------------------------------------------===//
41 
42 /// Parse a list of instance output ports.
43 /// output-list ::= `(` ( output-element (`,` output-element )* )? `)`
44 /// output-element ::= identifier `:` type
45 ParseResult parseOutputPortList(OpAsmParser &parser,
46  SmallVectorImpl<Type> &resultTypes,
47  ArrayAttr &resultNames);
48 
49 /// Print a list of instance output ports.
50 void printOutputPortList(OpAsmPrinter &p, Operation *op, TypeRange resultTypes,
51  ArrayAttr resultNames);
52 
53 //===----------------------------------------------------------------------===//
54 // OptionalParameterList Custom Directive
55 //===----------------------------------------------------------------------===//
56 
57 /// Parse an parameter list if present.
58 /// module-parameter-list ::= `<` parameter-decl (`,` parameter-decl)* `>`
59 /// parameter-decl ::= identifier `:` type
60 /// parameter-decl ::= identifier `:` type `=` attribute
61 ParseResult parseOptionalParameterList(OpAsmParser &parser,
62  ArrayAttr &parameters);
63 
64 /// Print a parameter list for a module or instance.
65 void printOptionalParameterList(OpAsmPrinter &p, Operation *op,
66  ArrayAttr parameters);
67 
68 } // namespace circt
69 
70 #endif // CIRCT_DIALECT_HW_CUSTOMDIRECTIVEIMPL_H
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
ParseResult parseInputPortList(OpAsmParser &parser, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &inputs, SmallVectorImpl< Type > &inputTypes, ArrayAttr &inputNames)
Parse a list of instance input ports.
void printOutputPortList(OpAsmPrinter &p, Operation *op, TypeRange resultTypes, ArrayAttr resultNames)
Print a list of instance output ports.
ParseResult parseOptionalParameterList(OpAsmParser &parser, ArrayAttr &parameters)
Parse an parameter list if present.
void printOptionalParameterList(OpAsmPrinter &p, Operation *op, ArrayAttr parameters)
Print a parameter list for a module or instance.
void printInputPortList(OpAsmPrinter &p, Operation *op, OperandRange inputs, TypeRange inputTypes, ArrayAttr inputNames)
Print a list of instance input ports.
ParseResult parseOutputPortList(OpAsmParser &parser, SmallVectorImpl< Type > &resultTypes, ArrayAttr &resultNames)
Parse a list of instance output ports.