CIRCT 23.0.0git
Loading...
Searching...
No Matches
OMOps.cpp
Go to the documentation of this file.
1//===- OMOps.cpp - Object Model operation definitions ---------------------===//
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 contains the Object Model operation definitions.
10//
11//===----------------------------------------------------------------------===//
12
17#include "mlir/IR/Builders.h"
18#include "mlir/IR/ImplicitLocOpBuilder.h"
19#include "mlir/IR/SymbolTable.h"
20#include "llvm/ADT/STLExtras.h"
21
22using namespace mlir;
23using namespace circt::om;
24
25//===----------------------------------------------------------------------===//
26// Custom Printers and Parsers
27//===----------------------------------------------------------------------===//
28
29static ParseResult parseBasePathString(OpAsmParser &parser, PathAttr &path) {
30 auto *context = parser.getContext();
31 auto loc = parser.getCurrentLocation();
32 std::string rawPath;
33 if (parser.parseString(&rawPath))
34 return failure();
35 if (parseBasePath(context, rawPath, path))
36 return parser.emitError(loc, "invalid base path");
37 return success();
38}
39
40static void printBasePathString(OpAsmPrinter &p, Operation *op, PathAttr path) {
41 p << '\"';
42 llvm::interleave(
43 path, p,
44 [&](const PathElement &elt) {
45 p << elt.module.getValue() << '/' << elt.instance.getValue();
46 },
47 ":");
48 p << '\"';
49}
50
51static ParseResult parsePathString(OpAsmParser &parser, PathAttr &path,
52 StringAttr &module, StringAttr &ref,
53 StringAttr &field) {
54
55 auto *context = parser.getContext();
56 auto loc = parser.getCurrentLocation();
57 std::string rawPath;
58 if (parser.parseString(&rawPath))
59 return failure();
60 if (parsePath(context, rawPath, path, module, ref, field))
61 return parser.emitError(loc, "invalid path");
62 return success();
63}
64
65static void printPathString(OpAsmPrinter &p, Operation *op, PathAttr path,
66 StringAttr module, StringAttr ref,
67 StringAttr field) {
68 p << '\"';
69 for (const auto &elt : path)
70 p << elt.module.getValue() << '/' << elt.instance.getValue() << ':';
71 if (!module.getValue().empty())
72 p << module.getValue();
73 if (!ref.getValue().empty())
74 p << '>' << ref.getValue();
75 if (!field.getValue().empty())
76 p << field.getValue();
77 p << '\"';
78}
79
80static ParseResult parseFieldLocs(OpAsmParser &parser, ArrayAttr &fieldLocs) {
81 if (parser.parseOptionalKeyword("field_locs"))
82 return success();
83 if (parser.parseLParen() || parser.parseAttribute(fieldLocs) ||
84 parser.parseRParen()) {
85 return failure();
86 }
87 return success();
88}
89
90static void printFieldLocs(OpAsmPrinter &printer, Operation *op,
91 ArrayAttr fieldLocs) {
92 mlir::OpPrintingFlags flags;
93 if (!flags.shouldPrintDebugInfo() || !fieldLocs)
94 return;
95 printer << "field_locs(";
96 printer.printAttribute(fieldLocs);
97 printer << ")";
98}
99
100//===----------------------------------------------------------------------===//
101// Shared definitions
102//===----------------------------------------------------------------------===//
103static ParseResult parseClassFieldsList(OpAsmParser &parser,
104 SmallVectorImpl<Attribute> &fieldNames,
105 SmallVectorImpl<Type> &fieldTypes) {
106
107 llvm::StringMap<SMLoc> nameLocMap;
108 auto parseElt = [&]() -> ParseResult {
109 // Parse the field name.
110 std::string fieldName;
111 if (parser.parseKeywordOrString(&fieldName))
112 return failure();
113 SMLoc currLoc = parser.getCurrentLocation();
114 if (nameLocMap.count(fieldName)) {
115 parser.emitError(currLoc, "field \"")
116 << fieldName << "\" is defined twice";
117 parser.emitError(nameLocMap[fieldName]) << "previous definition is here";
118 return failure();
119 }
120 nameLocMap[fieldName] = currLoc;
121 fieldNames.push_back(StringAttr::get(parser.getContext(), fieldName));
122
123 // Parse the field type.
124 fieldTypes.emplace_back();
125 if (parser.parseColonType(fieldTypes.back()))
126 return failure();
127
128 return success();
129 };
130
131 return parser.parseCommaSeparatedList(OpAsmParser::Delimiter::Paren,
132 parseElt);
133}
134
135static ParseResult parseClassLike(OpAsmParser &parser, OperationState &state) {
136 // Parse the optional symbol visibility.
137 (void)mlir::impl::parseOptionalVisibilityKeyword(parser, state.attributes);
138
139 // Parse the Class symbol name.
140 StringAttr symName;
141 if (parser.parseSymbolName(symName, mlir::SymbolTable::getSymbolAttrName(),
142 state.attributes))
143 return failure();
144
145 // Parse the formal parameters.
146 SmallVector<OpAsmParser::Argument> args;
147 if (parser.parseArgumentList(args, OpAsmParser::Delimiter::Paren,
148 /*allowType=*/true, /*allowAttrs=*/false))
149 return failure();
150
151 SmallVector<Type> fieldTypes;
152 SmallVector<Attribute> fieldNames;
153 if (succeeded(parser.parseOptionalArrow()))
154 if (failed(parseClassFieldsList(parser, fieldNames, fieldTypes)))
155 return failure();
156
157 SmallVector<NamedAttribute> fieldTypesMap;
158 if (!fieldNames.empty()) {
159 for (auto [name, type] : zip(fieldNames, fieldTypes))
160 fieldTypesMap.push_back(
161 NamedAttribute(cast<StringAttr>(name), TypeAttr::get(type)));
162 }
163 auto *ctx = parser.getContext();
164 state.addAttribute("fieldNames", mlir::ArrayAttr::get(ctx, fieldNames));
165 state.addAttribute("fieldTypes",
166 mlir::DictionaryAttr::get(ctx, fieldTypesMap));
167
168 // Parse the optional attribute dictionary.
169 if (failed(parser.parseOptionalAttrDictWithKeyword(state.attributes)))
170 return failure();
171
172 // Parse the body.
173 Region *region = state.addRegion();
174 if (parser.parseRegion(*region, args))
175 return failure();
176
177 // If the region was empty, add an empty block so it's still a SizedRegion<1>.
178 if (region->empty())
179 region->emplaceBlock();
180
181 // Remember the formal parameter names in an attribute.
182 auto argNames = llvm::map_range(args, [&](OpAsmParser::Argument arg) {
183 return StringAttr::get(parser.getContext(), arg.ssaName.name.drop_front());
184 });
185 state.addAttribute(
186 "formalParamNames",
187 ArrayAttr::get(parser.getContext(), SmallVector<Attribute>(argNames)));
188
189 return success();
190}
191
192static void printClassLike(ClassLike classLike, OpAsmPrinter &printer) {
193 printer << " ";
194
195 // Print the optional symbol visibility.
196 StringRef visibilityAttrName = SymbolTable::getVisibilityAttrName();
197 if (auto visibility =
198 classLike->getAttrOfType<StringAttr>(visibilityAttrName))
199 printer << visibility.getValue() << ' ';
200
201 // Print the Class symbol name.
202 printer.printSymbolName(classLike.getSymName());
203
204 // Retrieve the formal parameter names and values.
205 auto argNames = SmallVector<StringRef>(
206 classLike.getFormalParamNames().getAsValueRange<StringAttr>());
207 ArrayRef<BlockArgument> args = classLike.getBodyBlock()->getArguments();
208
209 // Print the formal parameters.
210 printer << '(';
211 for (size_t i = 0, e = args.size(); i < e; ++i) {
212 printer << '%' << argNames[i] << ": " << args[i].getType();
213 if (i < e - 1)
214 printer << ", ";
215 }
216 printer << ") ";
217
218 ArrayRef<Attribute> fieldNames =
219 cast<ArrayAttr>(classLike->getAttr("fieldNames")).getValue();
220
221 if (!fieldNames.empty()) {
222 printer << " -> (";
223 for (size_t i = 0, e = fieldNames.size(); i < e; ++i) {
224 if (i != 0)
225 printer << ", ";
226 StringAttr name = cast<StringAttr>(fieldNames[i]);
227 printer.printKeywordOrString(name.getValue());
228 printer << ": ";
229 Type type = classLike.getFieldType(name).value();
230 printer.printType(type);
231 }
232 printer << ") ";
233 }
234
235 // Print the optional attribute dictionary.
236 SmallVector<StringRef> elidedAttrs{
237 classLike.getSymNameAttrName(), classLike.getFormalParamNamesAttrName(),
238 visibilityAttrName, "fieldTypes", "fieldNames"};
239 printer.printOptionalAttrDictWithKeyword(classLike.getOperation()->getAttrs(),
240 elidedAttrs);
241
242 // Print the body.
243 printer.printRegion(classLike.getBody(), /*printEntryBlockArgs=*/false,
244 /*printBlockTerminators=*/true);
245}
246
247LogicalResult verifyClassLike(ClassLike classLike) {
248 // Verify the formal parameter names match up with the values.
249 if (classLike.getFormalParamNames().size() !=
250 classLike.getBodyBlock()->getArguments().size()) {
251 auto error = classLike.emitOpError(
252 "formal parameter name list doesn't match formal parameter value list");
253 error.attachNote(classLike.getLoc())
254 << "formal parameter names: " << classLike.getFormalParamNames();
255 error.attachNote(classLike.getLoc())
256 << "formal parameter values: "
257 << classLike.getBodyBlock()->getArguments();
258 return error;
259 }
260
261 return success();
262}
263
264void getClassLikeAsmBlockArgumentNames(ClassLike classLike, Region &region,
265 OpAsmSetValueNameFn setNameFn) {
266 // Retrieve the formal parameter names and values.
267 auto argNames = SmallVector<StringRef>(
268 classLike.getFormalParamNames().getAsValueRange<StringAttr>());
269 ArrayRef<BlockArgument> args = classLike.getBodyBlock()->getArguments();
270
271 // Use the formal parameter names as the SSA value names.
272 for (size_t i = 0, e = args.size(); i < e; ++i)
273 setNameFn(args[i], argNames[i]);
274}
275
276NamedAttribute makeFieldType(StringAttr name, Type type) {
277 return NamedAttribute(name, TypeAttr::get(type));
278}
279
280NamedAttribute makeFieldIdx(MLIRContext *ctx, mlir::StringAttr name,
281 unsigned i) {
282 return NamedAttribute(StringAttr(name),
283 mlir::IntegerAttr::get(mlir::IndexType::get(ctx), i));
284}
285
286std::optional<Type> getClassLikeFieldType(ClassLike classLike,
287 StringAttr name) {
288 DictionaryAttr fieldTypes = mlir::cast<DictionaryAttr>(
289 classLike.getOperation()->getAttr("fieldTypes"));
290 Attribute type = fieldTypes.get(name);
291 if (auto field = dyn_cast_or_null<TypeAttr>(type))
292 return field.getValue();
293 return std::nullopt;
294}
295
296void replaceClassLikeFieldTypes(ClassLike classLike,
297 AttrTypeReplacer &replacer) {
298 classLike->setAttr("fieldTypes", cast<DictionaryAttr>(replacer.replace(
299 classLike.getFieldTypes())));
300}
301
302//===----------------------------------------------------------------------===//
303// ClassOp
304//===----------------------------------------------------------------------===//
305
306ParseResult circt::om::ClassOp::parse(OpAsmParser &parser,
307 OperationState &state) {
308 return parseClassLike(parser, state);
309}
310
311circt::om::ClassOp circt::om::ClassOp::buildSimpleClassOp(
312 OpBuilder &odsBuilder, Location loc, Twine name,
313 ArrayRef<StringRef> formalParamNames, ArrayRef<StringRef> fieldNames,
314 ArrayRef<Type> fieldTypes) {
315 circt::om::ClassOp classOp = circt::om::ClassOp::create(
316 odsBuilder, loc, odsBuilder.getStringAttr(name),
317 odsBuilder.getStrArrayAttr(formalParamNames),
318 odsBuilder.getStrArrayAttr(fieldNames),
319 odsBuilder.getDictionaryAttr(llvm::map_to_vector(
320 llvm::zip(fieldNames, fieldTypes), [&](auto field) -> NamedAttribute {
321 return NamedAttribute(odsBuilder.getStringAttr(std::get<0>(field)),
322 TypeAttr::get(std::get<1>(field)));
323 })));
324 Block *body = &classOp.getRegion().emplaceBlock();
325 auto prevLoc = odsBuilder.saveInsertionPoint();
326 odsBuilder.setInsertionPointToEnd(body);
327
328 mlir::SmallVector<Attribute> locAttrs(fieldNames.size(), LocationAttr(loc));
329
330 ClassFieldsOp::create(odsBuilder, loc,
331 llvm::map_to_vector(fieldTypes,
332 [&](Type type) -> Value {
333 return body->addArgument(type,
334 loc);
335 }),
336 odsBuilder.getArrayAttr(locAttrs));
337
338 odsBuilder.restoreInsertionPoint(prevLoc);
339
340 return classOp;
341}
342
343void circt::om::ClassOp::print(OpAsmPrinter &printer) {
344 printClassLike(*this, printer);
345}
346
347LogicalResult circt::om::ClassOp::verify() { return verifyClassLike(*this); }
348
349LogicalResult circt::om::ClassOp::verifyRegions() {
350 auto fieldsOp =
351 dyn_cast_or_null<ClassFieldsOp>(this->getBodyBlock()->getTerminator());
352 if (!fieldsOp)
353 return this->emitOpError("expected terminator to be ClassFieldsOp");
354
355 // The number of results matches the number of terminator operands.
356 if (fieldsOp.getNumOperands() != this->getFieldNames().size()) {
357 auto diag = this->emitOpError()
358 << "returns '" << this->getFieldNames().size()
359 << "' fields, but its terminator returned '"
360 << fieldsOp.getNumOperands() << "' fields";
361 return diag.attachNote(fieldsOp.getLoc()) << "see terminator:";
362 }
363
364 // The type of each result matches the corresponding terminator operand type.
365 auto types = this->getFieldTypes();
366 for (auto [fieldName, terminatorOperandType] :
367 llvm::zip(this->getFieldNames(), fieldsOp.getOperandTypes())) {
368
369 auto fieldNameAttr = dyn_cast_or_null<StringAttr>(fieldName);
370 if (!fieldNameAttr)
371 return this->emitOpError("field name is not a StringAttr");
372
373 if (auto fieldType = types.get(fieldNameAttr))
374 if (auto typeAttr = dyn_cast<TypeAttr>(fieldType))
375 if (typeAttr.getValue() == terminatorOperandType)
376 continue;
377
378 auto diag = this->emitOpError()
379 << "returns different field types than its terminator";
380 return diag.attachNote(fieldsOp.getLoc()) << "see terminator:";
381 }
382
383 return success();
384}
385
386void circt::om::ClassOp::getAsmBlockArgumentNames(
387 Region &region, OpAsmSetValueNameFn setNameFn) {
388 getClassLikeAsmBlockArgumentNames(*this, region, setNameFn);
389}
390
391std::optional<mlir::Type>
392circt::om::ClassOp::getFieldType(mlir::StringAttr field) {
393 return getClassLikeFieldType(*this, field);
394}
395
396void circt::om::ClassOp::replaceFieldTypes(AttrTypeReplacer replacer) {
397 replaceClassLikeFieldTypes(*this, replacer);
398}
399
400void circt::om::ClassOp::updateFields(
401 mlir::ArrayRef<mlir::Location> newLocations,
402 mlir::ArrayRef<mlir::Value> newValues,
403 mlir::ArrayRef<mlir::Attribute> newNames) {
404
405 auto fieldsOp = getFieldsOp();
406 assert(fieldsOp && "The fields op should exist");
407 // Get field names.
408 SmallVector<Attribute> names(getFieldNamesAttr().getAsRange<StringAttr>());
409 // Get the field types.
410 SmallVector<NamedAttribute> fieldTypes(getFieldTypesAttr().getValue());
411 // Get the field values.
412 SmallVector<Value> fieldVals(fieldsOp.getFields());
413 // Get the field locations.
414 Location fieldOpLoc = fieldsOp->getLoc();
415
416 // Extract the locations per field.
417 SmallVector<Location> locations;
418 if (auto fl = dyn_cast<FusedLoc>(fieldOpLoc)) {
419 auto metadataArr = dyn_cast<ArrayAttr>(fl.getMetadata());
420 assert(metadataArr && "Expected the metadata for the fused location");
421 auto r = metadataArr.getAsRange<LocationAttr>();
422 locations.append(r.begin(), r.end());
423 } else {
424 // Assume same loc for every field.
425 locations.append(names.size(), fieldOpLoc);
426 }
427
428 // Append the new names, locations and values.
429 names.append(newNames.begin(), newNames.end());
430 locations.append(newLocations.begin(), newLocations.end());
431 fieldVals.append(newValues.begin(), newValues.end());
432
433 // Construct the new field types from values and names.
434 for (auto [v, n] : llvm::zip(newValues, newNames))
435 fieldTypes.emplace_back(
436 NamedAttribute(llvm::cast<StringAttr>(n), TypeAttr::get(v.getType())));
437
438 // Keep the locations as array on the metadata.
439 SmallVector<Attribute> locationsAttr;
440 llvm::for_each(locations, [&](Location &l) {
441 locationsAttr.push_back(cast<Attribute>(l));
442 });
443
444 ImplicitLocOpBuilder builder(getLoc(), *this);
445 // Update the field names attribute.
446 setFieldNamesAttr(builder.getArrayAttr(names));
447 // Update the fields type attribute.
448 setFieldTypesAttr(builder.getDictionaryAttr(fieldTypes));
449 fieldsOp.getFieldsMutable().assign(fieldVals);
450 // Update the location.
451 fieldsOp->setLoc(builder.getFusedLoc(
452 locations, ArrayAttr::get(getContext(), locationsAttr)));
453}
454
455void circt::om::ClassOp::addNewFieldsOp(mlir::OpBuilder &builder,
456 mlir::ArrayRef<Location> locs,
457 mlir::ArrayRef<Value> values) {
458 // Store the original locations as a metadata array so that unique locations
459 // are preserved as a mapping from field index to location
460 assert(locs.size() == values.size() && "Expected a location per value");
461 mlir::SmallVector<Attribute> locAttrs;
462 for (auto loc : locs) {
463 locAttrs.push_back(cast<Attribute>(LocationAttr(loc)));
464 }
465 // Also store the locations incase there's some other analysis that might
466 // be able to use the default FusedLoc representation.
467 ClassFieldsOp::create(builder, builder.getFusedLoc(locs), values,
468 builder.getArrayAttr(locAttrs));
469}
470
471mlir::Location circt::om::ClassOp::getFieldLocByIndex(size_t i) {
472 auto fieldsOp = this->getFieldsOp();
473 auto fieldLocs = fieldsOp.getFieldLocs();
474 if (!fieldLocs.has_value())
475 return fieldsOp.getLoc();
476 assert(i < fieldLocs.value().size() &&
477 "field index too large for location array");
478 return cast<LocationAttr>(fieldLocs.value()[i]);
479}
480
481//===----------------------------------------------------------------------===//
482// ClassExternOp
483//===----------------------------------------------------------------------===//
484
485ParseResult circt::om::ClassExternOp::parse(OpAsmParser &parser,
486 OperationState &state) {
487 return parseClassLike(parser, state);
488}
489
490void circt::om::ClassExternOp::print(OpAsmPrinter &printer) {
491 printClassLike(*this, printer);
492}
493
494LogicalResult circt::om::ClassExternOp::verify() {
495 if (failed(verifyClassLike(*this))) {
496 return failure();
497 }
498 // Verify body is empty
499 if (!this->getBodyBlock()->getOperations().empty()) {
500 return this->emitOpError("external class body should be empty");
501 }
502
503 return success();
504}
505
506void circt::om::ClassExternOp::getAsmBlockArgumentNames(
507 Region &region, OpAsmSetValueNameFn setNameFn) {
508 getClassLikeAsmBlockArgumentNames(*this, region, setNameFn);
509}
510
511std::optional<mlir::Type>
512circt::om::ClassExternOp::getFieldType(mlir::StringAttr field) {
513 return getClassLikeFieldType(*this, field);
514}
515
516void circt::om::ClassExternOp::replaceFieldTypes(AttrTypeReplacer replacer) {
517 replaceClassLikeFieldTypes(*this, replacer);
518}
519
520//===----------------------------------------------------------------------===//
521// ClassFieldsOp
522//===----------------------------------------------------------------------===//
523//
524LogicalResult circt::om::ClassFieldsOp::verify() {
525 auto fieldLocs = this->getFieldLocs();
526 if (fieldLocs.has_value()) {
527 auto fieldLocsVal = fieldLocs.value();
528 if (fieldLocsVal.size() != this->getFields().size()) {
529 auto error = this->emitOpError("size of field_locs (")
530 << fieldLocsVal.size()
531 << ") does not match number of fields ("
532 << this->getFields().size() << ")";
533 }
534 }
535 return success();
536}
537
538//===----------------------------------------------------------------------===//
539// ObjectOp
540//===----------------------------------------------------------------------===//
541
542void circt::om::ObjectOp::build(::mlir::OpBuilder &odsBuilder,
543 ::mlir::OperationState &odsState,
544 om::ClassOp classOp,
545 ::mlir::ValueRange actualParams) {
546 return build(odsBuilder, odsState,
547 om::ClassType::get(odsBuilder.getContext(),
548 mlir::FlatSymbolRefAttr::get(classOp)),
549 classOp.getNameAttr(), actualParams);
550}
551
552static FailureOr<ClassLike>
553verifyClassLikeSymbolUser(Operation *op, SymbolTableCollection &symbolTable,
554 ClassType resultType, StringAttr className) {
555 StringAttr resultClassName = resultType.getClassName().getAttr();
556 if (resultClassName != className)
557 return op->emitOpError("result type (")
558 << resultClassName << ") does not match referred to class ("
559 << className << ')';
560
561 auto classDef = dyn_cast_or_null<ClassLike>(
562 symbolTable.lookupNearestSymbolFrom(op, className));
563 if (!classDef)
564 return op->emitOpError("refers to non-existant class (")
565 << className << ')';
566 return classDef;
567}
568
569LogicalResult
570circt::om::ObjectOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
571 auto classDef = verifyClassLikeSymbolUser(
572 (*this), symbolTable, getResult().getType(), getClassNameAttr());
573 if (failed(classDef))
574 return failure();
575
576 auto actualTypes = getActualParams().getTypes();
577 auto formalTypes = classDef->getBodyBlock()->getArgumentTypes();
578
579 // Verify the actual parameter list matches the formal parameter list.
580 if (actualTypes.size() != formalTypes.size()) {
581 auto error = emitOpError(
582 "actual parameter list doesn't match formal parameter list");
583 error.attachNote(classDef->getLoc())
584 << "formal parameters: " << classDef->getBodyBlock()->getArguments();
585 error.attachNote(getLoc()) << "actual parameters: " << getActualParams();
586 return error;
587 }
588
589 // Verify the actual parameter types match the formal parameter types.
590 for (size_t i = 0, e = actualTypes.size(); i < e; ++i) {
591 if (actualTypes[i] != formalTypes[i]) {
592 return emitOpError("actual parameter type (")
593 << actualTypes[i] << ") doesn't match formal parameter type ("
594 << formalTypes[i] << ')';
595 }
596 }
597
598 return success();
599}
600
601//===----------------------------------------------------------------------===//
602// ObjectFieldOp
603//===----------------------------------------------------------------------===//
604
605LogicalResult
606circt::om::ObjectFieldOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
607 auto classType = getObject().getType();
608 auto className = classType.getClassName().getAttr();
609
610 // Verify the referred-to class exists.
611 auto classDef = dyn_cast_or_null<ClassLike>(
612 symbolTable.lookupNearestSymbolFrom(*this, className));
613 if (!classDef)
614 return emitOpError("class ") << className << " was not found";
615
616 // Verify the field exists in the class.
617 auto fieldName = getFieldAttr();
618 std::optional<Type> fieldType = classDef.getFieldType(fieldName);
619 if (!fieldType) {
620 auto diag = emitOpError("referenced non-existent field ") << fieldName;
621 diag.attachNote(classDef.getLoc()) << "class defined here";
622 return diag;
623 }
624
625 // Verify the result type matches the field type.
626 if (getResult().getType() != fieldType.value())
627 return emitOpError("expected type ")
628 << getResult().getType() << ", but accessed field has type "
629 << fieldType.value();
630 return success();
631}
632
633//===----------------------------------------------------------------------===//
634// ElaboratedObjectOp
635//===----------------------------------------------------------------------===//
636
637void circt::om::ElaboratedObjectOp::build(OpBuilder &odsBuilder,
638 OperationState &odsState,
639 om::ClassLike classOp,
640 ValueRange fieldValues) {
641 return build(odsBuilder, odsState,
642 om::ClassType::get(
643 odsBuilder.getContext(),
644 mlir::FlatSymbolRefAttr::get(classOp.getSymNameAttr())),
645 classOp.getSymNameAttr(), fieldValues);
646}
647
648LogicalResult circt::om::ElaboratedObjectOp::verifySymbolUses(
649 SymbolTableCollection &symbolTable) {
650 auto classDef = verifyClassLikeSymbolUser(
651 (*this), symbolTable, getResult().getType(), getClassNameAttr());
652 if (failed(classDef))
653 return failure();
654
655 auto fieldNames = classDef->getFieldNames();
656 auto fieldValues = getFieldValues();
657 if (fieldValues.size() != fieldNames.size())
658 return emitOpError("field value list doesn't match class field list, "
659 "expected ")
660 << fieldNames.size() << " values but got " << fieldValues.size();
661
662 for (auto [fieldName, fieldValue] : llvm::zip(fieldNames, fieldValues)) {
663 Type expectedType =
664 classDef->getFieldType(cast<StringAttr>(fieldName)).value();
665 if (fieldValue.getType() != expectedType)
666 return emitOpError("field value type for ")
667 << cast<StringAttr>(fieldName) << " (" << fieldValue.getType()
668 << ") doesn't match class field type (" << expectedType << ')';
669 }
670
671 return success();
672}
673
674//===----------------------------------------------------------------------===//
675// ConstantOp
676//===----------------------------------------------------------------------===//
677
678void circt::om::ConstantOp::build(::mlir::OpBuilder &odsBuilder,
679 ::mlir::OperationState &odsState,
680 ::mlir::TypedAttr constVal) {
681 return build(odsBuilder, odsState, constVal.getType(), constVal);
682}
683
684OpFoldResult circt::om::ConstantOp::fold(FoldAdaptor adaptor) {
685 assert(adaptor.getOperands().empty() && "constant has no operands");
686 return getValueAttr();
687}
688
689//===----------------------------------------------------------------------===//
690// ListCreateOp
691//===----------------------------------------------------------------------===//
692
693void circt::om::ListCreateOp::print(OpAsmPrinter &p) {
694 p << " ";
695 p.printOperands(getInputs());
696 p.printOptionalAttrDict((*this)->getAttrs());
697 p << " : " << getType().getElementType();
698}
699
700ParseResult circt::om::ListCreateOp::parse(OpAsmParser &parser,
701 OperationState &result) {
702 llvm::SmallVector<OpAsmParser::UnresolvedOperand, 16> operands;
703 Type elemType;
704
705 if (parser.parseOperandList(operands) ||
706 parser.parseOptionalAttrDict(result.attributes) || parser.parseColon() ||
707 parser.parseType(elemType))
708 return failure();
709 result.addTypes({circt::om::ListType::get(elemType)});
710
711 for (auto operand : operands)
712 if (parser.resolveOperand(operand, elemType, result.operands))
713 return failure();
714 return success();
715}
716
717//===----------------------------------------------------------------------===//
718// BasePathCreateOp
719//===----------------------------------------------------------------------===//
720
721LogicalResult
722BasePathCreateOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
723 auto hierPath = symbolTable.lookupNearestSymbolFrom<hw::HierPathOp>(
724 *this, getTargetAttr());
725 if (!hierPath)
726 return emitOpError("invalid symbol reference");
727 return success();
728}
729
730//===----------------------------------------------------------------------===//
731// PathCreateOp
732//===----------------------------------------------------------------------===//
733
734LogicalResult
735PathCreateOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
736 auto hierPath = symbolTable.lookupNearestSymbolFrom<hw::HierPathOp>(
737 *this, getTargetAttr());
738 if (!hierPath)
739 return emitOpError("invalid symbol reference");
740 return success();
741}
742
743//===----------------------------------------------------------------------===//
744// IntegerBinaryOp (arithmetic)
745//===----------------------------------------------------------------------===//
746
747static OpFoldResult foldIntegerBinaryArithmetic(IntegerBinaryOp op,
748 Attribute lhsAttr,
749 Attribute rhsAttr) {
750 auto lhs = dyn_cast_or_null<circt::om::IntegerAttr>(lhsAttr);
751 auto rhs = dyn_cast_or_null<circt::om::IntegerAttr>(rhsAttr);
752 if (!lhs || !rhs)
753 return {};
754 // Extend values if necessary to match bitwidth. Most interesting arithmetic
755 // on APSInt asserts that both operands are the same bitwidth, but the
756 // IntegerAttrs we are working with may have used the smallest necessary
757 // bitwidth to represent the number they hold, and won't necessarily match.
758 APSInt lhsVal = lhs.getValue().getAPSInt();
759 APSInt rhsVal = rhs.getValue().getAPSInt();
760 if (lhsVal.getBitWidth() > rhsVal.getBitWidth())
761 rhsVal = rhsVal.extend(lhsVal.getBitWidth());
762 else if (rhsVal.getBitWidth() > lhsVal.getBitWidth())
763 lhsVal = lhsVal.extend(rhsVal.getBitWidth());
764
765 // Perform arbitrary precision signed integer binary arithmetic.
766 auto result = op.evaluateIntegerOperation(lhsVal, rhsVal);
767 if (failed(result))
768 return {};
769
770 auto *ctx = op.getContext();
771 // Return the result as a new om::IntegerAttr.
772 return circt::om::IntegerAttr::get(
773 ctx, mlir::IntegerAttr::get(ctx, result.value()));
774}
775
776//===----------------------------------------------------------------------===//
777// IntegerAddOp
778//===----------------------------------------------------------------------===//
779
780FailureOr<llvm::APSInt>
781IntegerAddOp::evaluateIntegerOperation(const llvm::APSInt &lhs,
782 const llvm::APSInt &rhs) {
783 return success(lhs + rhs);
784}
785
786OpFoldResult IntegerAddOp::fold(FoldAdaptor adaptor) {
787 return foldIntegerBinaryArithmetic(*this, adaptor.getLhs(), adaptor.getRhs());
788}
789
790//===----------------------------------------------------------------------===//
791// IntegerMulOp
792//===----------------------------------------------------------------------===//
793
794FailureOr<llvm::APSInt>
795IntegerMulOp::evaluateIntegerOperation(const llvm::APSInt &lhs,
796 const llvm::APSInt &rhs) {
797 return success(lhs * rhs);
798}
799
800OpFoldResult IntegerMulOp::fold(FoldAdaptor adaptor) {
801 return foldIntegerBinaryArithmetic(*this, adaptor.getLhs(), adaptor.getRhs());
802}
803
804//===----------------------------------------------------------------------===//
805// IntegerShrOp
806//===----------------------------------------------------------------------===//
807
808FailureOr<llvm::APSInt>
809IntegerShrOp::evaluateIntegerOperation(const llvm::APSInt &lhs,
810 const llvm::APSInt &rhs) {
811 // Check non-negative constraint from operation semantics.
812 if (!rhs.isNonNegative())
813 return emitOpError("shift amount must be non-negative");
814 // Check size constraint from implementation detail of using getExtValue.
815 if (!rhs.isRepresentableByInt64())
816 return emitOpError("shift amount must be representable in 64 bits");
817 return success(lhs >> rhs.getExtValue());
818}
819
820OpFoldResult IntegerShrOp::fold(FoldAdaptor adaptor) {
821 return foldIntegerBinaryArithmetic(*this, adaptor.getLhs(), adaptor.getRhs());
822}
823
824//===----------------------------------------------------------------------===//
825// IntegerShlOp
826//===----------------------------------------------------------------------===//
827
828FailureOr<llvm::APSInt>
829IntegerShlOp::evaluateIntegerOperation(const llvm::APSInt &lhs,
830 const llvm::APSInt &rhs) {
831 // Check non-negative constraint from operation semantics.
832 if (!rhs.isNonNegative())
833 return emitOpError("shift amount must be non-negative");
834 // Check size constraint from implementation detail of using getExtValue.
835 if (!rhs.isRepresentableByInt64())
836 return emitOpError("shift amount must be representable in 64 bits");
837 return success(lhs << rhs.getExtValue());
838}
839
840OpFoldResult IntegerShlOp::fold(FoldAdaptor adaptor) {
841 return foldIntegerBinaryArithmetic(*this, adaptor.getLhs(), adaptor.getRhs());
842}
843
844//===----------------------------------------------------------------------===//
845// StringConcatOp
846//===----------------------------------------------------------------------===//
847
848OpFoldResult StringConcatOp::fold(FoldAdaptor adaptor) {
849 // Fold single-operand concat to just the operand.
850 if (getStrings().size() == 1) {
851 if (auto strAttr = adaptor.getStrings()[0])
852 return strAttr;
853
854 return getStrings()[0];
855 }
856
857 // Check if all operands are constant strings before accumulating.
858 if (!llvm::all_of(adaptor.getStrings(), [](Attribute operand) {
859 return isa_and_nonnull<StringAttr>(operand);
860 }))
861 return {};
862
863 // All operands are constant strings, concatenate them.
864 SmallString<64> result;
865 for (auto operand : adaptor.getStrings())
866 result += cast<StringAttr>(operand).getValue();
867
868 return StringAttr::get(result, getResult().getType());
869}
870
871namespace {
872/// Flatten nested string.concat operations into a single concat.
873/// string.concat(a, string.concat(b, c), d) -> string.concat(a, b, c, d)
874class FlattenOMStringConcat : public mlir::OpRewritePattern<StringConcatOp> {
875public:
876 using OpRewritePattern::OpRewritePattern;
877
878 LogicalResult
879 matchAndRewrite(StringConcatOp concat,
880 mlir::PatternRewriter &rewriter) const override {
881
882 // Check if any operands are nested concats with a single use. Only inline
883 // single-use nested concats to avoid fighting with DCE.
884 bool hasNestedConcat = llvm::any_of(concat.getStrings(), [](Value operand) {
885 auto nestedConcat = operand.getDefiningOp<StringConcatOp>();
886 return nestedConcat && operand.hasOneUse();
887 });
888
889 if (!hasNestedConcat)
890 return failure();
891
892 // Flatten nested concats that have a single use.
893 SmallVector<Value> flatOperands;
894 for (auto input : concat.getStrings()) {
895 if (auto nestedConcat = input.getDefiningOp<StringConcatOp>();
896 nestedConcat && input.hasOneUse())
897 llvm::append_range(flatOperands, nestedConcat.getStrings());
898 else
899 flatOperands.push_back(input);
900 }
901
902 rewriter.modifyOpInPlace(concat,
903 [&]() { concat->setOperands(flatOperands); });
904 return success();
905 }
906};
907
908/// Merge consecutive constant strings in a concat and remove empty strings.
909/// string.concat("a", "b", x, "", "c", "d") -> string.concat("ab", x, "cd")
910class MergeAdjacentOMStringConstants
911 : public mlir::OpRewritePattern<StringConcatOp> {
912public:
913 using OpRewritePattern::OpRewritePattern;
914
915 LogicalResult
916 matchAndRewrite(StringConcatOp concat,
917 mlir::PatternRewriter &rewriter) const override {
918
919 SmallVector<Value> newOperands;
920 SmallString<64> accumulatedLit;
921 SmallVector<ConstantOp> accumulatedOps;
922 bool changed = false;
923
924 auto flushLiterals = [&]() {
925 if (accumulatedOps.empty())
926 return;
927
928 // If only one literal, reuse it.
929 if (accumulatedOps.size() == 1) {
930 newOperands.push_back(accumulatedOps[0]);
931 } else {
932 // Multiple literals - merge them.
933 auto newLit = rewriter.createOrFold<ConstantOp>(
934 concat.getLoc(),
935 StringAttr::get(accumulatedLit, concat.getResult().getType()));
936 newOperands.push_back(newLit);
937 changed = true;
938 }
939 accumulatedLit.clear();
940 accumulatedOps.clear();
941 };
942
943 for (auto operand : concat.getStrings()) {
944 if (auto litOp = operand.getDefiningOp<ConstantOp>()) {
945 if (auto strAttr = dyn_cast<StringAttr>(litOp.getValue())) {
946 // Skip empty strings.
947 if (strAttr.getValue().empty()) {
948 changed = true;
949 continue;
950 }
951 accumulatedLit += strAttr.getValue();
952 accumulatedOps.push_back(litOp);
953 continue;
954 }
955 }
956
957 flushLiterals();
958 newOperands.push_back(operand);
959 }
960
961 // Flush any remaining literals.
962 flushLiterals();
963
964 if (!changed)
965 return failure();
966
967 // If no operands remain, replace with empty string.
968 if (newOperands.empty())
969 return rewriter.replaceOpWithNewOp<ConstantOp>(
970 concat, StringAttr::get("", concat.getResult().getType())),
971 success();
972
973 // Single-operand case is handled by the folder.
974 rewriter.modifyOpInPlace(concat,
975 [&]() { concat->setOperands(newOperands); });
976 return success();
977 }
978};
979
980} // namespace
981
982void StringConcatOp::getCanonicalizationPatterns(RewritePatternSet &results,
983 MLIRContext *context) {
984 results.insert<FlattenOMStringConcat, MergeAdjacentOMStringConstants>(
985 context);
986}
987
988//===----------------------------------------------------------------------===//
989// PropEqOp
990//===----------------------------------------------------------------------===//
991
992FailureOr<mlir::Attribute>
993PropEqOp::evaluateBinaryEquality(mlir::Attribute lhsAttr,
994 mlir::Attribute rhsAttr) {
995 auto resultType = mlir::IntegerType::get(getContext(), 1);
996
997 // String equality.
998 if (auto lhs = dyn_cast<mlir::StringAttr>(lhsAttr))
999 if (auto rhs = dyn_cast<mlir::StringAttr>(rhsAttr))
1000 return mlir::Attribute(
1001 mlir::IntegerAttr::get(resultType, lhs == rhs ? 1 : 0));
1002
1003 // OM integer equality (arbitrary precision).
1004 if (auto lhs = dyn_cast<om::IntegerAttr>(lhsAttr))
1005 if (auto rhs = dyn_cast<om::IntegerAttr>(rhsAttr)) {
1006 APSInt lhsVal = lhs.getValue().getAPSInt();
1007 APSInt rhsVal = rhs.getValue().getAPSInt();
1008 if (lhsVal.getBitWidth() > rhsVal.getBitWidth())
1009 rhsVal = rhsVal.extend(lhsVal.getBitWidth());
1010 else if (rhsVal.getBitWidth() > lhsVal.getBitWidth())
1011 lhsVal = lhsVal.extend(rhsVal.getBitWidth());
1012 return mlir::Attribute(
1013 mlir::IntegerAttr::get(resultType, lhsVal == rhsVal ? 1 : 0));
1014 }
1015
1016 // Boolean (i1) equality.
1017 if (auto lhs = dyn_cast<mlir::IntegerAttr>(lhsAttr))
1018 if (auto rhs = dyn_cast<mlir::IntegerAttr>(rhsAttr))
1019 return mlir::Attribute(
1020 mlir::IntegerAttr::get(resultType, lhs == rhs ? 1 : 0));
1021
1022 return failure();
1023}
1024
1025OpFoldResult PropEqOp::fold(FoldAdaptor adaptor) {
1026 auto lhsAttr = adaptor.getLhs();
1027 auto rhsAttr = adaptor.getRhs();
1028 if (!lhsAttr || !rhsAttr)
1029 return {};
1030
1031 auto result = evaluateBinaryEquality(lhsAttr, rhsAttr);
1032 if (failed(result))
1033 return {};
1034
1035 return *result;
1036}
1037
1038//===----------------------------------------------------------------------===//
1039// IntegerAndOp / IntegerOrOp / IntegerXorOp
1040//===----------------------------------------------------------------------===//
1041
1042static OpFoldResult foldIntegerBitwise(IntegerBinaryOp op, Attribute lhsAttr,
1043 Attribute rhsAttr) {
1044 auto lhsInt = dyn_cast_or_null<mlir::IntegerAttr>(lhsAttr);
1045 auto rhsInt = dyn_cast_or_null<mlir::IntegerAttr>(rhsAttr);
1046 if (!lhsInt || !rhsInt)
1047 return {};
1048 APSInt lhsVal(lhsInt.getValue());
1049 APSInt rhsVal(rhsInt.getValue());
1050 auto result = op.evaluateIntegerOperation(lhsVal, rhsVal);
1051 if (failed(result))
1052 return {};
1053 return mlir::IntegerAttr::get(
1054 lhsInt.getType(), result->extOrTrunc(lhsInt.getValue().getBitWidth()));
1055}
1056
1057// Returns true if attr is an IntegerAttr whose value is all-zeros.
1058static bool isZeroInt(Attribute a) {
1059 auto i = dyn_cast_or_null<mlir::IntegerAttr>(a);
1060 return i && i.getValue().isZero();
1061}
1062
1063// Returns true if attr is an IntegerAttr whose value is all-ones.
1064static bool isAllOnesInt(Attribute a) {
1065 auto i = dyn_cast_or_null<mlir::IntegerAttr>(a);
1066 return i && i.getValue().isAllOnes();
1067}
1068
1069FailureOr<APSInt> IntegerAndOp::evaluateIntegerOperation(const APSInt &lhs,
1070 const APSInt &rhs) {
1071 return success(APSInt(lhs & rhs, /*isUnsigned=*/false));
1072}
1073
1074OpFoldResult IntegerAndOp::fold(FoldAdaptor adaptor) {
1075 if (auto result =
1076 foldIntegerBitwise(*this, adaptor.getLhs(), adaptor.getRhs()))
1077 return result;
1078 // AND with all-zeros is always zero.
1079 if (isZeroInt(adaptor.getLhs()) || isZeroInt(adaptor.getRhs()))
1080 return mlir::IntegerAttr::get(getResult().getType(),
1081 APInt::getZero(getType().getWidth()));
1082 // AND with all-ones is identity.
1083 if (isAllOnesInt(adaptor.getLhs()))
1084 return getRhs();
1085 if (isAllOnesInt(adaptor.getRhs()))
1086 return getLhs();
1087 return {};
1088}
1089
1090FailureOr<APSInt> IntegerOrOp::evaluateIntegerOperation(const APSInt &lhs,
1091 const APSInt &rhs) {
1092 return success(APSInt(lhs | rhs, /*isUnsigned=*/false));
1093}
1094
1095OpFoldResult IntegerOrOp::fold(FoldAdaptor adaptor) {
1096 if (auto result =
1097 foldIntegerBitwise(*this, adaptor.getLhs(), adaptor.getRhs()))
1098 return result;
1099 // OR with all-ones is always all-ones.
1100 if (isAllOnesInt(adaptor.getLhs()) || isAllOnesInt(adaptor.getRhs()))
1101 return mlir::IntegerAttr::get(getResult().getType(),
1102 APInt::getAllOnes(getType().getWidth()));
1103 // OR with all-zeros is identity.
1104 if (isZeroInt(adaptor.getLhs()))
1105 return getRhs();
1106 if (isZeroInt(adaptor.getRhs()))
1107 return getLhs();
1108 return {};
1109}
1110
1111FailureOr<APSInt> IntegerXorOp::evaluateIntegerOperation(const APSInt &lhs,
1112 const APSInt &rhs) {
1113 return success(APSInt(lhs ^ rhs, /*isUnsigned=*/false));
1114}
1115
1116OpFoldResult IntegerXorOp::fold(FoldAdaptor adaptor) {
1117 if (auto result =
1118 foldIntegerBitwise(*this, adaptor.getLhs(), adaptor.getRhs()))
1119 return result;
1120 // XOR with all-zeros is identity.
1121 if (isZeroInt(adaptor.getLhs()))
1122 return getRhs();
1123 if (isZeroInt(adaptor.getRhs()))
1124 return getLhs();
1125 return {};
1126}
1127
1128//===----------------------------------------------------------------------===//
1129// UnknownValueOp
1130//===----------------------------------------------------------------------===//
1131
1132LogicalResult circt::om::UnknownValueOp::verifySymbolUses(
1133 SymbolTableCollection &symbolTable) {
1134
1135 // Unknown values of non-class type don't need to be verified.
1136 auto classType = dyn_cast<ClassType>(getType());
1137 if (!classType)
1138 return success();
1139
1140 // Verify the referred to ClassOp exists.
1141 auto className = classType.getClassName();
1142 if (symbolTable.lookupNearestSymbolFrom<ClassLike>(*this, className))
1143 return success();
1144
1145 return emitOpError() << "refers to non-existant class (\""
1146 << className.getValue() << "\")";
1147}
1148
1149//===----------------------------------------------------------------------===//
1150// TableGen generated logic.
1151//===----------------------------------------------------------------------===//
1152
1153#define GET_OP_CLASSES
1154#include "circt/Dialect/OM/OM.cpp.inc"
assert(baseType &&"element must be base type")
static std::unique_ptr< Context > context
static Location getLoc(DefSlot slot)
Definition Mem2Reg.cpp:218
static ParseResult parseClassLike(OpAsmParser &parser, OperationState &state)
Definition OMOps.cpp:135
LogicalResult verifyClassLike(ClassLike classLike)
Definition OMOps.cpp:247
std::optional< Type > getClassLikeFieldType(ClassLike classLike, StringAttr name)
Definition OMOps.cpp:286
void getClassLikeAsmBlockArgumentNames(ClassLike classLike, Region &region, OpAsmSetValueNameFn setNameFn)
Definition OMOps.cpp:264
static ParseResult parseBasePathString(OpAsmParser &parser, PathAttr &path)
Definition OMOps.cpp:29
static ParseResult parsePathString(OpAsmParser &parser, PathAttr &path, StringAttr &module, StringAttr &ref, StringAttr &field)
Definition OMOps.cpp:51
static void printBasePathString(OpAsmPrinter &p, Operation *op, PathAttr path)
Definition OMOps.cpp:40
static OpFoldResult foldIntegerBitwise(IntegerBinaryOp op, Attribute lhsAttr, Attribute rhsAttr)
Definition OMOps.cpp:1042
static FailureOr< ClassLike > verifyClassLikeSymbolUser(Operation *op, SymbolTableCollection &symbolTable, ClassType resultType, StringAttr className)
Definition OMOps.cpp:553
static void printFieldLocs(OpAsmPrinter &printer, Operation *op, ArrayAttr fieldLocs)
Definition OMOps.cpp:90
static OpFoldResult foldIntegerBinaryArithmetic(IntegerBinaryOp op, Attribute lhsAttr, Attribute rhsAttr)
Definition OMOps.cpp:747
static bool isZeroInt(Attribute a)
Definition OMOps.cpp:1058
static ParseResult parseFieldLocs(OpAsmParser &parser, ArrayAttr &fieldLocs)
Definition OMOps.cpp:80
static ParseResult parseClassFieldsList(OpAsmParser &parser, SmallVectorImpl< Attribute > &fieldNames, SmallVectorImpl< Type > &fieldTypes)
Definition OMOps.cpp:103
static void printClassLike(ClassLike classLike, OpAsmPrinter &printer)
Definition OMOps.cpp:192
void replaceClassLikeFieldTypes(ClassLike classLike, AttrTypeReplacer &replacer)
Definition OMOps.cpp:296
NamedAttribute makeFieldType(StringAttr name, Type type)
Definition OMOps.cpp:276
NamedAttribute makeFieldIdx(MLIRContext *ctx, mlir::StringAttr name, unsigned i)
Definition OMOps.cpp:280
static void printPathString(OpAsmPrinter &p, Operation *op, PathAttr path, StringAttr module, StringAttr ref, StringAttr field)
Definition OMOps.cpp:65
static bool isAllOnesInt(Attribute a)
Definition OMOps.cpp:1064
static Block * getBodyBlock(FModuleLike mod)
static InstancePath empty
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
Definition CalyxOps.cpp:56
uint64_t getWidth(Type t)
Definition ESIPasses.cpp:32
void error(Twine message)
Definition LSPUtils.cpp:16
ParseResult parsePath(MLIRContext *context, StringRef spelling, PathAttr &path, StringAttr &module, StringAttr &ref, StringAttr &field)
Parse a target string in to a path.
Definition OMUtils.cpp:182
ParseResult parseBasePath(MLIRContext *context, StringRef spelling, PathAttr &path)
Parse a target string of the form "Foo/bar:Bar/baz" in to a base path.
Definition OMUtils.cpp:177
function_ref< void(Value, StringRef)> OpAsmSetValueNameFn
Definition LLVM.h:193
A module name, and the name of an instance inside that module.
mlir::StringAttr mlir::StringAttr instance