12 using namespace circt;
17 SmallVectorImpl<OpAsmParser::UnresolvedOperand> &inputs,
18 SmallVectorImpl<Type> &inputTypes, ArrayAttr &inputNames) {
20 SmallVector<Attribute> argNames;
23 if (parser.parseKeywordOrString(&portName))
27 inputTypes.push_back({});
28 return failure(parser.parseColon() || parser.parseOperand(inputs.back()) ||
29 parser.parseColon() || parser.parseType(inputTypes.back()));
31 llvm::SMLoc inputsOperandsLoc;
32 if (parser.getCurrentLocation(&inputsOperandsLoc) ||
33 parser.parseCommaSeparatedList(OpAsmParser::Delimiter::Paren,
43 OperandRange inputs, TypeRange inputTypes,
44 ArrayAttr inputNames) {
46 llvm::interleaveComma(llvm::zip(inputs, inputNames), p,
47 [&](std::tuple<Value, Attribute> input) {
48 Value val = std::get<0>(input);
49 p.printKeywordOrString(
50 cast<StringAttr>(std::get<1>(input)).getValue());
51 p <<
": " << val <<
": " << val.getType();
57 SmallVectorImpl<Type> &resultTypes,
58 ArrayAttr &resultNames) {
60 SmallVector<Attribute> names;
61 auto parseResultPort = [&]() -> ParseResult {
63 if (parser.parseKeywordOrString(&portName))
66 resultTypes.push_back({});
67 return parser.parseColonType(resultTypes.back());
69 llvm::SMLoc inputsOperandsLoc;
70 if (parser.getCurrentLocation(&inputsOperandsLoc) ||
71 parser.parseCommaSeparatedList(OpAsmParser::Delimiter::Paren,
81 TypeRange resultTypes, ArrayAttr resultNames) {
83 llvm::interleaveComma(llvm::zip(resultTypes, resultNames), p,
84 [&](std::tuple<Type, Attribute> result) {
85 p.printKeywordOrString(
86 cast<StringAttr>(std::get<1>(result)).getValue());
87 p <<
": " << std::get<0>(result);
93 ArrayAttr ¶meters) {
94 SmallVector<Attribute> params;
96 auto parseParameter = [&]() {
101 if (parser.parseKeywordOrString(&name) || parser.parseColonType(type))
105 if (succeeded(parser.parseOptionalEqual())) {
106 if (parser.parseAttribute(value, type))
110 auto &builder = parser.getBuilder();
112 builder.getContext(), builder.getStringAttr(name), type, value));
116 if (failed(parser.parseCommaSeparatedList(
117 OpAsmParser::Delimiter::OptionalLessGreater, parseParameter)))
126 ArrayAttr parameters) {
127 if (parameters.empty())
131 llvm::interleaveComma(parameters, p, [&](Attribute param) {
132 auto paramAttr = cast<ParamDeclAttr>(param);
133 p << paramAttr.getName().getValue() <<
": " << paramAttr.getType();
134 if (
auto value = paramAttr.getValue()) {
136 p.printAttributeWithoutType(value);
static ParseResult parseInputPort(OpAsmParser &parser, module_like_impl::PortParse &result)
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
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 ¶meters)
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.